|
|
@ -34,3 +34,19 @@ def test_redirects_with_root_path(): |
|
|
|
response = client.get("/hello", follow_redirects=False) |
|
|
|
assert response.status_code == 307 |
|
|
|
assert response.headers["location"] == "http://testserver/api/hello/" |
|
|
|
|
|
|
|
|
|
|
|
def test_invalid_combination_of_root_path(): |
|
|
|
app = FastAPI(root_path="/api") |
|
|
|
router = APIRouter() |
|
|
|
|
|
|
|
@router.get("/hello/") |
|
|
|
def hello_page() -> str: |
|
|
|
return "Hello, World!" |
|
|
|
|
|
|
|
app.include_router(router) |
|
|
|
|
|
|
|
client = TestClient(app, base_url="http://testserver", root_path="/notapi") |
|
|
|
response = client.get("/hello", follow_redirects=False) |
|
|
|
assert response.status_code == 307 |
|
|
|
assert response.headers["location"] == "http://testserver/api/hello/" |
|
|
|