Coverage for tests / test_no_swagger_ui_redirect.py: 100%
20 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 import FastAPI 1abcd
2from fastapi.testclient import TestClient 1abcd
4app = FastAPI(swagger_ui_oauth2_redirect_url=None) 1abcd
7@app.get("/items/") 1abcd
8async def read_items(): 1abcd
9 return {"id": "foo"} 1hij
12client = TestClient(app) 1abcd
15def test_swagger_ui(): 1abcd
16 response = client.get("/docs") 1efg
17 assert response.status_code == 200, response.text 1efg
18 assert response.headers["content-type"] == "text/html; charset=utf-8" 1efg
19 assert "swagger-ui-dist" in response.text 1efg
20 print(client.base_url) 1efg
21 assert "oauth2RedirectUrl" not in response.text 1efg
24def test_swagger_ui_no_oauth2_redirect(): 1abcd
25 response = client.get("/docs/oauth2-redirect") 1klm
26 assert response.status_code == 404, response.text 1klm
29def test_response(): 1abcd
30 response = client.get("/items/") 1hij
31 assert response.json() == {"id": "foo"} 1hij