|
1
|
|
|
# pylint: disable=unused-variable,expression-not-assigned |
|
2
|
|
|
|
|
3
|
|
|
from expecter import expect |
|
|
|
|
|
|
4
|
|
|
|
|
5
|
|
|
from .conftest import load |
|
6
|
|
|
|
|
7
|
|
|
|
|
8
|
|
|
def describe_pattern(): |
|
9
|
|
|
|
|
10
|
|
|
def it_returns_matches(client): |
|
11
|
|
|
response = client.get("/magic/do-all-the-things") |
|
12
|
|
|
|
|
13
|
|
|
expect(response.status_code) == 200 |
|
14
|
|
|
expect(load(response)) == [ |
|
15
|
|
|
{ |
|
16
|
|
|
'template': "http://localhost/xy/do/all-the-things", |
|
17
|
|
|
'ratio': 0.94, |
|
18
|
|
|
}, |
|
19
|
|
|
] |
|
20
|
|
|
|
|
21
|
|
|
def it_returns_an_empty_list_when_no_matches(client): |
|
22
|
|
|
response = client.get("/magic/_") |
|
23
|
|
|
|
|
24
|
|
|
expect(response.status_code) == 200 |
|
25
|
|
|
expect(load(response)) == [] |
|
26
|
|
|
|
|
27
|
|
|
def it_returns_an_empty_list_for_missing_patterns(client): |
|
28
|
|
|
response = client.get("/magic/") |
|
29
|
|
|
|
|
30
|
|
|
expect(response.status_code) == 200 |
|
31
|
|
|
expect(load(response)) == [] |
|
32
|
|
|
|
|
33
|
|
|
def it_redirects_to_use_dashes(client): |
|
34
|
|
|
response = client.get("/magic/do all the things") |
|
35
|
|
|
|
|
36
|
|
|
expect(response.status_code) == 302 |
|
37
|
|
|
expect(load(response, as_json=False)).contains( |
|
38
|
|
|
'<a href="/magic/do-all-the-things">') |
|
39
|
|
|
|
|
40
|
|
|
def it_redirects_when_shortened(client): |
|
41
|
|
|
response = client.get("/m/_") |
|
42
|
|
|
|
|
43
|
|
|
expect(response.status_code) == 302 |
|
44
|
|
|
|
|
45
|
|
|
|
|
46
|
|
|
def describe_image(): |
|
47
|
|
|
|
|
48
|
|
|
def it_redirects_to_an_image(client): |
|
49
|
|
|
response = client.get("/magic/do all the things.jpg") |
|
50
|
|
|
|
|
51
|
|
|
expect(response.status_code) == 302 |
|
52
|
|
|
expect(load(response, as_json=False)).contains( |
|
53
|
|
|
'<a href="/xy/do/all-the-things.jpg">') |
|
54
|
|
|
|
|
55
|
|
|
def even_when_no_match(client): |
|
56
|
|
|
response = client.get("/magic/_.jpg") |
|
57
|
|
|
|
|
58
|
|
|
expect(response.status_code) == 302 |
|
59
|
|
|
expect(load(response, as_json=False)).contains( |
|
60
|
|
|
'<a href="/unknown/_.jpg">') |
|
61
|
|
|
|
This can be caused by one of the following:
1. Missing Dependencies
This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.
2. Missing __init__.py files
This error could also result from missing
__init__.pyfiles in your module folders. Make sure that you place one file in each sub-folder.