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

Function test_multi_range

tests/test_asyncio/test_timeseries.py:369–426  ·  view source on GitHub ↗
(decoded_r: redis.Redis)

Source from the content-addressed store, hash-verified

367@pytest.mark.onlynoncluster
368@pytest.mark.redismod
369async def test_multi_range(decoded_r: redis.Redis):
370 await decoded_r.ts().create(KEY1, labels={"Test": "This", "team": "ny"})
371 await decoded_r.ts().create(
372 KEY2, labels={"Test": "This", "Taste": "That", "team": "sf"}
373 )
374 for i in range(100):
375 await decoded_r.ts().add(KEY1, i, i % 7)
376 await decoded_r.ts().add(KEY2, i, i % 11)
377
378 res = await decoded_r.ts().mrange(0, 200, filters=["Test=This"])
379 assert res is not None
380 assert 2 == len(res)
381 if expects_resp2_shape(decoded_r):
382 assert 100 == len(res[0][KEY1][1])
383
384 res = await decoded_r.ts().mrange(0, 200, filters=["Test=This"], count=10)
385 assert res is not None
386 assert 10 == len(res[0][KEY1][1])
387
388 for i in range(100):
389 await decoded_r.ts().add(KEY1, i + 200, i % 7)
390 res = await decoded_r.ts().mrange(
391 0, 500, filters=["Test=This"], aggregation_type="avg", bucket_size_msec=10
392 )
393 assert res is not None
394 assert 2 == len(res)
395 assert 20 == len(res[0][KEY1][1])
396
397 # test withlabels
398 assert {} == res[0][KEY1][0]
399 res = await decoded_r.ts().mrange(
400 0, 200, filters=["Test=This"], with_labels=True
401 )
402 assert res is not None
403 assert {"Test": "This", "team": "ny"} == res[0][KEY1][0]
404 else:
405 assert 100 == len(res[KEY1][2])
406
407 res = await decoded_r.ts().mrange(0, 200, filters=["Test=This"], count=10)
408 assert res is not None
409 assert 10 == len(res[KEY1][2])
410
411 for i in range(100):
412 await decoded_r.ts().add(KEY1, i + 200, i % 7)
413 res = await decoded_r.ts().mrange(
414 0, 500, filters=["Test=This"], aggregation_type="avg", bucket_size_msec=10
415 )
416 assert res is not None
417 assert 2 == len(res)
418 assert 20 == len(res[KEY1][2])
419
420 # test withlabels
421 assert {} == res[KEY1][0]
422 res = await decoded_r.ts().mrange(
423 0, 200, filters=["Test=This"], with_labels=True
424 )
425 assert res is not None
426 assert {"Test": "This", "team": "ny"} == res[KEY1][0]

Callers

nothing calls this directly

Calls 5

expects_resp2_shapeFunction · 0.90
mrangeMethod · 0.80
createMethod · 0.45
tsMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected