| 1 |
from fastapi.testclient import TestClient |
| 2 |
|
| 3 |
from docs_src.behind_a_proxy.tutorial001_01_py310 import app |
| 4 |
|
| 5 |
client = TestClient( |
| 6 |
app, |
| 7 |
base_url="https://example.com", |
| 8 |
follow_redirects=False, |
| 9 |
) |
| 10 |
|
| 11 |
|
| 12 |
def test_redirect() -> None: |
| 13 |
response = client.get("/items") |
| 14 |
assert response.status_code == 307 |
| 15 |
assert response.headers["location"] == "https://example.com/items/" |
| 16 |
|
| 17 |
|
| 18 |
def test_no_redirect() -> None: |
| 19 |
response = client.get("/items/") |
| 20 |
assert response.status_code == 200 |
| 21 |
assert response.json() == ["plumbus", "portal gun"] |