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 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.tutorial003 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 '"deepLinking": false,' in response.text, ( 1abcdef
12 "overridden configs should be preserved"
13 )
14 assert '"deepLinking": true' not in response.text, ( 1abcdef
15 "overridden configs should not include the old value"
16 )
17 assert '"syntaxHighlight": false' not in response.text, ( 1abcdef
18 "not used parameters should not be included"
19 )
20 assert '"dom_id": "#swagger-ui"' in response.text, ( 1abcdef
21 "default configs should be preserved"
22 )
23 assert "presets: [" in response.text, "default configs should be preserved" 1abcdef
24 assert "SwaggerUIBundle.presets.apis," in response.text, ( 1abcdef
25 "default configs should be preserved"
26 )
27 assert "SwaggerUIBundle.SwaggerUIStandalonePreset" in response.text, ( 1abcdef
28 "default configs should be preserved"
29 )
30 assert '"layout": "BaseLayout",' 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