| 842 | |
| 843 | @pytest.mark.redismod |
| 844 | def 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 |