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 2024-08-08 03:53 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
1from fastapi.testclient import TestClient 1abcde
3from docs_src.configure_swagger_ui.tutorial001 import app 1abcde
5client = TestClient(app) 1abcde
8def test_swagger_ui(): 1abcde
9 response = client.get("/docs") 1abcde
10 assert response.status_code == 200, response.text 1abcde
11 assert ( 1abcde
12 '"syntaxHighlight": false' in response.text
13 ), "syntaxHighlight should be included and converted to JSON"
14 assert ( 1abcde
15 '"dom_id": "#swagger-ui"' in response.text
16 ), "default configs should be preserved"
17 assert "presets: [" in response.text, "default configs should be preserved" 1abcde
18 assert ( 1abcde
19 "SwaggerUIBundle.presets.apis," in response.text
20 ), "default configs should be preserved"
21 assert ( 1abcde
22 "SwaggerUIBundle.SwaggerUIStandalonePreset" in response.text
23 ), "default configs should be preserved"
24 assert ( 1abcde
25 '"layout": "BaseLayout",' in response.text
26 ), "default configs should be preserved"
27 assert ( 1abcde
28 '"deepLinking": true,' in response.text
29 ), "default configs should be preserved"
30 assert ( 1abcde
31 '"showExtensions": true,' in response.text
32 ), "default configs should be preserved"
33 assert ( 1abcde
34 '"showCommonExtensions": true,' in response.text
35 ), "default configs should be preserved"
38def test_get_users(): 1abcde
39 response = client.get("/users/foo") 1abcde
40 assert response.status_code == 200, response.text 1abcde
41 assert response.json() == {"message": "Hello foo"} 1abcde