Skip to content

RedisJSON 2.0.4 behaviour support #1747

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,12 @@ def skip_ifmodversion_lt(min_version: str, module_name: str):

def skip_if_redis_enterprise(func):
check = REDIS_INFO["enterprise"] is True
return pytest.mark.skipif(check, reason="Redis enterprise"
)
return pytest.mark.skipif(check, reason="Redis enterprise")


def skip_ifnot_redis_enterprise(func):
check = REDIS_INFO["enterprise"] is False
return pytest.mark.skipif(check, reason="Redis enterprise")
return pytest.mark.skipif(check, reason="Not running in redis enterprise")


def _get_client(cls, request, single_connection_client=True, flushdb=True,
Expand Down
53 changes: 30 additions & 23 deletions tests/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ def test_objlen(client):
assert len(obj) == client.json().objlen("obj")


@pytest.mark.pipeline
@pytest.mark.redismod
def test_json_commands_in_pipeline(client):
p = client.json().pipeline()
Expand All @@ -290,8 +289,9 @@ def test_json_commands_in_pipeline(client):
client.flushdb()
p = client.json().pipeline()
d = {"hello": "world", "oh": "snap"}
p.jsonset("foo", Path.rootPath(), d)
p.jsonget("foo")
with pytest.deprecated_call():
p.jsonset("foo", Path.rootPath(), d)
p.jsonget("foo")
p.exists("notarealkey")
p.delete("foo")
assert [True, d, 0, 1] == p.execute()
Expand Down Expand Up @@ -463,14 +463,18 @@ def test_numby_commands_dollar(client):
client.json().set("doc1", "$", {"a": "b", "b": [
{"a": 2}, {"a": 5.0}, {"a": "c"}]})

assert client.json().nummultby("doc1", "$..a", 2) == \
[None, 4, 10, None]
assert client.json().nummultby("doc1", "$..a", 2.5) == \
[None, 10.0, 25.0, None]
# test list
with pytest.deprecated_call():
assert client.json().nummultby("doc1", "$..a", 2) == \
[None, 4, 10, None]
assert client.json().nummultby("doc1", "$..a", 2.5) == \
[None, 10.0, 25.0, None]

# Test single
assert client.json().nummultby("doc1", "$.b[1].a", 2) == [50.0]
assert client.json().nummultby("doc1", "$.b[2].a", 2) == [None]
assert client.json().nummultby("doc1", "$.b[1].a", 3) == [150.0]
with pytest.deprecated_call():
assert client.json().nummultby("doc1", "$.b[1].a", 2) == [50.0]
assert client.json().nummultby("doc1", "$.b[2].a", 2) == [None]
assert client.json().nummultby("doc1", "$.b[1].a", 3) == [150.0]

# test missing keys
with pytest.raises(exceptions.ResponseError):
Expand All @@ -485,7 +489,9 @@ def test_numby_commands_dollar(client):
# Test legacy NUMMULTBY
client.json().set("doc1", "$", {"a": "b", "b": [
{"a": 2}, {"a": 5.0}, {"a": "c"}]})
client.json().nummultby("doc1", ".b[0].a", 3) == 6

with pytest.deprecated_call():
client.json().nummultby("doc1", ".b[0].a", 3) == 6


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

# Test missing key
# Test non existing doc
with pytest.raises(exceptions.ResponseError):
client.json().objkeys("doc1", "$.nowhere")
assert client.json().objkeys("non_existing_doc", "$..a") == []

assert client.json().objkeys("doc1", "$..nowhere") == []


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

# Test missing key
assert client.json().objlen("non_existing_doc", "$..a") is None

# Test missing path
# Test missing key, and path
with pytest.raises(exceptions.ResponseError):
client.json().objlen("doc1", "$.nowhere")
client.json().objlen("non_existing_doc", "$..a")

assert client.json().objlen("doc1", "$.nowhere") == []

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

# Test missing path
with pytest.raises(exceptions.ResponseError):
client.json().objlen("doc1", ".nowhere")
# with pytest.raises(exceptions.ResponseError):
client.json().objlen("doc1", ".nowhere")


@pytest.mark.redismod
Expand Down Expand Up @@ -1143,11 +1150,11 @@ def test_resp_dollar(client):
]

# Test missing path
with pytest.raises(exceptions.ResponseError):
client.json().resp("doc1", "$.nowhere")
client.json().resp("doc1", "$.nowhere")

# Test missing key
assert client.json().resp("non_existing_doc", "$..a") is None
# with pytest.raises(exceptions.ResponseError):
client.json().resp("non_existing_doc", "$..a")


@pytest.mark.redismod
Expand Down
1 change: 0 additions & 1 deletion tests/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,6 @@ def test_query_index(client):


@pytest.mark.redismod
@pytest.mark.pipeline
def test_pipeline(client):
pipeline = client.ts().pipeline()
pipeline.create("with_pipeline")
Expand Down