|
1
|
|
|
"""Tests for template pattern matching.""" |
|
2
|
|
|
# pylint: disable=expression-not-assigned |
|
3
|
|
|
|
|
4
|
|
|
import pytest |
|
5
|
|
|
from expecter import expect |
|
|
|
|
|
|
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
|
|
|
|
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.