Coverage for tests/test_tutorial/test_testing_dependencies/test_tutorial001.py: 100%
24 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
1from docs_src.dependency_testing.tutorial001 import ( 1abcde
2 app,
3 client,
4 test_override_in_items,
5 test_override_in_items_with_params,
6 test_override_in_items_with_q,
7)
10def test_override_in_items_run(): 1abcde
11 test_override_in_items() 1abcde
14def test_override_in_items_with_q_run(): 1abcde
15 test_override_in_items_with_q() 1abcde
18def test_override_in_items_with_params_run(): 1abcde
19 test_override_in_items_with_params() 1abcde
22def test_override_in_users(): 1abcde
23 response = client.get("/users/") 1abcde
24 assert response.status_code == 200, response.text 1abcde
25 assert response.json() == { 1abcde
26 "message": "Hello Users!",
27 "params": {"q": None, "skip": 5, "limit": 10},
28 }
31def test_override_in_users_with_q(): 1abcde
32 response = client.get("/users/?q=foo") 1abcde
33 assert response.status_code == 200, response.text 1abcde
34 assert response.json() == { 1abcde
35 "message": "Hello Users!",
36 "params": {"q": "foo", "skip": 5, "limit": 10},
37 }
40def test_override_in_users_with_params(): 1abcde
41 response = client.get("/users/?q=foo&skip=100&limit=200") 1abcde
42 assert response.status_code == 200, response.text 1abcde
43 assert response.json() == { 1abcde
44 "message": "Hello Users!",
45 "params": {"q": "foo", "skip": 5, "limit": 10},
46 }
49def test_normal_app(): 1abcde
50 app.dependency_overrides = None 1abcde
51 response = client.get("/items/?q=foo&skip=100&limit=200") 1abcde
52 assert response.status_code == 200, response.text 1abcde
53 assert response.json() == { 1abcde
54 "message": "Hello Items!",
55 "params": {"q": "foo", "skip": 100, "limit": 200},
56 }