diff options
author | Alex Schmitz <alex.schmitz@gmail.com> | 2023-03-15 04:33:38 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-15 11:33:38 +0200 |
commit | b546a9a81c374b054835a5eeda9b580344d78dfd (patch) | |
tree | 6d5e3a89ec63adff4a55fe6d63a4ff26aa05eaae /tests | |
parent | 6c708c2e0511364c2c3f21fa1259de05e590632d (diff) | |
download | redis-py-b546a9a81c374b054835a5eeda9b580344d78dfd.tar.gz |
update json().arrindex() default values (#2611)
* update json().arrindex() default values
* add unit test
* fix falsy checks
* more unit tests
* add asyncio tests
* fix lint line length
---------
Co-authored-by: Alex Schmitz <aschmitz@box.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_asyncio/test_json.py | 12 | ||||
-rw-r--r-- | tests/test_json.py | 5 |
2 files changed, 14 insertions, 3 deletions
diff --git a/tests/test_asyncio/test_json.py b/tests/test_asyncio/test_json.py index b8854d2..fc530c6 100644 --- a/tests/test_asyncio/test_json.py +++ b/tests/test_asyncio/test_json.py @@ -145,9 +145,15 @@ async def test_arrappend(modclient: redis.Redis): @pytest.mark.redismod async def test_arrindex(modclient: redis.Redis): - await modclient.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4]) - assert 1 == await modclient.json().arrindex("arr", Path.root_path(), 1) - assert -1 == await modclient.json().arrindex("arr", Path.root_path(), 1, 2) + r_path = Path.root_path() + await modclient.json().set("arr", r_path, [0, 1, 2, 3, 4]) + assert 1 == await modclient.json().arrindex("arr", r_path, 1) + assert -1 == await modclient.json().arrindex("arr", r_path, 1, 2) + assert 4 == await modclient.json().arrindex("arr", r_path, 4) + assert 4 == await modclient.json().arrindex("arr", r_path, 4, start=0) + assert 4 == await modclient.json().arrindex("arr", r_path, 4, start=0, stop=5000) + assert -1 == await modclient.json().arrindex("arr", r_path, 4, start=0, stop=-1) + assert -1 == await modclient.json().arrindex("arr", r_path, 4, start=1, stop=3) @pytest.mark.redismod diff --git a/tests/test_json.py b/tests/test_json.py index a776e9e..8e8da05 100644 --- a/tests/test_json.py +++ b/tests/test_json.py @@ -166,6 +166,11 @@ def test_arrindex(client): client.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4]) assert 1 == client.json().arrindex("arr", Path.root_path(), 1) assert -1 == client.json().arrindex("arr", Path.root_path(), 1, 2) + assert 4 == client.json().arrindex("arr", Path.root_path(), 4) + assert 4 == client.json().arrindex("arr", Path.root_path(), 4, start=0) + assert 4 == client.json().arrindex("arr", Path.root_path(), 4, start=0, stop=5000) + assert -1 == client.json().arrindex("arr", Path.root_path(), 4, start=0, stop=-1) + assert -1 == client.json().arrindex("arr", Path.root_path(), 4, start=1, stop=3) @pytest.mark.redismod |