Coverage for tests/test_tutorial/test_configure_swagger_ui/test_tutorial002.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.tutorial002 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 '"syntaxHighlight": false' not in response.text 

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

14 assert ( 1abcde

15 '"syntaxHighlight.theme": "obsidian"' in response.text 

16 ), "parameters with middle dots should be included in a JSON compatible way" 

17 assert ( 1abcde

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

19 ), "default configs should be preserved" 

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

21 assert ( 1abcde

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

23 ), "default configs should be preserved" 

24 assert ( 1abcde

25 "SwaggerUIBundle.SwaggerUIStandalonePreset" in response.text 

26 ), "default configs should be preserved" 

27 assert ( 1abcde

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

29 ), "default configs should be preserved" 

30 assert ( 1abcde

31 '"deepLinking": true,' 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