Skip to content

Commit e8bcdcb

Browse files
committed
RedisJSON 2.0.4 behaviour support improvements
1 parent 64791a5 commit e8bcdcb

File tree

3 files changed

+32
-27
lines changed

3 files changed

+32
-27
lines changed

tests/conftest.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,12 @@ def skip_ifmodversion_lt(min_version: str, module_name: str):
102102

103103
def skip_if_redis_enterprise(func):
104104
check = REDIS_INFO["enterprise"] is True
105-
return pytest.mark.skipif(check, reason="Redis enterprise"
106-
)
105+
return pytest.mark.skipif(check, reason="Redis enterprise")
107106

108107

109108
def skip_ifnot_redis_enterprise(func):
110109
check = REDIS_INFO["enterprise"] is False
111-
return pytest.mark.skipif(check, reason="Redis enterprise")
110+
return pytest.mark.skipif(check, reason="Not running in redis enterprise")
112111

113112

114113
def _get_client(cls, request, single_connection_client=True, flushdb=True,

tests/test_json.py

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,6 @@ def test_objlen(client):
275275
assert len(obj) == client.json().objlen("obj")
276276

277277

278-
@pytest.mark.pipeline
279278
@pytest.mark.redismod
280279
def test_json_commands_in_pipeline(client):
281280
p = client.json().pipeline()
@@ -290,8 +289,9 @@ def test_json_commands_in_pipeline(client):
290289
client.flushdb()
291290
p = client.json().pipeline()
292291
d = {"hello": "world", "oh": "snap"}
293-
p.jsonset("foo", Path.rootPath(), d)
294-
p.jsonget("foo")
292+
with pytest.deprecated_call():
293+
p.jsonset("foo", Path.rootPath(), d)
294+
p.jsonget("foo")
295295
p.exists("notarealkey")
296296
p.delete("foo")
297297
assert [True, d, 0, 1] == p.execute()
@@ -463,14 +463,18 @@ def test_numby_commands_dollar(client):
463463
client.json().set("doc1", "$", {"a": "b", "b": [
464464
{"a": 2}, {"a": 5.0}, {"a": "c"}]})
465465

466-
assert client.json().nummultby("doc1", "$..a", 2) == \
467-
[None, 4, 10, None]
468-
assert client.json().nummultby("doc1", "$..a", 2.5) == \
469-
[None, 10.0, 25.0, None]
466+
# test list
467+
with pytest.deprecated_call():
468+
assert client.json().nummultby("doc1", "$..a", 2) == \
469+
[None, 4, 10, None]
470+
assert client.json().nummultby("doc1", "$..a", 2.5) == \
471+
[None, 10.0, 25.0, None]
472+
470473
# Test single
471-
assert client.json().nummultby("doc1", "$.b[1].a", 2) == [50.0]
472-
assert client.json().nummultby("doc1", "$.b[2].a", 2) == [None]
473-
assert client.json().nummultby("doc1", "$.b[1].a", 3) == [150.0]
474+
with pytest.deprecated_call():
475+
assert client.json().nummultby("doc1", "$.b[1].a", 2) == [50.0]
476+
assert client.json().nummultby("doc1", "$.b[2].a", 2) == [None]
477+
assert client.json().nummultby("doc1", "$.b[1].a", 3) == [150.0]
474478

475479
# test missing keys
476480
with pytest.raises(exceptions.ResponseError):
@@ -485,7 +489,9 @@ def test_numby_commands_dollar(client):
485489
# Test legacy NUMMULTBY
486490
client.json().set("doc1", "$", {"a": "b", "b": [
487491
{"a": 2}, {"a": 5.0}, {"a": "c"}]})
488-
client.json().nummultby("doc1", ".b[0].a", 3) == 6
492+
493+
with pytest.deprecated_call():
494+
client.json().nummultby("doc1", ".b[0].a", 3) == 6
489495

490496

491497
@pytest.mark.redismod
@@ -824,9 +830,11 @@ def test_objkeys_dollar(client):
824830
# Test missing key
825831
assert client.json().objkeys("non_existing_doc", "..a") is None
826832

827-
# Test missing key
833+
# Test non existing doc
828834
with pytest.raises(exceptions.ResponseError):
829-
client.json().objkeys("doc1", "$.nowhere")
835+
assert client.json().objkeys("non_existing_doc", "$..a") == []
836+
837+
assert client.json().objkeys("doc1", "$..nowhere") == []
830838

831839

832840
@pytest.mark.redismod
@@ -845,12 +853,11 @@ def test_objlen_dollar(client):
845853
# Test single
846854
assert client.json().objlen("doc1", "$.nested1.a") == [2]
847855

848-
# Test missing key
849-
assert client.json().objlen("non_existing_doc", "$..a") is None
850-
851-
# Test missing path
856+
# Test missing key, and path
852857
with pytest.raises(exceptions.ResponseError):
853-
client.json().objlen("doc1", "$.nowhere")
858+
client.json().objlen("non_existing_doc", "$..a")
859+
860+
assert client.json().objlen("doc1", "$.nowhere") == []
854861

855862
# Test legacy
856863
assert client.json().objlen("doc1", ".*.a") == 2
@@ -862,8 +869,8 @@ def test_objlen_dollar(client):
862869
assert client.json().objlen("non_existing_doc", "..a") is None
863870

864871
# Test missing path
865-
with pytest.raises(exceptions.ResponseError):
866-
client.json().objlen("doc1", ".nowhere")
872+
# with pytest.raises(exceptions.ResponseError):
873+
client.json().objlen("doc1", ".nowhere")
867874

868875

869876
@pytest.mark.redismod
@@ -1143,11 +1150,11 @@ def test_resp_dollar(client):
11431150
]
11441151

11451152
# Test missing path
1146-
with pytest.raises(exceptions.ResponseError):
1147-
client.json().resp("doc1", "$.nowhere")
1153+
client.json().resp("doc1", "$.nowhere")
11481154

11491155
# Test missing key
1150-
assert client.json().resp("non_existing_doc", "$..a") is None
1156+
# with pytest.raises(exceptions.ResponseError):
1157+
client.json().resp("non_existing_doc", "$..a")
11511158

11521159

11531160
@pytest.mark.redismod

tests/test_timeseries.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,6 @@ def test_query_index(client):
565565

566566

567567
@pytest.mark.redismod
568-
@pytest.mark.pipeline
569568
def test_pipeline(client):
570569
pipeline = client.ts().pipeline()
571570
pipeline.create("with_pipeline")

0 commit comments

Comments
 (0)