Passed
Push — master ( 00d837...bc5250 )
by Jace
49s
created

TestBool   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Importance

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