Coverage for tests/test_tutorial/test_testing_dependencies/test_tutorial001_an_py39.py: 100%

38 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-08-08 03:53 +0000

1from ...utils import needs_py39 1eabcd

2 

3 

4@needs_py39 1eabcd

5def test_override_in_items_run(): 1eabcd

6 from docs_src.dependency_testing.tutorial001_an_py39 import test_override_in_items 1abcd

7 

8 test_override_in_items() 1abcd

9 

10 

11@needs_py39 1eabcd

12def test_override_in_items_with_q_run(): 1eabcd

13 from docs_src.dependency_testing.tutorial001_an_py39 import ( 1abcd

14 test_override_in_items_with_q, 

15 ) 

16 

17 test_override_in_items_with_q() 1abcd

18 

19 

20@needs_py39 1eabcd

21def test_override_in_items_with_params_run(): 1eabcd

22 from docs_src.dependency_testing.tutorial001_an_py39 import ( 1abcd

23 test_override_in_items_with_params, 

24 ) 

25 

26 test_override_in_items_with_params() 1abcd

27 

28 

29@needs_py39 1eabcd

30def test_override_in_users(): 1eabcd

31 from docs_src.dependency_testing.tutorial001_an_py39 import client 1abcd

32 

33 response = client.get("/users/") 1abcd

34 assert response.status_code == 200, response.text 1abcd

35 assert response.json() == { 1abcd

36 "message": "Hello Users!", 

37 "params": {"q": None, "skip": 5, "limit": 10}, 

38 } 

39 

40 

41@needs_py39 1eabcd

42def test_override_in_users_with_q(): 1eabcd

43 from docs_src.dependency_testing.tutorial001_an_py39 import client 1abcd

44 

45 response = client.get("/users/?q=foo") 1abcd

46 assert response.status_code == 200, response.text 1abcd

47 assert response.json() == { 1abcd

48 "message": "Hello Users!", 

49 "params": {"q": "foo", "skip": 5, "limit": 10}, 

50 } 

51 

52 

53@needs_py39 1eabcd

54def test_override_in_users_with_params(): 1eabcd

55 from docs_src.dependency_testing.tutorial001_an_py39 import client 1abcd

56 

57 response = client.get("/users/?q=foo&skip=100&limit=200") 1abcd

58 assert response.status_code == 200, response.text 1abcd

59 assert response.json() == { 1abcd

60 "message": "Hello Users!", 

61 "params": {"q": "foo", "skip": 5, "limit": 10}, 

62 } 

63 

64 

65@needs_py39 1eabcd

66def test_normal_app(): 1eabcd

67 from docs_src.dependency_testing.tutorial001_an_py39 import app, client 1abcd

68 

69 app.dependency_overrides = None 1abcd

70 response = client.get("/items/?q=foo&skip=100&limit=200") 1abcd

71 assert response.status_code == 200, response.text 1abcd

72 assert response.json() == { 1abcd

73 "message": "Hello Items!", 

74 "params": {"q": "foo", "skip": 100, "limit": 200}, 

75 }