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

38 statements  

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

1from ...utils import needs_py310 1deabc

2 

3 

4@needs_py310 1deabc

5def test_override_in_items_run(): 1deabc

6 from docs_src.dependency_testing.tutorial001_an_py310 import test_override_in_items 1abc

7 

8 test_override_in_items() 1abc

9 

10 

11@needs_py310 1deabc

12def test_override_in_items_with_q_run(): 1deabc

13 from docs_src.dependency_testing.tutorial001_an_py310 import ( 1abc

14 test_override_in_items_with_q, 

15 ) 

16 

17 test_override_in_items_with_q() 1abc

18 

19 

20@needs_py310 1deabc

21def test_override_in_items_with_params_run(): 1deabc

22 from docs_src.dependency_testing.tutorial001_an_py310 import ( 1abc

23 test_override_in_items_with_params, 

24 ) 

25 

26 test_override_in_items_with_params() 1abc

27 

28 

29@needs_py310 1deabc

30def test_override_in_users(): 1deabc

31 from docs_src.dependency_testing.tutorial001_an_py310 import client 1abc

32 

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

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

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

36 "message": "Hello Users!", 

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

38 } 

39 

40 

41@needs_py310 1deabc

42def test_override_in_users_with_q(): 1deabc

43 from docs_src.dependency_testing.tutorial001_an_py310 import client 1abc

44 

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

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

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

48 "message": "Hello Users!", 

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

50 } 

51 

52 

53@needs_py310 1deabc

54def test_override_in_users_with_params(): 1deabc

55 from docs_src.dependency_testing.tutorial001_an_py310 import client 1abc

56 

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

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

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

60 "message": "Hello Users!", 

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

62 } 

63 

64 

65@needs_py310 1deabc

66def test_normal_app(): 1deabc

67 from docs_src.dependency_testing.tutorial001_an_py310 import app, client 1abc

68 

69 app.dependency_overrides = None 1abc

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

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

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

73 "message": "Hello Items!", 

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

75 }