Completed
Push — master ( eac9d6...cda706 )
by Jace
11s
created

describe_pattern()   B

Complexity

Conditions 6

Size

Total Lines 36

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 6
dl 0
loc 36
rs 7.5384

5 Methods

Rating   Name   Duplication   Size   Complexity  
A it_returns_matches() 0 8 1
A it_returns_an_empty_list_for_missing_patterns() 0 5 1
A it_redirects_to_use_dashes() 0 6 1
A it_redirects_when_shortened() 0 4 1
A it_returns_an_empty_list_when_no_matches() 0 5 1
1
# pylint: disable=unused-variable,expression-not-assigned
2
3
from expecter import expect
0 ignored issues
show
Configuration introduced by
The import expecter could not be resolved.

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.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
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