| 957 | |
| 958 | @pytest.mark.redismod |
| 959 | async def test_objkeys_dollar(decoded_r: redis.Redis): |
| 960 | await decoded_r.json().set( |
| 961 | "doc1", |
| 962 | "$", |
| 963 | { |
| 964 | "nested1": {"a": {"foo": 10, "bar": 20}}, |
| 965 | "a": ["foo"], |
| 966 | "nested2": {"a": {"baz": 50}}, |
| 967 | }, |
| 968 | ) |
| 969 | |
| 970 | # Test single |
| 971 | assert await decoded_r.json().objkeys("doc1", "$.nested1.a") == [["foo", "bar"]] |
| 972 | |
| 973 | # Test legacy |
| 974 | assert await decoded_r.json().objkeys("doc1", ".*.a") == ["foo", "bar"] |
| 975 | # Test single |
| 976 | assert await decoded_r.json().objkeys("doc1", ".nested2.a") == ["baz"] |
| 977 | |
| 978 | # Test missing key |
| 979 | assert await decoded_r.json().objkeys("non_existing_doc", "..a") is None |
| 980 | |
| 981 | # Test non existing doc |
| 982 | with pytest.raises(exceptions.ResponseError): |
| 983 | assert await decoded_r.json().objkeys("non_existing_doc", "$..a") == [] |
| 984 | |
| 985 | assert await decoded_r.json().objkeys("doc1", "$..nowhere") == [] |
| 986 | |
| 987 | |
| 988 | @pytest.mark.redismod |