tests/test_integration.py
2Integration tests for the library.
5from datetime import datetime
8from pydantic import BaseModel
10from funkycache import FunkyCache
13def test_long_mutable_key() -> None:
15 We can cache a function argument which includes a long key that
16 gets reduced during key encoding.
18 This is a regression test for a bug in 1.0.1, where the key would be
19 mutated when we checked if a value was already cached, which led to
20 cache misses and errors about overwriting values.
23 class MyType(BaseModel):
26 cache = FunkyCache(storage="memory")
29 def upcase(tp: MyType) -> str:
30 return str(datetime.now())
32 t = MyType(content="a" * 2500)