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

Function test_arrtrim

tests/test_json.py:366–385  ·  view source on GitHub ↗
(client)

Source from the content-addressed store, hash-verified

364
365@pytest.mark.redismod
366def test_arrtrim(client):
367 client.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4])
368 assert 3 == client.json().arrtrim("arr", Path.root_path(), 1, 3)
369 assert [1, 2, 3] == client.json().get("arr")
370
371 # <0 test, should be 0 equivalent
372 client.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4])
373 assert 0 == client.json().arrtrim("arr", Path.root_path(), -1, 3)
374
375 # testing stop > end
376 client.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4])
377 assert 2 == client.json().arrtrim("arr", Path.root_path(), 3, 99)
378
379 # start > array size and stop
380 client.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4])
381 assert 0 == client.json().arrtrim("arr", Path.root_path(), 9, 1)
382
383 # all larger
384 client.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4])
385 assert 0 == client.json().arrtrim("arr", Path.root_path(), 9, 11)
386
387
388@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