MCPcopy
hub / github.com/redis/redis-py / test_arrtrim

Function test_arrtrim

tests/test_asyncio/test_json.py:378–397  ·  view source on GitHub ↗
(decoded_r: redis.Redis)

Source from the content-addressed store, hash-verified

376
377@pytest.mark.redismod
378async def test_arrtrim(decoded_r: redis.Redis):
379 await decoded_r.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4])
380 assert 3 == await decoded_r.json().arrtrim("arr", Path.root_path(), 1, 3)
381 assert [1, 2, 3] == await decoded_r.json().get("arr")
382
383 # <0 test, should be 0 equivalent
384 await decoded_r.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4])
385 assert 0 == await decoded_r.json().arrtrim("arr", Path.root_path(), -1, 3)
386
387 # testing stop > end
388 await decoded_r.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4])
389 assert 2 == await decoded_r.json().arrtrim("arr", Path.root_path(), 3, 99)
390
391 # start > array size and stop
392 await decoded_r.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4])
393 assert 0 == await decoded_r.json().arrtrim("arr", Path.root_path(), 9, 1)
394
395 # all larger
396 await decoded_r.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4])
397 assert 0 == await decoded_r.json().arrtrim("arr", Path.root_path(), 9, 11)
398
399
400@pytest.mark.redismod

Callers

nothing calls this directly

Calls 5

root_pathMethod · 0.80
arrtrimMethod · 0.80
setMethod · 0.45
jsonMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected