Passed
Push — master ( 19f245...563a46 )
by Jace
01:59
created

tests.test_images   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 343
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 234
dl 0
loc 343
rs 10
c 0
b 0
f 0
wmc 2

1 Function

Rating   Name   Duplication   Size   Complexity  
B describe_get() 0 326 2
1
# pylint: disable=unused-variable,unused-argument,misplaced-comparison-constant,expression-not-assigned,singleton-comparison
2
3
import os
4
5
import pytest
0 ignored issues
show
introduced by
Unable to import 'pytest'
Loading history...
6
from expecter import expect
0 ignored issues
show
introduced by
Unable to import 'expecter'
Loading history...
7
8
from memegen.routes.image import cache_filtered, cache_unfiltered
9
10
from .utils import load
11
12
TESTS = os.path.dirname(__file__)
13
ROOT = os.path.dirname(TESTS)
14
IMAGES = os.path.join(ROOT, 'data', 'images')
15
16
17
def describe_get():
18
19
    def describe_visible():
0 ignored issues
show
Unused Code introduced by
The variable describe_visible seems to be unused.
Loading history...
20
21
        def with_nominal_text(client):
0 ignored issues
show
Unused Code introduced by
The variable with_nominal_text seems to be unused.
Loading history...
22
            path = os.path.join(IMAGES, 'iw', 'hello', 'world' + '.img')
23
            if os.path.exists(path):
24
                os.remove(path)
25
26
            response = client.get("/iw/hello/world.jpg?watermark=none")
27
28
            expect(response.status_code) == 200
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(response.status_code) == 200 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
29
            expect(response.mimetype) == 'image/jpeg'
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(response.mimetype) == 'image/jpeg' does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
30
            expect(os.path.isfile(path)) == True
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(os.path.isfile(path)) == True does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
introduced by
Comparison to True should be just 'expr' or 'expr is True'
Loading history...
31
32
        def with_only_1_line(client):
0 ignored issues
show
Unused Code introduced by
The variable with_only_1_line seems to be unused.
Loading history...
33
            response = client.get("/iw/hello.jpg")
34
35
            expect(response.status_code) == 200
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(response.status_code) == 200 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
36
            expect(response.mimetype) == 'image/jpeg'
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(response.mimetype) == 'image/jpeg' does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
37
38
        @pytest.mark.xfail(os.name == 'nt', reason="Windows has a path limit")
39
        def with_lots_of_text(client):
0 ignored issues
show
Unused Code introduced by
The variable with_lots_of_text seems to be unused.
Loading history...
40
            top = "_".join(["hello"] * 20)
41
            bottom = "_".join(["world"] * 20)
42
            response = client.get("/iw/" + top + "/" + bottom + ".jpg")
43
44
            expect(response.status_code) == 200
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(response.status_code) == 200 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
45
            expect(response.mimetype) == 'image/jpeg'
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(response.mimetype) == 'image/jpeg' does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
46
47
    def describe_hidden():
0 ignored issues
show
Unused Code introduced by
The variable describe_hidden seems to be unused.
Loading history...
48
49
        def when_jpg(client):
0 ignored issues
show
Unused Code introduced by
The variable when_jpg seems to be unused.
Loading history...
50
            response = client.get("/_aXcJaGVsbG8vd29ybGQJ.jpg")
51
52
            expect(response.status_code) == 200
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(response.status_code) == 200 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
53
            expect(response.mimetype) == 'image/jpeg'
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(response.mimetype) == 'image/jpeg' does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
54
55
    def describe_custom_style():
0 ignored issues
show
Unused Code introduced by
The variable describe_custom_style seems to be unused.
Loading history...
56
57
        def when_provided(client):
0 ignored issues
show
Unused Code introduced by
The variable when_provided seems to be unused.
Loading history...
58
            response = client.get("/sad-biden/hello.jpg?alt=scowl")
59
60
            expect(response.status_code) == 200
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(response.status_code) == 200 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
61
            expect(response.mimetype) == 'image/jpeg'
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(response.mimetype) == 'image/jpeg' does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
62
63
        def it_redirects_to_lose_alt_when_default_style(client):
0 ignored issues
show
Unused Code introduced by
The variable it_redirects_to_lose_alt_when_default_style seems to be unused.
Loading history...
64
            status, data = load(client.get("/sad-biden/hello.jpg?alt=default"))
65
66
            expect(status) == 302
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(status) == 302 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
67
            expect(data).contains('<a href="/sad-biden/hello.jpg">')
68
69
        def it_redirects_to_lose_alt_when_unknown_style(client):
0 ignored issues
show
Unused Code introduced by
The variable it_redirects_to_lose_alt_when_unknown_style seems to be unused.
Loading history...
70
            status, data = load(client.get(
71
                "/sad-biden/hello.jpg?alt=__unknown__"))
72
73
            expect(status) == 302
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(status) == 302 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
74
            expect(data).contains('<a href="/sad-biden/hello.jpg">')
75
76
        def it_keeps_alt_after_template_redirect(client):
0 ignored issues
show
Unused Code introduced by
The variable it_keeps_alt_after_template_redirect seems to be unused.
Loading history...
77
            status, data = load(client.get("/sad-joe/hello.jpg?alt=scowl"))
78
79
            expect(status) == 302
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(status) == 302 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
80
            expect(data).contains('<a href="/sad-biden/hello.jpg?alt=scowl">')
81
82
        def it_keeps_alt_after_text_redirect(client):
0 ignored issues
show
Unused Code introduced by
The variable it_keeps_alt_after_text_redirect seems to be unused.
Loading history...
83
            status, data = load(client.get("/sad-biden.jpg?alt=scowl"))
84
85
            expect(status) == 302
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(status) == 302 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
86
            expect(data).contains("_vote.jpg")
87
            expect(data).contains("alt=scowl")
88
89
        def it_redirects_to_custom_when_alt_is_url(client):
0 ignored issues
show
Unused Code introduced by
The variable it_redirects_to_custom_when_alt_is_url seems to be unused.
Loading history...
90
            url = "http://www.gstatic.com/webp/gallery/1.jpg"
91
            status, data = load(client.get(f"/sad-biden/hello.jpg?alt={url}"))
92
93
            expect(status) == 302
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(status) == 302 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
94
            expect(data).contains(f'<a href="/custom/hello.jpg?alt={url}">')
95
96
        def it_redirects_to_standard_when_alt_is_builtin(client):
0 ignored issues
show
Unused Code introduced by
The variable it_redirects_to_standard_when_alt_is_builtin seems to be unused.
Loading history...
97
            url = "https://memegen.link/cbg/_.jpg"
98
            status, data = load(client.get(f"/custom/hello.jpg?alt={url}"))
99
100
            expect(status) == 302
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(status) == 302 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
101
            expect(data).contains(f'<a href="/cbg/hello.jpg">')
102
103
        def it_returns_an_error_with_non_image_urls(client):
0 ignored issues
show
Unused Code introduced by
The variable it_returns_an_error_with_non_image_urls seems to be unused.
Loading history...
104
            url = "http://example.com"
105
            response = client.get(f"/custom/hello.jpg?alt={url}")
106
107
            expect(response.status_code) == 415
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(response.status_code) == 415 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
108
109
        def it_returns_an_error_with_non_urls(client):
0 ignored issues
show
Unused Code introduced by
The variable it_returns_an_error_with_non_urls seems to be unused.
Loading history...
110
            url = "undefined"
111
            response = client.get(f"/custom/hello.jpg?alt={url}")
112
113
            print(response.data)
114
            expect(response.status_code) == 415
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(response.status_code) == 415 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
115
116
        def it_handles_png_int32_pixels(client):
0 ignored issues
show
Unused Code introduced by
The variable it_handles_png_int32_pixels seems to be unused.
Loading history...
117
            url = "https://raw.githubusercontent.com/jacebrowning/memegen/master/tests/files/201692816359570.jpeg"
118
            response = client.get(f"/custom/hello.jpg?alt={url}")
119
120
            expect(response.status_code) == 200
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(response.status_code) == 200 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
121
            expect(response.mimetype) == 'image/jpeg'
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(response.mimetype) == 'image/jpeg' does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
122
123
        def it_handles_jpg_cmyk_pixels(client):
0 ignored issues
show
Unused Code introduced by
The variable it_handles_jpg_cmyk_pixels seems to be unused.
Loading history...
124
            url = "https://raw.githubusercontent.com/jacebrowning/memegen/master/tests/files/Channel_digital_image_CMYK_color.jpg"
125
            response = client.get(f"/custom/hello.jpg?alt={url}")
126
127
            expect(response.status_code) == 200
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(response.status_code) == 200 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
128
            expect(response.mimetype) == 'image/jpeg'
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(response.mimetype) == 'image/jpeg' does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
129
130
        def it_redirects_to_lose_alt_when_invalid_url(client):
0 ignored issues
show
Unused Code introduced by
The variable it_redirects_to_lose_alt_when_invalid_url seems to be unused.
Loading history...
131
            url = "http:invalid"
132
            status, data = load(client.get(f"/sad-biden/hello.jpg?alt={url}"))
133
134
            expect(status) == 302
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(status) == 302 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
135
            expect(data).contains('<a href="/sad-biden/hello.jpg">')
136
137
        def it_redirects_to_lose_alt_when_missing_schema(client):
0 ignored issues
show
Unused Code introduced by
The variable it_redirects_to_lose_alt_when_missing_schema seems to be unused.
Loading history...
138
            url = "http:/www.gstatic.com/webp/gallery/1.jpg"
139
            status, data = load(client.get(f"/sad-biden/hello.jpg?alt={url}"))
140
141
            expect(status) == 302
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(status) == 302 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
142
            expect(data).contains('<a href="/sad-biden/hello.jpg">')
143
144
    def describe_custom_font():
0 ignored issues
show
Unused Code introduced by
The variable describe_custom_font seems to be unused.
Loading history...
145
146
        def when_provided(client):
0 ignored issues
show
Unused Code introduced by
The variable when_provided seems to be unused.
Loading history...
147
            response = client.get("/iw/hello.jpg?font=impact")
148
149
            expect(response.status_code) == 200
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(response.status_code) == 200 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
150
            expect(response.mimetype) == 'image/jpeg'
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(response.mimetype) == 'image/jpeg' does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
151
152
        def it_redirects_on_unknown_fonts(client):
0 ignored issues
show
Unused Code introduced by
The variable it_redirects_on_unknown_fonts seems to be unused.
Loading history...
153
            status, data = load(client.get("/iw/hello.jpg?font=__unknown__"))
154
155
            expect(status) == 302
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(status) == 302 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
156
            expect(data).contains('<a href="/iw/hello.jpg">')
157
158
        def it_keeps_font_after_redirect(client):
0 ignored issues
show
Unused Code introduced by
The variable it_keeps_font_after_redirect seems to be unused.
Loading history...
159
            status, data = load(client.get("/iw/what%3F.jpg?font=impact"))
160
161
            expect(status) == 302
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(status) == 302 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
162
            expect(data).contains('<a href="/iw/what~q.jpg?font=impact">')
163
164
    def describe_custom_size():
0 ignored issues
show
Unused Code introduced by
The variable describe_custom_size seems to be unused.
Loading history...
165
166
        def it_keeps_size_after_redirect(client):
0 ignored issues
show
Unused Code introduced by
The variable it_keeps_size_after_redirect seems to be unused.
Loading history...
167
            status, data = load(client.get(
168
                "/iw/what%3F.jpg?width=67&height=89"))
169
170
            expect(status) == 302
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(status) == 302 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
171
            expect(data).contains('<a href="/iw/what~q.jpg?')
172
            expect(data).contains('width=67')
173
            expect(data).contains('height=89')
174
175
    def describe_watermark():
0 ignored issues
show
Unused Code introduced by
The variable describe_watermark seems to be unused.
Loading history...
176
177
        def it_is_required_with_text(public_client):
0 ignored issues
show
Unused Code introduced by
The variable it_is_required_with_text seems to be unused.
Loading history...
178
            url = "/iw/test.jpg?watermark=none"
179
            status, data = load(public_client.get(url))
180
181
            expect(status) == 302
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(status) == 302 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
182
            expect(data).contains('<a href="/iw/test.jpg"')
183
184
        def it_accepts_supported_custom_watermarks(client):
0 ignored issues
show
Unused Code introduced by
The variable it_accepts_supported_custom_watermarks seems to be unused.
Loading history...
185
            response = client.get("/iw/test.jpg?watermark=test")
186
187
            expect(response.status_code) == 200
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(response.status_code) == 200 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
188
            expect(response.mimetype) == 'image/jpeg'
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(response.mimetype) == 'image/jpeg' does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
189
190
        def it_redirects_with_unsupported_watermarks(client):
0 ignored issues
show
Unused Code introduced by
The variable it_redirects_with_unsupported_watermarks seems to be unused.
Loading history...
191
            status, data = load(client.get(
192
                "/iw/test.jpg?watermark=unsupported"))
193
194
            expect(status) == 302
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(status) == 302 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
195
            expect(data).contains('<a href="/iw/test.jpg"')
196
197
        def it_keeps_watermark_after_redirect(client):
0 ignored issues
show
Unused Code introduced by
The variable it_keeps_watermark_after_redirect seems to be unused.
Loading history...
198
            status, data = load(client.get("/iw/test 2.jpg?watermark=test"))
199
200
            expect(status) == 302
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(status) == 302 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
201
            expect(data).contains('<a href="/iw/test_2.jpg?watermark=test"')
202
203
        def it_is_disable_when_no_text(public_client):
0 ignored issues
show
Unused Code introduced by
The variable it_is_disable_when_no_text seems to be unused.
Loading history...
204
            response = public_client.get("/iw/_.jpg")
205
206
            expect(response.status_code) == 200
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(response.status_code) == 200 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
207
            expect(response.mimetype) == 'image/jpeg'
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(response.mimetype) == 'image/jpeg' does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
208
209
        def it_redirect_to_be_disabled_when_no_text(client):
0 ignored issues
show
Unused Code introduced by
The variable it_redirect_to_be_disabled_when_no_text seems to be unused.
Loading history...
210
            status, data = load(client.get("/iw/_.jpg?watermark=test"))
211
212
            expect(status) == 302
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(status) == 302 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
213
            expect(data).contains('<a href="/iw/_.jpg"')
214
215
    def describe_preview():
0 ignored issues
show
Unused Code introduced by
The variable describe_preview seems to be unused.
Loading history...
216
217
        def it_keeps_flag_after_redirect(client):
0 ignored issues
show
Unused Code introduced by
The variable it_keeps_flag_after_redirect seems to be unused.
Loading history...
218
            status, data = load(client.get(
219
                "/iw/i am still typi.jpg?preview=true"))
220
221
            expect(status) == 302
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(status) == 302 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
222
            expect(data).contains(
223
                '<a href="/iw/i_am_still_typi.jpg?preview=true">')
224
225
    def describe_latest():
0 ignored issues
show
Unused Code introduced by
The variable describe_latest seems to be unused.
Loading history...
226
227
        @pytest.fixture()
228
        def enable_cache():
0 ignored issues
show
Unused Code introduced by
The variable enable_cache seems to be unused.
Loading history...
229
            cache_filtered.disabled = False
230
            cache_unfiltered.disabled = False
231
            cache_filtered.items = []
232
            cache_unfiltered.items = []
233
234
        @pytest.fixture()
235
        def disable_cache():
0 ignored issues
show
Unused Code introduced by
The variable disable_cache seems to be unused.
Loading history...
236
            cache_filtered.disabled = True
237
            cache_unfiltered.disabled = True
238
            cache_filtered.items = []
239
            cache_unfiltered.items = []
240
241
        def it_returns_the_last_image(client, enable_cache):
0 ignored issues
show
Unused Code introduced by
The argument enable_cache seems to be unused.
Loading history...
Unused Code introduced by
The variable it_returns_the_last_image seems to be unused.
Loading history...
242
            client.get("/iw/my_first_meme.jpg")
243
244
            status, data = load(client.get("/latest.jpg"))
245
246
            expect(status) == 302
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(status) == 302 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
247
            expect(data).contains(
248
                '<a href="http://localhost/iw/my_first_meme.jpg?preview=true">')
249
250
        def it_returns_a_placeholder_with_an_empty_cache(
0 ignored issues
show
Unused Code introduced by
The variable it_returns_a_placeholder_with_an_empty_cache seems to be unused.
Loading history...
251
                client, disable_cache):
0 ignored issues
show
Unused Code introduced by
The argument disable_cache seems to be unused.
Loading history...
252
            status, data = load(client.get("/latest.jpg"))
253
254
            expect(status) == 302
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(status) == 302 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
255
            expect(data).contains(
256
                '<a href="http://localhost/custom/your_meme/goes_here.jpg'
257
                '?alt=https://raw.githubusercontent.com/jacebrowning/memegen/'
258
                'master/memegen/static/images/missing.png">')
259
260
        def it_filters_blocked_words(client, enable_cache):
0 ignored issues
show
Unused Code introduced by
The argument enable_cache seems to be unused.
Loading history...
Unused Code introduced by
The variable it_filters_blocked_words seems to be unused.
Loading history...
261
            client.get("/iw/nazis.jpg")
262
263
            status, data = load(client.get("/latest.jpg"))
264
265
            expect(status) == 302
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(status) == 302 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
266
            expect(data).excludes(
267
                '<a href="http://localhost/iw/nazis.jpg')
268
269
            status, data = load(client.get("/latest.jpg?filtered=false"))
270
271
            expect(status) == 302
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(status) == 302 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
272
            expect(data).contains(
273
                '<a href="http://localhost/iw/nazis.jpg?preview=true">')
274
275
        def it_filters_custom_images(client, enable_cache):
0 ignored issues
show
Unused Code introduced by
The argument enable_cache seems to be unused.
Loading history...
Unused Code introduced by
The variable it_filters_custom_images seems to be unused.
Loading history...
276
            client.get("/custom/test.jpg")
277
278
            status, data = load(client.get("/latest.jpg"))
279
280
            expect(status) == 302
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(status) == 302 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
281
            expect(data).excludes(
282
                '<a href="http://localhost/custom/test.jpg')
283
284
            status, data = load(client.get("/latest.jpg?filtered=false"))
285
286
            expect(status) == 302
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(status) == 302 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
287
            expect(data).contains(
288
                '<a href="http://localhost/custom/test.jpg?preview=true">')
289
290
    def describe_redirects():
0 ignored issues
show
Unused Code introduced by
The variable describe_redirects seems to be unused.
Loading history...
291
292
        def when_missing_dashes(client):
0 ignored issues
show
Unused Code introduced by
The variable when_missing_dashes seems to be unused.
Loading history...
293
            status, data = load(client.get(
294
                "/iw/HelloThere_World/How-areYOU.jpg"))
295
296
            expect(status) == 302
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(status) == 302 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
297
            expect(data).contains(
298
                '<a href="/iw/hello_there_world/how_are_you.jpg">')
299
300
        def when_no_text(client):
0 ignored issues
show
Unused Code introduced by
The variable when_no_text seems to be unused.
Loading history...
301
            status, data = load(client.get("/live.jpg"))
302
303
            expect(status) == 302
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(status) == 302 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
304
            expect(data).contains('<a href="/live/_/do_it_live!.jpg">')
305
306
        def when_aliased_template(client):
0 ignored issues
show
Unused Code introduced by
The variable when_aliased_template seems to be unused.
Loading history...
307
            status, data = load(client.get("/insanity-wolf/hello/world.jpg"))
308
309
            expect(status) == 302
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(status) == 302 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
310
            expect(data).contains('<a href="/iw/hello/world.jpg">')
311
312
        def when_jpeg_extension_without_text(client):
0 ignored issues
show
Unused Code introduced by
The variable when_jpeg_extension_without_text seems to be unused.
Loading history...
313
            status, data = load(client.get("/iw.jpeg"))
314
315
            expect(status) == 302
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(status) == 302 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
316
            expect(data).contains('<a href="/iw.jpg">')
317
318
        def when_jpeg_extension_with_text(client):
0 ignored issues
show
Unused Code introduced by
The variable when_jpeg_extension_with_text seems to be unused.
Loading history...
319
            status, data = load(client.get("/iw/hello/world.jpeg"))
320
321
            expect(status) == 302
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(status) == 302 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
322
            expect(data).contains('<a href="/iw/hello/world.jpg">')
323
324
    def describe_errors():
0 ignored issues
show
Unused Code introduced by
The variable describe_errors seems to be unused.
Loading history...
325
326
        def when_unknown_template(client):
0 ignored issues
show
Unused Code introduced by
The variable when_unknown_template seems to be unused.
Loading history...
327
            response = client.get("/make/sudo/give.me.jpg")
328
329
            expect(response.status_code) == 200
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(response.status_code) == 200 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
330
            expect(response.mimetype) == 'image/jpeg'
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(response.mimetype) == 'image/jpeg' does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
331
            # unit tests ensure this is a placeholder image
332
333
        @pytest.mark.xfail(os.name == 'nt', reason="Windows has a path limit")
334
        def when_too_much_text_for_a_filename(client):
0 ignored issues
show
Unused Code introduced by
The variable when_too_much_text_for_a_filename seems to be unused.
Loading history...
335
            top = "hello"
336
            bottom = "_".join(["world"] * 50)
337
            url = "/iw/" + top + "/" + bottom + ".jpg"
338
            status, data = load(client.get(url))
339
340
            expect(status) == 414
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(status) == 414 does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
341
            expect(data) == {
0 ignored issues
show
Unused Code Bug introduced by
The expression expect(data) == {'message': 'Filename too long.'} does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
342
                'message': "Filename too long."
343
            }
344