11from math import inf
22
33import pytest
4+ import pytest_asyncio
45import redis .asyncio as redis
56from redis .exceptions import ModuleError , RedisError
67from redis .utils import HIREDIS_AVAILABLE
1112)
1213
1314
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+
1420def intlist (obj ):
1521 return [int (v ) for v in obj ]
1622
1723
24+ @pytest .mark .redismod
1825async def test_create (decoded_r : redis .Redis ):
1926 """Test CREATE/RESERVE calls"""
2027 assert await decoded_r .bf ().create ("bloom" , 0.01 , 1000 )
@@ -30,10 +37,12 @@ async def test_create(decoded_r: redis.Redis):
3037
3138
3239@pytest .mark .experimental
40+ @pytest .mark .redismod
3341async def test_tdigest_create (decoded_r : redis .Redis ):
3442 assert await decoded_r .tdigest ().create ("tDigest" , 100 )
3543
3644
45+ @pytest .mark .redismod
3746async def test_bf_add (decoded_r : redis .Redis ):
3847 assert await decoded_r .bf ().create ("bloom" , 0.01 , 1000 )
3948 assert 1 == await decoded_r .bf ().add ("bloom" , "foo" )
@@ -46,6 +55,7 @@ async def test_bf_add(decoded_r: redis.Redis):
4655 assert [1 , 0 ] == intlist (await decoded_r .bf ().mexists ("bloom" , "foo" , "noexist" ))
4756
4857
58+ @pytest .mark .redismod
4959async def test_bf_insert (decoded_r : redis .Redis ):
5060 assert await decoded_r .bf ().create ("bloom" , 0.01 , 1000 )
5161 assert [1 ] == intlist (await decoded_r .bf ().insert ("bloom" , ["foo" ]))
@@ -76,6 +86,7 @@ async def test_bf_insert(decoded_r: redis.Redis):
7686 )
7787
7888
89+ @pytest .mark .redismod
7990async def test_bf_scandump_and_loadchunk (decoded_r : redis .Redis ):
8091 # Store a filter
8192 await decoded_r .bf ().create ("myBloom" , "0.0001" , "1000" )
@@ -127,6 +138,7 @@ async def do_verify():
127138 await decoded_r .bf ().create ("myBloom" , "0.0001" , "10000000" )
128139
129140
141+ @pytest .mark .redismod
130142async def test_bf_info (decoded_r : redis .Redis ):
131143 expansion = 4
132144 # Store a filter
@@ -158,6 +170,7 @@ async def test_bf_info(decoded_r: redis.Redis):
158170 assert True
159171
160172
173+ @pytest .mark .redismod
161174async def test_bf_card (decoded_r : redis .Redis ):
162175 # return 0 if the key does not exist
163176 assert await decoded_r .bf ().card ("not_exist" ) == 0
@@ -172,6 +185,7 @@ async def test_bf_card(decoded_r: redis.Redis):
172185 await decoded_r .bf ().card ("setKey" )
173186
174187
188+ @pytest .mark .redismod
175189async def test_cf_add_and_insert (decoded_r : redis .Redis ):
176190 assert await decoded_r .cf ().create ("cuckoo" , 1000 )
177191 assert await decoded_r .cf ().add ("cuckoo" , "filter" )
@@ -197,6 +211,7 @@ async def test_cf_add_and_insert(decoded_r: redis.Redis):
197211 )
198212
199213
214+ @pytest .mark .redismod
200215async def test_cf_exists_and_del (decoded_r : redis .Redis ):
201216 assert await decoded_r .cf ().create ("cuckoo" , 1000 )
202217 assert await decoded_r .cf ().add ("cuckoo" , "filter" )
@@ -208,6 +223,7 @@ async def test_cf_exists_and_del(decoded_r: redis.Redis):
208223 assert 0 == await decoded_r .cf ().count ("cuckoo" , "filter" )
209224
210225
226+ @pytest .mark .redismod
211227async def test_cms (decoded_r : redis .Redis ):
212228 assert await decoded_r .cms ().initbydim ("dim" , 1000 , 5 )
213229 assert await decoded_r .cms ().initbyprob ("prob" , 0.01 , 0.01 )
@@ -224,6 +240,7 @@ async def test_cms(decoded_r: redis.Redis):
224240
225241
226242@pytest .mark .onlynoncluster
243+ @pytest .mark .redismod
227244async def test_cms_merge (decoded_r : redis .Redis ):
228245 assert await decoded_r .cms ().initbydim ("A" , 1000 , 5 )
229246 assert await decoded_r .cms ().initbydim ("B" , 1000 , 5 )
@@ -240,6 +257,7 @@ async def test_cms_merge(decoded_r: redis.Redis):
240257 assert [16 , 15 , 21 ] == await decoded_r .cms ().query ("C" , "foo" , "bar" , "baz" )
241258
242259
260+ @pytest .mark .redismod
243261async def test_topk (decoded_r : redis .Redis ):
244262 # test list with empty buckets
245263 assert await decoded_r .topk ().reserve ("topk" , 3 , 50 , 4 , 0.9 )
@@ -320,6 +338,7 @@ async def test_topk(decoded_r: redis.Redis):
320338 assert 0.9 == round (float (info ["decay" ]), 1 )
321339
322340
341+ @pytest .mark .redismod
323342async def test_topk_incrby (decoded_r : redis .Redis ):
324343 await decoded_r .flushdb ()
325344 assert await decoded_r .topk ().reserve ("topk" , 3 , 10 , 3 , 1 )
@@ -335,6 +354,7 @@ async def test_topk_incrby(decoded_r: redis.Redis):
335354
336355
337356@pytest .mark .experimental
357+ @pytest .mark .redismod
338358async def test_tdigest_reset (decoded_r : redis .Redis ):
339359 assert await decoded_r .tdigest ().create ("tDigest" , 10 )
340360 # reset on empty histogram
@@ -351,6 +371,7 @@ async def test_tdigest_reset(decoded_r: redis.Redis):
351371
352372
353373@pytest .mark .onlynoncluster
374+ @pytest .mark .redismod
354375async def test_tdigest_merge (decoded_r : redis .Redis ):
355376 assert await decoded_r .tdigest ().create ("to-tDigest" , 10 )
356377 assert await decoded_r .tdigest ().create ("from-tDigest" , 10 )
@@ -378,6 +399,7 @@ async def test_tdigest_merge(decoded_r: redis.Redis):
378399
379400
380401@pytest .mark .experimental
402+ @pytest .mark .redismod
381403async def test_tdigest_min_and_max (decoded_r : redis .Redis ):
382404 assert await decoded_r .tdigest ().create ("tDigest" , 100 )
383405 # insert data-points into sketch
@@ -388,6 +410,7 @@ async def test_tdigest_min_and_max(decoded_r: redis.Redis):
388410
389411
390412@pytest .mark .experimental
413+ @pytest .mark .redismod
391414@skip_ifmodversion_lt ("2.4.0" , "bf" )
392415async def test_tdigest_quantile (decoded_r : redis .Redis ):
393416 assert await decoded_r .tdigest ().create ("tDigest" , 500 )
@@ -416,6 +439,7 @@ async def test_tdigest_quantile(decoded_r: redis.Redis):
416439
417440
418441@pytest .mark .experimental
442+ @pytest .mark .redismod
419443async def test_tdigest_cdf (decoded_r : redis .Redis ):
420444 assert await decoded_r .tdigest ().create ("tDigest" , 100 )
421445 # insert data-points into sketch
@@ -427,6 +451,7 @@ async def test_tdigest_cdf(decoded_r: redis.Redis):
427451
428452
429453@pytest .mark .experimental
454+ @pytest .mark .redismod
430455@skip_ifmodversion_lt ("2.4.0" , "bf" )
431456async def test_tdigest_trimmed_mean (decoded_r : redis .Redis ):
432457 assert await decoded_r .tdigest ().create ("tDigest" , 100 )
@@ -437,6 +462,7 @@ async def test_tdigest_trimmed_mean(decoded_r: redis.Redis):
437462
438463
439464@pytest .mark .experimental
465+ @pytest .mark .redismod
440466async def test_tdigest_rank (decoded_r : redis .Redis ):
441467 assert await decoded_r .tdigest ().create ("t-digest" , 500 )
442468 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):
447473
448474
449475@pytest .mark .experimental
476+ @pytest .mark .redismod
450477async def test_tdigest_revrank (decoded_r : redis .Redis ):
451478 assert await decoded_r .tdigest ().create ("t-digest" , 500 )
452479 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):
456483
457484
458485@pytest .mark .experimental
486+ @pytest .mark .redismod
459487async def test_tdigest_byrank (decoded_r : redis .Redis ):
460488 assert await decoded_r .tdigest ().create ("t-digest" , 500 )
461489 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):
467495
468496
469497@pytest .mark .experimental
498+ @pytest .mark .redismod
470499async def test_tdigest_byrevrank (decoded_r : redis .Redis ):
471500 assert await decoded_r .tdigest ().create ("t-digest" , 500 )
472501 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):
475504 assert (await decoded_r .tdigest ().byrevrank ("t-digest" , 100 ))[0 ] == - inf
476505 with pytest .raises (redis .ResponseError ):
477506 (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