1
1
from math import inf
2
2
3
3
import pytest
4
+ import pytest_asyncio
4
5
import redis .asyncio as redis
5
6
from redis .exceptions import ModuleError , RedisError
6
7
from redis .utils import HIREDIS_AVAILABLE
11
12
)
12
13
13
14
15
+ @pytest_asyncio .fixture ()
16
+ async def decoded_r (create_redis , stack_url ):
17
+ return await create_redis (decode_responses = True , url = stack_url )
18
+
19
+
14
20
def intlist (obj ):
15
21
return [int (v ) for v in obj ]
16
22
17
23
24
+ @pytest .mark .redismod
18
25
async def test_create (decoded_r : redis .Redis ):
19
26
"""Test CREATE/RESERVE calls"""
20
27
assert await decoded_r .bf ().create ("bloom" , 0.01 , 1000 )
@@ -30,10 +37,12 @@ async def test_create(decoded_r: redis.Redis):
30
37
31
38
32
39
@pytest .mark .experimental
40
+ @pytest .mark .redismod
33
41
async def test_tdigest_create (decoded_r : redis .Redis ):
34
42
assert await decoded_r .tdigest ().create ("tDigest" , 100 )
35
43
36
44
45
+ @pytest .mark .redismod
37
46
async def test_bf_add (decoded_r : redis .Redis ):
38
47
assert await decoded_r .bf ().create ("bloom" , 0.01 , 1000 )
39
48
assert 1 == await decoded_r .bf ().add ("bloom" , "foo" )
@@ -46,6 +55,7 @@ async def test_bf_add(decoded_r: redis.Redis):
46
55
assert [1 , 0 ] == intlist (await decoded_r .bf ().mexists ("bloom" , "foo" , "noexist" ))
47
56
48
57
58
+ @pytest .mark .redismod
49
59
async def test_bf_insert (decoded_r : redis .Redis ):
50
60
assert await decoded_r .bf ().create ("bloom" , 0.01 , 1000 )
51
61
assert [1 ] == intlist (await decoded_r .bf ().insert ("bloom" , ["foo" ]))
@@ -76,6 +86,7 @@ async def test_bf_insert(decoded_r: redis.Redis):
76
86
)
77
87
78
88
89
+ @pytest .mark .redismod
79
90
async def test_bf_scandump_and_loadchunk (decoded_r : redis .Redis ):
80
91
# Store a filter
81
92
await decoded_r .bf ().create ("myBloom" , "0.0001" , "1000" )
@@ -127,6 +138,7 @@ async def do_verify():
127
138
await decoded_r .bf ().create ("myBloom" , "0.0001" , "10000000" )
128
139
129
140
141
+ @pytest .mark .redismod
130
142
async def test_bf_info (decoded_r : redis .Redis ):
131
143
expansion = 4
132
144
# Store a filter
@@ -158,6 +170,7 @@ async def test_bf_info(decoded_r: redis.Redis):
158
170
assert True
159
171
160
172
173
+ @pytest .mark .redismod
161
174
async def test_bf_card (decoded_r : redis .Redis ):
162
175
# return 0 if the key does not exist
163
176
assert await decoded_r .bf ().card ("not_exist" ) == 0
@@ -172,6 +185,7 @@ async def test_bf_card(decoded_r: redis.Redis):
172
185
await decoded_r .bf ().card ("setKey" )
173
186
174
187
188
+ @pytest .mark .redismod
175
189
async def test_cf_add_and_insert (decoded_r : redis .Redis ):
176
190
assert await decoded_r .cf ().create ("cuckoo" , 1000 )
177
191
assert await decoded_r .cf ().add ("cuckoo" , "filter" )
@@ -197,6 +211,7 @@ async def test_cf_add_and_insert(decoded_r: redis.Redis):
197
211
)
198
212
199
213
214
+ @pytest .mark .redismod
200
215
async def test_cf_exists_and_del (decoded_r : redis .Redis ):
201
216
assert await decoded_r .cf ().create ("cuckoo" , 1000 )
202
217
assert await decoded_r .cf ().add ("cuckoo" , "filter" )
@@ -208,6 +223,7 @@ async def test_cf_exists_and_del(decoded_r: redis.Redis):
208
223
assert 0 == await decoded_r .cf ().count ("cuckoo" , "filter" )
209
224
210
225
226
+ @pytest .mark .redismod
211
227
async def test_cms (decoded_r : redis .Redis ):
212
228
assert await decoded_r .cms ().initbydim ("dim" , 1000 , 5 )
213
229
assert await decoded_r .cms ().initbyprob ("prob" , 0.01 , 0.01 )
@@ -224,6 +240,7 @@ async def test_cms(decoded_r: redis.Redis):
224
240
225
241
226
242
@pytest .mark .onlynoncluster
243
+ @pytest .mark .redismod
227
244
async def test_cms_merge (decoded_r : redis .Redis ):
228
245
assert await decoded_r .cms ().initbydim ("A" , 1000 , 5 )
229
246
assert await decoded_r .cms ().initbydim ("B" , 1000 , 5 )
@@ -240,6 +257,7 @@ async def test_cms_merge(decoded_r: redis.Redis):
240
257
assert [16 , 15 , 21 ] == await decoded_r .cms ().query ("C" , "foo" , "bar" , "baz" )
241
258
242
259
260
+ @pytest .mark .redismod
243
261
async def test_topk (decoded_r : redis .Redis ):
244
262
# test list with empty buckets
245
263
assert await decoded_r .topk ().reserve ("topk" , 3 , 50 , 4 , 0.9 )
@@ -320,6 +338,7 @@ async def test_topk(decoded_r: redis.Redis):
320
338
assert 0.9 == round (float (info ["decay" ]), 1 )
321
339
322
340
341
+ @pytest .mark .redismod
323
342
async def test_topk_incrby (decoded_r : redis .Redis ):
324
343
await decoded_r .flushdb ()
325
344
assert await decoded_r .topk ().reserve ("topk" , 3 , 10 , 3 , 1 )
@@ -335,6 +354,7 @@ async def test_topk_incrby(decoded_r: redis.Redis):
335
354
336
355
337
356
@pytest .mark .experimental
357
+ @pytest .mark .redismod
338
358
async def test_tdigest_reset (decoded_r : redis .Redis ):
339
359
assert await decoded_r .tdigest ().create ("tDigest" , 10 )
340
360
# reset on empty histogram
@@ -351,6 +371,7 @@ async def test_tdigest_reset(decoded_r: redis.Redis):
351
371
352
372
353
373
@pytest .mark .onlynoncluster
374
+ @pytest .mark .redismod
354
375
async def test_tdigest_merge (decoded_r : redis .Redis ):
355
376
assert await decoded_r .tdigest ().create ("to-tDigest" , 10 )
356
377
assert await decoded_r .tdigest ().create ("from-tDigest" , 10 )
@@ -378,6 +399,7 @@ async def test_tdigest_merge(decoded_r: redis.Redis):
378
399
379
400
380
401
@pytest .mark .experimental
402
+ @pytest .mark .redismod
381
403
async def test_tdigest_min_and_max (decoded_r : redis .Redis ):
382
404
assert await decoded_r .tdigest ().create ("tDigest" , 100 )
383
405
# insert data-points into sketch
@@ -388,6 +410,7 @@ async def test_tdigest_min_and_max(decoded_r: redis.Redis):
388
410
389
411
390
412
@pytest .mark .experimental
413
+ @pytest .mark .redismod
391
414
@skip_ifmodversion_lt ("2.4.0" , "bf" )
392
415
async def test_tdigest_quantile (decoded_r : redis .Redis ):
393
416
assert await decoded_r .tdigest ().create ("tDigest" , 500 )
@@ -416,6 +439,7 @@ async def test_tdigest_quantile(decoded_r: redis.Redis):
416
439
417
440
418
441
@pytest .mark .experimental
442
+ @pytest .mark .redismod
419
443
async def test_tdigest_cdf (decoded_r : redis .Redis ):
420
444
assert await decoded_r .tdigest ().create ("tDigest" , 100 )
421
445
# insert data-points into sketch
@@ -427,6 +451,7 @@ async def test_tdigest_cdf(decoded_r: redis.Redis):
427
451
428
452
429
453
@pytest .mark .experimental
454
+ @pytest .mark .redismod
430
455
@skip_ifmodversion_lt ("2.4.0" , "bf" )
431
456
async def test_tdigest_trimmed_mean (decoded_r : redis .Redis ):
432
457
assert await decoded_r .tdigest ().create ("tDigest" , 100 )
@@ -437,6 +462,7 @@ async def test_tdigest_trimmed_mean(decoded_r: redis.Redis):
437
462
438
463
439
464
@pytest .mark .experimental
465
+ @pytest .mark .redismod
440
466
async def test_tdigest_rank (decoded_r : redis .Redis ):
441
467
assert await decoded_r .tdigest ().create ("t-digest" , 500 )
442
468
assert await decoded_r .tdigest ().add ("t-digest" , list (range (0 , 20 )))
@@ -447,6 +473,7 @@ async def test_tdigest_rank(decoded_r: redis.Redis):
447
473
448
474
449
475
@pytest .mark .experimental
476
+ @pytest .mark .redismod
450
477
async def test_tdigest_revrank (decoded_r : redis .Redis ):
451
478
assert await decoded_r .tdigest ().create ("t-digest" , 500 )
452
479
assert await decoded_r .tdigest ().add ("t-digest" , list (range (0 , 20 )))
@@ -456,6 +483,7 @@ async def test_tdigest_revrank(decoded_r: redis.Redis):
456
483
457
484
458
485
@pytest .mark .experimental
486
+ @pytest .mark .redismod
459
487
async def test_tdigest_byrank (decoded_r : redis .Redis ):
460
488
assert await decoded_r .tdigest ().create ("t-digest" , 500 )
461
489
assert await decoded_r .tdigest ().add ("t-digest" , list (range (1 , 11 )))
@@ -467,6 +495,7 @@ async def test_tdigest_byrank(decoded_r: redis.Redis):
467
495
468
496
469
497
@pytest .mark .experimental
498
+ @pytest .mark .redismod
470
499
async def test_tdigest_byrevrank (decoded_r : redis .Redis ):
471
500
assert await decoded_r .tdigest ().create ("t-digest" , 500 )
472
501
assert await decoded_r .tdigest ().add ("t-digest" , list (range (1 , 11 )))
@@ -475,19 +504,3 @@ async def test_tdigest_byrevrank(decoded_r: redis.Redis):
475
504
assert (await decoded_r .tdigest ().byrevrank ("t-digest" , 100 ))[0 ] == - inf
476
505
with pytest .raises (redis .ResponseError ):
477
506
(await decoded_r .tdigest ().byrevrank ("t-digest" , - 1 ))[0 ]
478
-
479
-
480
- # # async def test_pipeline(decoded_r: redis.Redis):
481
- # pipeline = await decoded_r.bf().pipeline()
482
- # assert not await decoded_r.bf().execute_command("get pipeline")
483
- #
484
- # assert await decoded_r.bf().create("pipeline", 0.01, 1000)
485
- # for i in range(100):
486
- # pipeline.add("pipeline", i)
487
- # for i in range(100):
488
- # assert not (await decoded_r.bf().exists("pipeline", i))
489
- #
490
- # pipeline.execute()
491
- #
492
- # for i in range(100):
493
- # assert await decoded_r.bf().exists("pipeline", i)
0 commit comments