aboutsummaryrefslogtreecommitdiffstats
path: root/python/tests/routes.py
blob: 5ec0f36f2cca57a99ca0f4ba78924a2c3d6e2819 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120

import json
import tempfile
import pytest
import fatcat
from fatcat_client.rest import ApiException
from fixtures import *


def test_static_routes(app):
    for route in ('/health', '/robots.txt', '/', '/about'):
        rv = app.get(route)
        assert rv.status_code == 200

    assert app.get("/static/bogus/route").status_code == 404


def test_all_views(app):
    for route in ('work', 'release', 'creator', 'container', 'file'):
        print(route)
        rv = app.get('/{}/9999999999'.format(route))
        assert rv.status_code == 400

        rv = app.get('/{}/f1f046a3-45c9-ffff-ffff-ffffffffffff'.format(route))
        assert rv.status_code == 400

        rv = app.get('/{}/ccccccccccccccccccccccccca'.format(route))
        assert rv.status_code == 404

    rv = app.get('/container/aaaaaaaaaaaaaeiraaaaaaaaai')
    assert rv.status_code == 200

    rv = app.get('/container/aaaaaaaaaaaaaeiraaaaaaaaai/history')
    assert rv.status_code == 200

    rv = app.get('/container/aaaaaaaaaaaaaeiraaaaaaaaai/edit')
    assert rv.status_code == 200

    #rv = app.get('/container/create')
    #assert rv.status_code == 200

    rv = app.get('/container/lookup')
    assert rv.status_code == 400

    rv = app.get('/container/lookup?issnl=9999-9999')
    assert rv.status_code == 404

    rv = app.get('/container/lookup?issnl=1234-5678')
    assert rv.status_code == 302

    rv = app.get('/creator/aaaaaaaaaaaaaircaaaaaaaaai')
    assert rv.status_code == 200

    rv = app.get('/creator/aaaaaaaaaaaaaircaaaaaaaaai/history')
    assert rv.status_code == 200

    rv = app.get('/creator/aaaaaaaaaaaaaircaaaaaaaaai/edit')
    assert rv.status_code == 200

    rv = app.get('/creator/lookup?orcid=0000-0003-2088-7465')
    assert rv.status_code == 302

    rv = app.get('/file/aaaaaaaaaaaaamztaaaaaaaaai')
    assert rv.status_code == 200

    rv = app.get('/file/lookup?sha1=7d97e98f8af710c7e7fe703abc8f639e0ee507c4')
    assert rv.status_code == 302

    rv = app.get('/release/aaaaaaaaaaaaarceaaaaaaaaai')
    assert rv.status_code == 200

    rv = app.get('/release/aaaaaaaaaaaaarceaaaaaaaaai/history')
    assert rv.status_code == 200

    rv = app.get('/release/aaaaaaaaaaaaarceaaaaaaaaai/edit')
    assert rv.status_code == 200

    #rv = app.get('/release/create')
    #assert rv.status_code == 200

    rv = app.get('/release/lookup?doi=10.123/abc')
    assert rv.status_code == 302

    rv = app.get('/release/lookup?doi=10.123%2Fabc')
    assert rv.status_code == 302

    rv = app.get('/release/search')
    assert rv.status_code == 200

    rv = app.get('/work/aaaaaaaaaaaaavkvaaaaaaaaai')
    assert rv.status_code == 200

    rv = app.get('/work/aaaaaaaaaaaaavkvaaaaaaaaai/history')
    assert rv.status_code == 200

    rv = app.get('/work/aaaaaaaaaaaaavkvaaaaaaaaai/edit')
    assert rv.status_code == 200

    #rv = app.get('/work/create')
    #assert rv.status_code == 404

    rv = app.get('/editgroup/aaaaaaaaaaaabo53aaaaaaaaae')
    assert rv.status_code == 200

    rv = app.get('/editgroup/ccccccccccccccccccccccccca')
    print(rv)
    print(rv.data)
    assert rv.status_code == 404

    #rv = app.get('/editgroup/current')
    #assert rv.status_code == 302

    rv = app.get('/editor/aaaaaaaaaaaabkvkaaaaaaaaae')
    assert rv.status_code == 200

    rv = app.get('/editor/aaaaaaaaaaaabkvkaaaaaaaaae/changelog')
    assert rv.status_code == 200

    rv = app.get('/stats')
    assert rv.status_code == 200