Skip to content

Commit

Permalink
Fix TIMESERIES (round floats) and JSON tests (#2421)
Browse files Browse the repository at this point in the history
* Fix timeseries tests (round floats)

* fix json tests
  • Loading branch information
dvora-h authored Oct 23, 2022
1 parent e867f9e commit aa0ae68
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 14 deletions.
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

0 comments on commit aa0ae68

Please sign in to comment.