Issues (59)

tests/test_api_links.py (1 issue)

Severity
1
# pylint: disable=unused-variable,misplaced-comparison-constant,expression-not-assigned
2
3
from expecter import expect
0 ignored issues
show
Unable to import 'expecter'
Loading history...
4
5
from .utils import load
6
7
8
def describe_get():
9
10
    def it_returns_link_options(client):
11
        status, data = load(client.get("/api/templates/iw/hello/world"))
12
13
        expect(status) == 200
14
        expect(data) == dict(
15
            direct=dict(
16
                visible="http://localhost/iw/hello/world.jpg",
17
                masked="http://localhost/_aXcJaGVsbG8vd29ybGQJ.jpg",
18
            ),
19
            markdown=dict(
20
                visible="![iw](http://localhost/iw/hello/world.jpg)",
21
                masked="![iw](http://localhost/_aXcJaGVsbG8vd29ybGQJ.jpg)",
22
            ),
23
        )
24
25
    def with_top_only(client):
26
        status, data = load(client.get("/api/templates/iw/hello"))
27
28
        expect(status) == 200
29
        expect(data['direct']) == dict(
30
            visible="http://localhost/iw/hello.jpg",
31
            masked="http://localhost/_aXcJaGVsbG8J.jpg",
32
        )
33
34
    def with_bottom_only(client):
35
        status, data = load(client.get("/api/templates/iw/_/hello"))
36
37
        expect(status) == 200
38
        expect(data['direct']) == dict(
39
            visible="http://localhost/iw/_/hello.jpg",
40
            masked="http://localhost/_aXcJXy9oZWxsbwkJ.jpg",
41
        )
42
43
    def with_dashes(client):
44
        status, data = load(client.get(
45
            "/api/templates/iw/HelloThere_World/How-areYOU"))
46
47
        expect(status) == 302
48
        expect(data).contains(
49
            '<a href="/api/templates/iw/hello_there_world/how_are_you">')
50
51
    def when_masked(client):
52
        status, data = load(client.get("/_aXcJaGVsbG8vd29ybGQJ"))
53
54
        expect(status) == 302
55
        expect(data).contains('<a href="/api/templates/iw/hello/world">')
56
57
    def when_masked_with_1_line(client):
58
        status, data = load(client.get("/_aXcJaGVsbG8J"))
59
60
        expect(status) == 302
61
        expect(data).contains('<a href="/api/templates/iw/hello">')
62
63
    def when_alias(client):
64
        status, data = load(client.get("/api/templates/insanity-wolf"))
65
66
        expect(status) == 302
67
        expect(data).contains('<a href="/api/templates/iw">')
68
69
    def when_alias_with_text(client):
70
        status, data = load(client.get(
71
            "/api/templates/insanity-wolf/hello/world"))
72
73
        expect(status) == 302
74
        expect(data).contains('<a href="/api/templates/iw/hello/world">')
75
76
    def old_api_is_still_supported_via_redirect(client):
77
        status, data = load(client.get("/iw/top/bottom"))
78
79
        expect(status) == 302
80
        expect(data).contains('<a href="/api/templates/iw/top/bottom">')
81