Coverage for tests / test_tutorial / test_configure_swagger_ui / test_tutorial001.py: 100%
19 statements
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-12 18:15 +0000
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-12 18:15 +0000
1from fastapi.testclient import TestClient 1defg
3from docs_src.configure_swagger_ui.tutorial001_py310 import app 1defg
5client = TestClient(app) 1defg
8def test_swagger_ui(): 1defg
9 response = client.get("/docs") 1abc
10 assert response.status_code == 200, response.text 1abc
11 assert '"syntaxHighlight": false' in response.text, ( 1abc
12 "syntaxHighlight should be included and converted to JSON"
13 )
14 assert '"dom_id": "#swagger-ui"' in response.text, ( 1abc
15 "default configs should be preserved"
16 )
17 assert "presets: [" in response.text, "default configs should be preserved" 1abc
18 assert "SwaggerUIBundle.presets.apis," in response.text, ( 1abc
19 "default configs should be preserved"
20 )
21 assert "SwaggerUIBundle.SwaggerUIStandalonePreset" in response.text, ( 1abc
22 "default configs should be preserved"
23 )
24 assert '"layout": "BaseLayout",' in response.text, ( 1abc
25 "default configs should be preserved"
26 )
27 assert '"deepLinking": true,' in response.text, ( 1abc
28 "default configs should be preserved"
29 )
30 assert '"showExtensions": true,' in response.text, ( 1abc
31 "default configs should be preserved"
32 )
33 assert '"showCommonExtensions": true,' in response.text, ( 1abc
34 "default configs should be preserved"
35 )
38def test_get_users(): 1defg
39 response = client.get("/users/foo") 1hij
40 assert response.status_code == 200, response.text 1hij
41 assert response.json() == {"message": "Hello foo"} 1hij