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

Function test_arrpop_dollar

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

Source from the content-addressed store, hash-verified

842
843@pytest.mark.redismod
844def test_arrpop_dollar(client):
845 client.json().set(
846 "doc1",
847 "$",
848 {
849 "a": ["foo"],
850 "nested1": {"a": ["hello", None, "world"]},
851 "nested2": {"a": 31},
852 },
853 )
854
855 # # # Test multi
856 assert client.json().arrpop("doc1", "$..a", 1) == ['"foo"', None, None]
857
858 res = [{"a": [], "nested1": {"a": ["hello", "world"]}, "nested2": {"a": 31}}]
859 assert client.json().get("doc1", "$") == res
860
861 # Test missing key
862 with pytest.raises(exceptions.ResponseError):
863 client.json().arrpop("non_existing_doc", "..a")
864
865 # # Test legacy
866 client.json().set(
867 "doc1",
868 "$",
869 {
870 "a": ["foo"],
871 "nested1": {"a": ["hello", None, "world"]},
872 "nested2": {"a": 31},
873 },
874 )
875 # Test multi (all paths are updated, but return result of last path)
876 assert client.json().arrpop("doc1", "..a", "1") == "null"
877 res = [{"a": [], "nested1": {"a": ["hello", "world"]}, "nested2": {"a": 31}}]
878 assert client.json().get("doc1", "$") == res
879
880 # # Test missing key
881 with pytest.raises(exceptions.ResponseError):
882 client.json().arrpop("non_existing_doc", "..a")
883
884
885@pytest.mark.redismod

Callers

nothing calls this directly

Calls 4

arrpopMethod · 0.80
setMethod · 0.45
jsonMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected