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