mirror of
https://github.com/long2ice/fastapi-cache.git
synced 2026-03-24 20:47:54 +00:00
Decode cache data to the correct endpoint type
Use the return annotation to decode cached data to the correct type. This follows the same logic FastAPI uses to JSON request bodies. For the PickleCoder, this is a no-op as pickle already stores type information in the serialised data.
This commit is contained in:
@@ -79,3 +79,10 @@ def test_method() -> None:
|
||||
with TestClient(app) as client:
|
||||
response = client.get("/method")
|
||||
assert response.json() == 17
|
||||
|
||||
|
||||
def test_pydantic_model() -> None:
|
||||
with TestClient(app) as client:
|
||||
r1 = client.get("/pydantic_instance").json()
|
||||
r2 = client.get("/pydantic_instance").json()
|
||||
assert r1 == r2
|
||||
|
||||
Reference in New Issue
Block a user