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

Function test_mrange

tests/test_timeseries.py:556–600  ·  view source on GitHub ↗
(client)

Source from the content-addressed store, hash-verified

554@pytest.mark.onlynoncluster
555@pytest.mark.redismod
556def test_mrange(client):
557 client.ts().create(1, labels={"Test": "This", "team": "ny"})
558 client.ts().create(2, labels={"Test": "This", "Taste": "That", "team": "sf"})
559 for i in range(100):
560 client.ts().add(1, i, i % 7)
561 client.ts().add(2, i, i % 11)
562
563 res = client.ts().mrange(0, 200, filters=["Test=This"])
564 assert 2 == len(res)
565 if expects_resp2_shape(client):
566 assert 100 == len(res[0]["1"][1])
567
568 res = client.ts().mrange(0, 200, filters=["Test=This"], count=10)
569 assert 10 == len(res[0]["1"][1])
570
571 for i in range(100):
572 client.ts().add(1, i + 200, i % 7)
573 res = client.ts().mrange(
574 0, 500, filters=["Test=This"], aggregation_type="avg", bucket_size_msec=10
575 )
576 assert 2 == len(res)
577 assert 20 == len(res[0]["1"][1])
578
579 # test withlabels
580 assert {} == res[0]["1"][0]
581 res = client.ts().mrange(0, 200, filters=["Test=This"], with_labels=True)
582 assert {"Test": "This", "team": "ny"} == res[0]["1"][0]
583 else:
584 assert 100 == len(res["1"][2])
585
586 res = client.ts().mrange(0, 200, filters=["Test=This"], count=10)
587 assert 10 == len(res["1"][2])
588
589 for i in range(100):
590 client.ts().add(1, i + 200, i % 7)
591 res = client.ts().mrange(
592 0, 500, filters=["Test=This"], aggregation_type="avg", bucket_size_msec=10
593 )
594 assert 2 == len(res)
595 assert 20 == len(res["1"][2])
596
597 # test withlabels
598 assert {} == res["1"][0]
599 res = client.ts().mrange(0, 200, filters=["Test=This"], with_labels=True)
600 assert {"Test": "This", "team": "ny"} == res["1"][0]
601
602
603@pytest.mark.onlynoncluster

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected