Coverage for tests/test_tutorial/test_configure_swagger_ui/test_tutorial003.py: 100%

20 statements  

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

1from fastapi.testclient import TestClient 1abcde

2 

3from docs_src.configure_swagger_ui.tutorial003 import app 1abcde

4 

5client = TestClient(app) 1abcde

6 

7 

8def test_swagger_ui(): 1abcde

9 response = client.get("/docs") 1abcde

10 assert response.status_code == 200, response.text 1abcde

11 assert ( 1abcde

12 '"deepLinking": false,' in response.text 

13 ), "overridden configs should be preserved" 

14 assert ( 1abcde

15 '"deepLinking": true' not in response.text 

16 ), "overridden configs should not include the old value" 

17 assert ( 1abcde

18 '"syntaxHighlight": false' not in response.text 

19 ), "not used parameters should not be included" 

20 assert ( 1abcde

21 '"dom_id": "#swagger-ui"' in response.text 

22 ), "default configs should be preserved" 

23 assert "presets: [" in response.text, "default configs should be preserved" 1abcde

24 assert ( 1abcde

25 "SwaggerUIBundle.presets.apis," in response.text 

26 ), "default configs should be preserved" 

27 assert ( 1abcde

28 "SwaggerUIBundle.SwaggerUIStandalonePreset" in response.text 

29 ), "default configs should be preserved" 

30 assert ( 1abcde

31 '"layout": "BaseLayout",' in response.text 

32 ), "default configs should be preserved" 

33 assert ( 1abcde

34 '"showExtensions": true,' in response.text 

35 ), "default configs should be preserved" 

36 assert ( 1abcde

37 '"showCommonExtensions": true,' in response.text 

38 ), "default configs should be preserved" 

39 

40 

41def test_get_users(): 1abcde

42 response = client.get("/users/foo") 1abcde

43 assert response.status_code == 200, response.text 1abcde

44 assert response.json() == {"message": "Hello foo"} 1abcde