Coverage for tests / test_tutorial / test_behind_a_proxy / test_tutorial001_01.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.13.3, created at 2026-02-12 18:15 +0000

1from fastapi.testclient import TestClient 1abcd

2 

3from docs_src.behind_a_proxy.tutorial001_01_py310 import app 1abcd

4 

5client = TestClient( 1abcd

6 app, 

7 base_url="https://example.com", 

8 follow_redirects=False, 

9) 

10 

11 

12def test_redirect() -> None: 1abcd

13 response = client.get("/items") 1efg

14 assert response.status_code == 307 1efg

15 assert response.headers["location"] == "https://example.com/items/" 1efg

16 

17 

18def test_no_redirect() -> None: 1abcd

19 response = client.get("/items/") 1hij

20 assert response.status_code == 200 1hij

21 assert response.json() == ["plumbus", "portal gun"] 1hij