-
Notifications
You must be signed in to change notification settings - Fork 64
/
test_app.py
41 lines (29 loc) · 1.03 KB
/
test_app.py
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
# pytest automatically injects fixtures
# that are defined in conftest.py
# in this case, client is injected
def test_index(client):
res = client.get("/")
assert res.status_code == 200
assert res.json["result"]["content"] == "hello world!"
def test_mirror(client):
res = client.get("/mirror/Tim")
assert res.status_code == 200
assert res.json["result"]["name"] == "Tim"
def test_get_users(client):
res = client.get("/users")
assert res.status_code == 200
res_users = res.json["result"]["users"]
assert len(res_users) == 4
assert res_users[0]["name"] == "Aria"
def tests_get_users_with_team(client):
res = client.get("/users?team=LWB")
assert res.status_code == 200
res_users = res.json["result"]["users"]
assert len(res_users) == 2
assert res_users[1]["name"] == "Tim"
def test_get_user_id(client):
res = client.get("/users/1")
assert res.status_code == 200
res_user = res.json["result"]["user"]
assert res_user["name"] == "Aria"
assert res_user["age"] == 19