This commit is contained in:
John Lyu
2024-05-09 14:43:53 +08:00
parent e4a0df62dd
commit 6f8994b843

View File

@@ -115,25 +115,25 @@ def test_alternate_injected_namespace() -> None:
def test_cache_control() -> None: def test_cache_control() -> None:
with TestClient(app) as client: with TestClient(app) as client:
response = client.get("/uncached_put") response = client.put("/uncached_put")
assert "X-FastAPI-Cache" not in response.headers assert "X-FastAPI-Cache" not in response.headers
assert response.json() == {"value": 1} assert response.json() == {"value": 1}
# HIT # HIT
response = client.get("/uncached_put") response = client.put("/uncached_put")
assert response.headers.get("X-FastAPI-Cache") == "HIT" assert response.headers.get("X-FastAPI-Cache") == "HIT"
assert response.json() == {"value": 1} assert response.json() == {"value": 1}
# no-cache # no-cache
response = client.get("/uncached_put", headers={"Cache-Control": "no-cache"}) response = client.put("/uncached_put", headers={"Cache-Control": "no-cache"})
assert response.json() == {"value": 2} assert response.json() == {"value": 2}
response = client.get("/uncached_put") response = client.put("/uncached_put")
assert response.json() == {"value": 2} assert response.json() == {"value": 2}
# no-store # no-store
response = client.get("/uncached_put", headers={"Cache-Control": "no-store"}) response = client.put("/uncached_put", headers={"Cache-Control": "no-store"})
assert response.json() == {"value": 3} assert response.json() == {"value": 3}
response = client.get("/uncached_put") response = client.put("/uncached_put")
assert response.json() == {"value": 2} assert response.json() == {"value": 2}