mirror of
https://github.com/long2ice/fastapi-cache.git
synced 2026-03-24 20:47:54 +00:00
adding test coverage
This commit is contained in:
@@ -42,6 +42,13 @@ async def get_date():
|
||||
async def get_datetime(request: Request, response: Response):
|
||||
return {"now": pendulum.now()}
|
||||
|
||||
@cache(namespace="test")
|
||||
async def func_kwargs(*unused_args, **kwargs):
|
||||
return kwargs
|
||||
|
||||
@app.get("/kwargs")
|
||||
async def get_kwargs(name: str):
|
||||
return await func_kwargs(name, name=name)
|
||||
|
||||
@app.get("/sync-me")
|
||||
@cache(namespace="test")
|
||||
|
||||
@@ -67,3 +67,9 @@ def test_cache_response_obj() -> None:
|
||||
assert get_cache_response.json() == {"a": 1}
|
||||
assert get_cache_response.headers.get("cache-control")
|
||||
assert get_cache_response.headers.get("etag")
|
||||
|
||||
def test_kwargs() -> None:
|
||||
with TestClient(app) as client:
|
||||
name = "Jon"
|
||||
response = client.get("/kwargs", params = {"name": name})
|
||||
assert response.json() == {"name": name}
|
||||
|
||||
Reference in New Issue
Block a user