-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_l.py
120 lines (76 loc) · 2.72 KB
/
test_l.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
from uuid import uuid4
import pytest
import redis_rs
async def test_lpush(async_client: redis_rs.AsyncClient):
key = str(uuid4())
n = await async_client.lpush(key, 2)
assert n == 1
n = await async_client.lpush(key, 3)
assert n == 2
result = await async_client.lrange(key, encoding="int")
assert result == [3, 2]
async def test_rpush(async_client: redis_rs.AsyncClient):
key = str(uuid4())
n = await async_client.rpush(key, 2)
assert n == 1
n = await async_client.rpush(key, 3)
assert n == 2
result = await async_client.lrange(key, encoding="int")
assert result == [2, 3]
async def test_lrange(async_client: redis_rs.AsyncClient):
key = str(uuid4())
n = await async_client.lpush(key, 2)
assert n == 1
n = await async_client.lpush(key, 1)
assert n == 2
n = await async_client.rpush(key, 3)
assert n == 3
result = await async_client.lrange(key, 1, 1, encoding="int")
assert result == [2]
result = await async_client.lrange(key, 0, -1, encoding="int")
assert result == [1, 2, 3]
result = await async_client.lrange(key, encoding="int")
assert result == [1, 2, 3]
@pytest.mark.redis(version=6.2)
async def test_lpop(async_client: redis_rs.AsyncClient):
key = str(uuid4())
n = await async_client.lpush(key, 2)
assert n == 1
n = await async_client.lpush(key, 3)
assert n == 2
result = await async_client.lpop(key, encoding="int")
assert result == 3
n = await async_client.lpush(key, 4)
assert n == 2
result = await async_client.lpop(key, count=3, encoding="int")
assert result == [4, 2]
result = await async_client.lpush(key, 5)
assert result == 1
@pytest.mark.redis(version=6)
async def test_blpop(async_client: redis_rs.AsyncClient):
key1 = str(uuid4()) + "{a}"
key2 = str(uuid4()) + "{a}"
n = await async_client.lpush(key1, 1)
assert n == 1
n = await async_client.lpush(key2, 2)
assert n == 1
result = await async_client.blpop(key1, key2, timeout=0, encoding="int")
assert result == {key1: 1}
result = await async_client.blpop(key1, key2, timeout=0, encoding="int")
assert result == {key2: 2}
async def test_llen(async_client: redis_rs.AsyncClient):
key = str(uuid4())
result = await async_client.lpush(key, 2)
assert result == 1
result = await async_client.rpush(key, 3)
assert result == 2
result = await async_client.llen(key)
assert result == 2
async def test_lrem(async_client: redis_rs.AsyncClient):
key = str(uuid4())
n = await async_client.lpush(key, 2)
assert n == 1
n = await async_client.lpush(key, 3)
assert n == 2
result = await async_client.lrem(key, 0, 2)
assert result == 1