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

24 statements  

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

1from docs_src.dependency_testing.tutorial001_an 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) 

8 

9 

10def test_override_in_items_run(): 1abcde

11 test_override_in_items() 1abcde

12 

13 

14def test_override_in_items_with_q_run(): 1abcde

15 test_override_in_items_with_q() 1abcde

16 

17 

18def test_override_in_items_with_params_run(): 1abcde

19 test_override_in_items_with_params() 1abcde

20 

21 

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 } 

29 

30 

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 } 

38 

39 

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 } 

47 

48 

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 }