MCPcopy
hub / github.com/redis/redis-py / test_hexpire_conditions

Function test_hexpire_conditions

tests/test_asyncio/test_hash.py:34–48  ·  view source on GitHub ↗
(r)

Source from the content-addressed store, hash-verified

32
33@skip_if_server_version_lt("7.3.240")
34async def test_hexpire_conditions(r):
35 await r.delete("test:hash")
36 await r.hset("test:hash", mapping={"field1": "value1"})
37 assert await r.hexpire("test:hash", 2, "field1", xx=True) == [0]
38 assert await r.hexpire("test:hash", 2, "field1", nx=True) == [1]
39 assert await r.hexpire("test:hash", 1, "field1", xx=True) == [1]
40 assert await r.hexpire("test:hash", 2, "field1", nx=True) == [0]
41 await asyncio.sleep(1.1)
42 assert await r.hexists("test:hash", "field1") is False
43 await r.hset("test:hash", "field1", "value1")
44 await r.hexpire("test:hash", 2, "field1")
45 assert await r.hexpire("test:hash", 1, "field1", gt=True) == [0]
46 assert await r.hexpire("test:hash", 1, "field1", lt=True) == [1]
47 await asyncio.sleep(1.1)
48 assert await r.hexists("test:hash", "field1") is False
49
50
51@skip_if_server_version_lt("7.3.240")

Callers

nothing calls this directly

Calls 5

hsetMethod · 0.80
hexpireMethod · 0.80
hexistsMethod · 0.80
deleteMethod · 0.45
sleepMethod · 0.45

Tested by

no test coverage detected