Completed
Push — master ( a4efa7...8c7a15 )
by Jace
08:04 queued 22s
created

TestLines.test_quotes_are_escaped()   A

Complexity

Conditions 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 2
dl 0
loc 4
rs 10
1
# pylint: disable=no-self-use
2
# pylint: disable=misplaced-comparison-constant
0 ignored issues
show
introduced by
Bad option value 'misplaced-comparison-constant'
Loading history...
3
4
from memegen.domain import Text
5
6
7
class TestInit:
8
9
    def test_none(self):
10
        text = Text()
11
12
        assert "" == text.top
13
        assert "" == text.bottom
14
15
    def test_0_slashes(self):
16
        text = Text("foo")
17
18
        assert "FOO" == text.top
19
        assert "" == text.bottom
20
21
    def test_1_slash(self):
22
        text = Text("foo/bar")
23
24
        assert "FOO" == text.top
25
        assert "BAR" == text.bottom
26
        assert "" == text.get_line(2)
27
28
    def test_2_slashes(self):
29
        text = Text("foo/bar/qux")
30
31
        assert "FOO" == text.top
32
        assert "BAR" == text.bottom
33
        assert "QUX" == text.get_line(2)
34
        assert "" == text.get_line(3)
35
36
37
class TestBool:
38
39
    def test_content_is_truthy(self):
40
        assert True is bool(Text("Hello, world!"))
41
42
    def test_empty_is_falsey(self):
43
        assert False is bool(Text())
44
45
    def test_only_spaces_is_falsey(self):
46
        assert False is bool(Text("_/_/_"))
47
48
49
class TestLines:
50
51
    def test_split_underscore_as_spaces(self):
52
        text = Text("hello_world")
53
54
        assert ["HELLO WORLD"] == text.lines
55
56
    def test_split_dash_as_spaces(self):
57
        text = Text("hello-world")
58
59
        assert ["HELLO WORLD"] == text.lines
60
61
    def test_split_case_as_spaces(self):
62
        text = Text("helloWorld")
63
64
        assert ["HELLO WORLD"] == text.lines
65
66
    def test_keep_spaces(self):
67
        text = Text("hello world")
68
69
        assert ["HELLO WORLD"] == text.lines
70
71
    def test_case_ignored_after_space(self):
72
        text = Text("HELLO WORLD")
73
74
        assert ["HELLO WORLD"] == text.lines
75
76
    def test_ignore_initial_capital(self):
77
        text = Text("HelloWorld")
78
79
        assert ["HELLO WORLD"] == text.lines
80
81
    def test_ignore_capital_after_sep(self):
82
        text = Text("hello-World")
83
84
        assert ["HELLO WORLD"] == text.lines
85
86
    def test_ignore_capital_after_apostrophe(self):
87
        text = Text("Y'ALL")
88
89
        assert ["Y'ALL"] == text.lines
90
91
    def test_strip_spaces(self):
92
        text = Text("  hello  World /    ")
93
94
        assert ["HELLO  WORLD"] == text.lines
95
96
    def test_duplicate_capitals_treated_as_spaces(self):
97
        text = Text("IWantTHISPattern_to-Work")
98
99
        assert ["I WANT THIS PATTERN TO WORK"] == text.lines
100
101
    def test_no_space_after_apostrophe(self):
102
        text = Text("that'd be great")
103
104
        assert ["THAT'D BE GREAT"] == text.lines
105
106
    def test_double_dashes_are_escaped(self):
107
        text = Text("i'm----  /working 9--5")
108
109
        assert ["I'M--", "WORKING 9-5"] == text.lines
110
111
    def test_double_underscores_are_escaped(self):
112
        text = Text("Calls ____init____/with __args")
113
114
        assert ["CALLS __INIT__", "WITH _ARGS"] == text.lines
115
116
    def test_special_characters_are_kept(self):
117
        text = Text("special?")
118
119
        assert ["SPECIAL?"] == text.lines
120
121
    def test_question_marks_are_escaped(self):
122
        text = Text("special~q~Q")
123
124
        assert ["SPECIAL??"] == text.lines
125
126
    def test_percents_are_escaped(self):
127
        text = Text("99~p vs. 1~P")
128
129
        assert ["99% VS. 1%"] == text.lines
130
131
    def test_quotes_are_escaped(self):
132
        text = Text("the ''word'' said")
133
134
        assert ['THE "WORD" SAID'] == text.lines
135
136
137
class TestPath:
138
139
    def test_case_ignored(self):
140
        text = Text("hello/World")
141
142
        assert "hello/world" == text.path
143
144
    def test_single_dashes_kept(self):
145
        text = Text("with-dashes/in-it")
146
147
        assert "with-dashes/in-it" == text.path
148
149
    def test_underscores_become_dashes(self):
150
        text = Text("with_underscores/in_it")
151
152
        assert "with-underscores/in-it" == text.path
153
154
    def test_case_changes_become_dashes(self):
155
        text = Text("withCaseChanges/InIT")
156
157
        assert "with-case-changes/in-it" == text.path
158
159
    def test_extra_spaces_are_stripped(self):
160
        text = Text("  with  spaces/  in it   / ")
161
162
        assert "with--spaces/in-it" == text.path
163
164
    def test_single_underscore_is_kept(self):
165
        text = Text(" _     ")
166
167
        assert "_" == text.path
168
169
    def test_duplicate_capitals_are_ignored(self):
170
        text = Text("IWantTHISPattern_to-Work")
171
172
        assert "i-want-this-pattern-to-work" == text.path
173
174
    def test_double_dashes_are_escaped(self):
175
        text = Text("i'm----  /working 9--5")
176
177
        assert "i'm----/working-9--5" == text.path
178
179
    def test_double_underscores_are_escaped(self):
180
        text = Text("Calls ____init____/with __args")
181
182
        assert "calls-____init____/with-__args" == text.path
183
184
    def test_question_marks_are_escaped(self):
185
        text = Text("special?")
186
187
        assert "special~q" == text.path
188
189
    def test_percents_are_escaped(self):
190
        text = Text("50% off")
191
192
        assert "50~p-off" == text.path
193
194
    def test_quotes_are_escaped(self):
195
        text = Text('"quoted"')
196
197
        assert "''quoted''" == text.path
198