-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_string.py
39 lines (30 loc) · 1.07 KB
/
test_string.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from uuid import uuid4
import redis_rs
async def test_set(async_client: redis_rs.AsyncClient):
key = str(uuid4())
await async_client.set(key, 1)
result = await async_client.get(key)
assert result == b"1"
async def test_get_int(async_client: redis_rs.AsyncClient):
key = str(uuid4())
await async_client.set(key, 3)
result = await async_client.get(key, encoding="int")
assert result == 3
async def test_set_ex(async_client: redis_rs.AsyncClient):
key = str(uuid4())
ttl = await async_client.fetch_int("TTL", key)
assert ttl < 0
await async_client.set(key, 2, ex=10)
result = await async_client.get(key)
assert result == b"2"
ttl = await async_client.fetch_int("TTL", key)
assert ttl > 0
async def test_set_px(async_client: redis_rs.AsyncClient):
key = str(uuid4())
ttl = await async_client.fetch_int("TTL", key)
assert ttl < 0
await async_client.set(key, 2, px=10000)
result = await async_client.get(key)
assert result == b"2"
ttl = await async_client.fetch_int("TTL", key)
assert ttl > 0