Skip to content
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

Fix TIMESERIES (round floats) and JSON tests #2421

Merged
merged 3 commits into from
Oct 23, 2022
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
2 changes: 1 addition & 1 deletion tests/test_asyncio/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ async def test_objlen_dollar(modclient: redis.Redis):
},
)
# Test multi
assert await modclient.json().objlen("doc1", "$..a") == [2, None, 1]
assert await modclient.json().objlen("doc1", "$..a") == [None, 2, 1]
# Test single
assert await modclient.json().objlen("doc1", "$.nested1.a") == [2]

Expand Down
2 changes: 1 addition & 1 deletion tests/test_asyncio/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ async def test_range_advanced(modclient: redis.Redis):
assert [(0, 5.0), (5, 6.0)] == await modclient.ts().range(
1, 0, 10, aggregation_type="count", bucket_size_msec=10, align=5
)
assert [(0, 2.5500000000000003), (10, 3.0)] == await modclient.ts().range(
assert [(0, 2.55), (10, 3.0)] == await modclient.ts().range(
1, 0, 10, aggregation_type="twa", bucket_size_msec=10
)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ def test_objlen_dollar(client):
},
)
# Test multi
assert client.json().objlen("doc1", "$..a") == [2, None, 1]
assert client.json().objlen("doc1", "$..a") == [None, 2, 1]
# Test single
assert client.json().objlen("doc1", "$.nested1.a") == [2]

Expand Down
11 changes: 2 additions & 9 deletions tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -1448,23 +1448,16 @@ def test_json_with_jsonpath(client):
assert res.docs[0].id == "doc:1"
assert res.docs[0].json == '{"prod:name":"RediSearch"}'

# query for an unsupported field fails
# query for an unsupported field
res = client.ft().search("@name_unsupported:RediSearch")
assert res.total == 0
assert res.total == 1

# return of a supported field succeeds
res = client.ft().search(Query("@name:RediSearch").return_field("name"))
assert res.total == 1
assert res.docs[0].id == "doc:1"
assert res.docs[0].name == "RediSearch"

# return of an unsupported field fails
res = client.ft().search(Query("@name:RediSearch").return_field("name_unsupported"))
assert res.total == 1
assert res.docs[0].id == "doc:1"
with pytest.raises(Exception):
res.docs[0].name_unsupported


@pytest.mark.redismod
@pytest.mark.onlynoncluster
Expand Down
4 changes: 2 additions & 2 deletions tests/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def test_range_advanced(client):
assert [(0, 5.0), (5, 6.0)] == client.ts().range(
1, 0, 10, aggregation_type="count", bucket_size_msec=10, align=5
)
assert [(0, 2.5500000000000003), (10, 3.0)] == client.ts().range(
assert [(0, 2.55), (10, 3.0)] == client.ts().range(
1, 0, 10, aggregation_type="twa", bucket_size_msec=10
)

Expand Down Expand Up @@ -343,7 +343,7 @@ def test_rev_range(client):
assert [(1, 10.0), (0, 1.0)] == client.ts().revrange(
1, 0, 10, aggregation_type="count", bucket_size_msec=10, align=1
)
assert [(10, 3.0), (0, 2.5500000000000003)] == client.ts().revrange(
assert [(10, 3.0), (0, 2.55)] == client.ts().revrange(
1, 0, 10, aggregation_type="twa", bucket_size_msec=10
)

Expand Down