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 2025-05-05 00:03 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2025-05-05 00:03 +0000
1from fastapi.testclient import TestClient 1ghijkl
3from docs_src.configure_swagger_ui.tutorial002 import app 1ghijkl
5client = TestClient(app) 1ghijkl
8def test_swagger_ui(): 1ghijkl
9 response = client.get("/docs") 1abcdef
10 assert response.status_code == 200, response.text 1abcdef
11 assert '"syntaxHighlight": false' not in response.text, ( 1abcdef
12 "not used parameters should not be included"
13 )
14 assert '"syntaxHighlight": {"theme": "obsidian"}' in response.text, ( 1abcdef
15 "parameters with middle dots should be included in a JSON compatible way"
16 )
17 assert '"dom_id": "#swagger-ui"' in response.text, ( 1abcdef
18 "default configs should be preserved"
19 )
20 assert "presets: [" in response.text, "default configs should be preserved" 1abcdef
21 assert "SwaggerUIBundle.presets.apis," in response.text, ( 1abcdef
22 "default configs should be preserved"
23 )
24 assert "SwaggerUIBundle.SwaggerUIStandalonePreset" in response.text, ( 1abcdef
25 "default configs should be preserved"
26 )
27 assert '"layout": "BaseLayout",' in response.text, ( 1abcdef
28 "default configs should be preserved"
29 )
30 assert '"deepLinking": true,' in response.text, ( 1abcdef
31 "default configs should be preserved"
32 )
33 assert '"showExtensions": true,' in response.text, ( 1abcdef
34 "default configs should be preserved"
35 )
36 assert '"showCommonExtensions": true,' in response.text, ( 1abcdef
37 "default configs should be preserved"
38 )
41def test_get_users(): 1ghijkl
42 response = client.get("/users/foo") 1mnopqr
43 assert response.status_code == 200, response.text 1mnopqr
44 assert response.json() == {"message": "Hello foo"} 1mnopqr