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

19 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-05-06 08:24 +0000

1from fastapi.testclient import TestClient 1ghijkl

2 

3from docs_src.configure_swagger_ui.tutorial001 import app 1ghijkl

4 

5client = TestClient(app) 1ghijkl

6 

7 

8def test_swagger_ui(): 1ghijkl

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

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

11 assert '"syntaxHighlight": false' in response.text, ( 1abcdef

12 "syntaxHighlight should be included and converted to JSON" 

13 ) 

14 assert '"dom_id": "#swagger-ui"' in response.text, ( 1abcdef

15 "default configs should be preserved" 

16 ) 

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

18 assert "SwaggerUIBundle.presets.apis," in response.text, ( 1abcdef

19 "default configs should be preserved" 

20 ) 

21 assert "SwaggerUIBundle.SwaggerUIStandalonePreset" in response.text, ( 1abcdef

22 "default configs should be preserved" 

23 ) 

24 assert '"layout": "BaseLayout",' in response.text, ( 1abcdef

25 "default configs should be preserved" 

26 ) 

27 assert '"deepLinking": true,' in response.text, ( 1abcdef

28 "default configs should be preserved" 

29 ) 

30 assert '"showExtensions": true,' in response.text, ( 1abcdef

31 "default configs should be preserved" 

32 ) 

33 assert '"showCommonExtensions": true,' in response.text, ( 1abcdef

34 "default configs should be preserved" 

35 ) 

36 

37 

38def test_get_users(): 1ghijkl

39 response = client.get("/users/foo") 1mnopqr

40 assert response.status_code == 200, response.text 1mnopqr

41 assert response.json() == {"message": "Hello foo"} 1mnopqr