From 599f5a991eda770799a1aea23848b1442019deeb Mon Sep 17 00:00:00 2001 From: Chayim Date: Tue, 9 Nov 2021 11:24:48 +0200 Subject: Re-enable pipeline support for JSON and TimeSeries (#1674) --- tests/test_json.py | 32 ++++++++++++++++++++++---------- tests/test_timeseries.py | 31 +++++++++++++------------------ 2 files changed, 35 insertions(+), 28 deletions(-) (limited to 'tests') diff --git a/tests/test_json.py b/tests/test_json.py index 19b0c32..b3f38f7 100644 --- a/tests/test_json.py +++ b/tests/test_json.py @@ -275,16 +275,28 @@ def test_objlen(client): assert len(obj) == client.json().objlen("obj") -# @pytest.mark.pipeline -# @pytest.mark.redismod -# def test_pipelineshouldsucceed(client): -# p = client.json().pipeline() -# p.set("foo", Path.rootPath(), "bar") -# p.get("foo") -# p.delete("foo") -# assert [True, "bar", 1] == p.execute() -# assert client.keys() == [] -# assert client.get("foo") is None +@pytest.mark.pipeline +@pytest.mark.redismod +def test_json_commands_in_pipeline(client): + p = client.json().pipeline() + p.set("foo", Path.rootPath(), "bar") + p.get("foo") + p.delete("foo") + assert [True, "bar", 1] == p.execute() + assert client.keys() == [] + assert client.get("foo") is None + + # now with a true, json object + client.flushdb() + p = client.json().pipeline() + d = {"hello": "world", "oh": "snap"} + p.jsonset("foo", Path.rootPath(), d) + p.jsonget("foo") + p.exists("notarealkey") + p.delete("foo") + assert [True, d, 0, 1] == p.execute() + assert client.keys() == [] + assert client.get("foo") is None @pytest.mark.redismod diff --git a/tests/test_timeseries.py b/tests/test_timeseries.py index b2df3fe..d3d474f 100644 --- a/tests/test_timeseries.py +++ b/tests/test_timeseries.py @@ -49,10 +49,6 @@ def testAlter(client): assert 10 == client.ts().info(1).retention_msecs -# pipe = client.ts().pipeline() -# assert pipe.create(2) - - @pytest.mark.redismod @skip_ifmodversion_lt("1.4.0", "timeseries") def testAlterDiplicatePolicy(client): @@ -568,20 +564,19 @@ def testQueryIndex(client): assert [2] == client.ts().queryindex(["Taste=That"]) -# -# @pytest.mark.redismod -# @pytest.mark.pipeline -# def testPipeline(client): -# pipeline = client.ts().pipeline() -# pipeline.create("with_pipeline") -# for i in range(100): -# pipeline.add("with_pipeline", i, 1.1 * i) -# pipeline.execute() - -# info = client.ts().info("with_pipeline") -# assert info.lastTimeStamp == 99 -# assert info.total_samples == 100 -# assert client.ts().get("with_pipeline")[1] == 99 * 1.1 +@pytest.mark.redismod +@pytest.mark.pipeline +def test_pipeline(client): + pipeline = client.ts().pipeline() + pipeline.create("with_pipeline") + for i in range(100): + pipeline.add("with_pipeline", i, 1.1 * i) + pipeline.execute() + + info = client.ts().info("with_pipeline") + assert info.lastTimeStamp == 99 + assert info.total_samples == 100 + assert client.ts().get("with_pipeline")[1] == 99 * 1.1 @pytest.mark.redismod -- cgit v1.2.1