Completed
Push — master ( 84c3c7...b77abd )
by Jace
03:21
created

test_match()   A

Complexity

Conditions 2

Size

Total Lines 49

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
cc 2
c 4
b 0
f 0
dl 0
loc 49
rs 9.2258
1
"""Tests for template pattern matching."""
2
# pylint: disable=expression-not-assigned
3
4
import pytest
5
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...
6
7
from .utils import load
8
9
10
BASE = "http://localhost/api/templates/"
11
12
13
@pytest.mark.parametrize("pattern,links", [
14
15
    ("take my money", [
16
        BASE + "money/_/take-my-money",
17
    ]),
18
19
    ("shut up and take my money", [
20
        BASE + "money/shut-up-and/take-my-money",
21
    ]),
22
23
    ("shut up and do that thing", [
24
        BASE + "money/shut-up-and/do-that-thing",
25
    ]),
26
27
    ("stop talking and take my money", [
28
        BASE + "money/stop-talking-and/take-my-money",
29
    ]),
30
31
    ("oops i should not have said that", [
32
        BASE + "hagrid/oops/i-should-not-have-said-that",
33
    ]),
34
35
    ("we should not have done that", [
36
        BASE + "hagrid/_/we-should-not-have-done-that",
37
    ]),
38
39
    ("they shouldn't have done that", [
40
        BASE + "hagrid/_/they-shouldn't-have-done-that",
41
    ]),
42
43
    ("we found something so we got that, which is nice", [
44
        BASE + "nice/we-found-something/so-we-got-that,-which-is-nice",
45
    ]),
46
47
    ("'member star wars", [
48
        BASE + "mb/'member/star-wars",
49
    ]),
50
51
    ("remember the good times", [
52
        BASE + "mb/member/the-good-times",
53
    ]),
54
55
])
56
def test_match(client, pattern, links):
57
    response = client.get("/api/magic/" + pattern, follow_redirects=True)
58
59
    _, matches = load(response)
60
61
    expect([match['link'] for match in matches]) == links
62