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

20 statements  

« prev     ^ index     » next       coverage.py v7.13.3, created at 2026-02-12 18:15 +0000

1from fastapi.testclient import TestClient 1defg

2 

3from docs_src.configure_swagger_ui.tutorial002_py310 import app 1defg

4 

5client = TestClient(app) 1defg

6 

7 

8def test_swagger_ui(): 1defg

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

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

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

12 "not used parameters should not be included" 

13 ) 

14 assert '"syntaxHighlight": {"theme": "obsidian"}' in response.text, ( 1abc

15 "parameters with middle dots should be included in a JSON compatible way" 

16 ) 

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

18 "default configs should be preserved" 

19 ) 

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

21 assert "SwaggerUIBundle.presets.apis," in response.text, ( 1abc

22 "default configs should be preserved" 

23 ) 

24 assert "SwaggerUIBundle.SwaggerUIStandalonePreset" in response.text, ( 1abc

25 "default configs should be preserved" 

26 ) 

27 assert '"layout": "BaseLayout",' in response.text, ( 1abc

28 "default configs should be preserved" 

29 ) 

30 assert '"deepLinking": true,' in response.text, ( 1abc

31 "default configs should be preserved" 

32 ) 

33 assert '"showExtensions": true,' in response.text, ( 1abc

34 "default configs should be preserved" 

35 ) 

36 assert '"showCommonExtensions": true,' in response.text, ( 1abc

37 "default configs should be preserved" 

38 ) 

39 

40 

41def test_get_users(): 1defg

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

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

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