-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest_routes_file_based.py
More file actions
62 lines (53 loc) · 1.62 KB
/
test_routes_file_based.py
File metadata and controls
62 lines (53 loc) · 1.62 KB
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
import pytest
from .main import create_app
@pytest.fixture
def client():
app = create_app(testing=True)
with app.test_client() as client:
yield client
@pytest.mark.parametrize(
'name,status',
[
('Kidney (Left)', '200 OK'), # We now strip the (Left) part
('Small Intestine', '200 OK'),
('kidney', '200 OK'),
('small-intestine', '200 OK'),
('turtle', '308 PERMANENT REDIRECT'),
('doggo', '308 PERMANENT REDIRECT'),
('Placenta', '200 OK'),
('PLACENTA', '200 OK'),
('Blood Vasculature', '200 OK'),
('Blood_vasculature', '200 OK'),
(' PlAcEntA ', '200 OK'),
],
)
def test_organ(client, name, status):
response = client.get(f'/organs/{name}')
assert response.status == status
@pytest.mark.parametrize(
'name,expected',
[
('kidney', 'Kidney'),
('small-intestine', 'Small Intestine'),
('placenta', 'Placenta'),
('blood-vasculature', 'Blood Vasculature'),
('blah', None),
],
)
def test_get_organ_details(client, name, expected):
response = client.get(f'/organs/{name}.json')
if expected is not None:
assert response.json.get('name') == expected
else:
assert response.json == {}
@pytest.mark.parametrize(
'organs,expected',
[
(['kidney'], ['kidney']),
(['kidney', 'blah'], ['kidney']),
(['kidney', 'heart', 'blah'], ['heart', 'kidney']),
],
)
def test_get_organ_list(client, organs, expected):
response = client.post('/organs.json', json={'organs': organs})
assert list(response.json.keys()) == expected