Debian Codegraph @

tests/test_tutorial/test_configure_swagger_ui/test_tutorial001.py

raw
1 from fastapi.testclient import TestClient
2
3 from docs_src.configure_swagger_ui.tutorial001_py310 import app
4
5 client = TestClient(app)
6
7
8 def test_swagger_ui():
9 response = client.get("/docs")
10 assert response.status_code == 200, response.text
11 assert '"syntaxHighlight": false' in response.text, (
12 "syntaxHighlight should be included and converted to JSON"
13 )
14 assert '"dom_id": "#swagger-ui"' in response.text, (
15 "default configs should be preserved"
16 )
17 assert "presets: [" in response.text, "default configs should be preserved"
18 assert "SwaggerUIBundle.presets.apis," in response.text, (
19 "default configs should be preserved"
20 )
21 assert "SwaggerUIBundle.SwaggerUIStandalonePreset" in response.text, (
22 "default configs should be preserved"
23 )
24 assert '"layout": "BaseLayout",' in response.text, (
25 "default configs should be preserved"
26 )
27 assert '"deepLinking": true,' in response.text, (
28 "default configs should be preserved"
29 )
30 assert '"showExtensions": true,' in response.text, (
31 "default configs should be preserved"
32 )
33 assert '"showCommonExtensions": true,' in response.text, (
34 "default configs should be preserved"
35 )
36
37
38 def test_get_users():
39 response = client.get("/users/foo")
40 assert response.status_code == 200, response.text
41 assert response.json() == {"message": "Hello foo"}