Skip to content

Commit 106d662

Browse files
committed
COH-27475 - Add Test for using an Object as a Key
1 parent ae7a1a0 commit 106d662

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/test_client.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,18 @@ async def test_get_and_put(setup_and_teardown: NamedCache[str, str | int | Perso
173173
assert r.address.city == Person.Andy().address.city
174174

175175

176+
@pytest.mark.asyncio
177+
async def test_object_as_key(setup_and_teardown: NamedCache[Person, Address]) -> None:
178+
cache: NamedCache[Person, Address] = setup_and_teardown
179+
180+
k1: Person = Person.Andy()
181+
v1: Address = k1.address
182+
await cache.put(k1, v1)
183+
r = await cache.get(k1)
184+
assert type(r) == Address
185+
assert r.city == "Miami"
186+
187+
176188
# noinspection PyShadowingNames
177189
@pytest.mark.asyncio
178190
async def test_put_if_absent(setup_and_teardown: NamedCache[str, str]) -> None:

0 commit comments

Comments
 (0)