@@ -104,7 +104,7 @@ def test_jsonsetexistentialmodifiersshouldsucceed(client):
104
104
assert client .json ().set ("obj" , Path ("foo" ), "baz" , xx = True )
105
105
assert client .json ().set ("obj" , Path ("qaz" ), "baz" , nx = True )
106
106
107
- # Test that flags are mutually exlusive
107
+ # Test that flags are mutually exclusive
108
108
with pytest .raises (Exception ):
109
109
client .json ().set ("obj" , Path ("foo" ), "baz" , nx = True , xx = True )
110
110
@@ -453,6 +453,7 @@ def test_json_forget_with_dollar(client):
453
453
client .json ().forget ("not_a_document" , "..a" )
454
454
455
455
456
+ @pytest .mark .onlynoncluster
456
457
@pytest .mark .redismod
457
458
def test_json_mget_dollar (client ):
458
459
# Test mget with multi paths
@@ -473,14 +474,14 @@ def test_json_mget_dollar(client):
473
474
assert_resp_response (client , client .json ().get ("doc2" , "$..a" ), res , [res ])
474
475
475
476
# Test mget with single path
476
- client .json ().mget ("doc1" , "$..a" ) == [1 , 3 , None ]
477
+ assert client .json ().mget ([ "doc1" ] , "$..a" ) == [[ 1 , 3 , None ] ]
477
478
# Test mget with multi path
478
- client .json ().mget (["doc1" , "doc2" ], "$..a" ) == [[1 , 3 , None ], [4 , 6 , [None ]]]
479
+ res = [[1 , 3 , None ], [4 , 6 , [None ]]]
480
+ assert client .json ().mget (["doc1" , "doc2" ], "$..a" ) == res
479
481
480
482
# Test missing key
481
- client .json ().mget (["doc1" , "missing_doc" ], "$..a" ) == [[1 , 3 , None ], None ]
482
- res = client .json ().mget (["missing_doc1" , "missing_doc2" ], "$..a" )
483
- assert res == [None , None ]
483
+ assert client .json ().mget (["doc1" , "missing_doc" ], "$..a" ) == [[1 , 3 , None ], None ]
484
+ assert client .json ().mget (["missing_doc1" , "missing_doc2" ], "$..a" ) == [None , None ]
484
485
485
486
486
487
@pytest .mark .redismod
@@ -518,13 +519,13 @@ def test_numby_commands_dollar(client):
518
519
519
520
# Test legacy NUMINCRBY
520
521
client .json ().set ("doc1" , "$" , {"a" : "b" , "b" : [{"a" : 2 }, {"a" : 5.0 }, {"a" : "c" }]})
521
- client .json ().numincrby ("doc1" , ".b[0].a" , 3 ) == 5
522
+ assert client .json ().numincrby ("doc1" , ".b[0].a" , 3 ) == 5
522
523
523
524
# Test legacy NUMMULTBY
524
525
client .json ().set ("doc1" , "$" , {"a" : "b" , "b" : [{"a" : 2 }, {"a" : 5.0 }, {"a" : "c" }]})
525
526
526
527
with pytest .deprecated_call ():
527
- client .json ().nummultby ("doc1" , ".b[0].a" , 3 ) == 6
528
+ assert client .json ().nummultby ("doc1" , ".b[0].a" , 3 ) == 6
528
529
529
530
530
531
@pytest .mark .redismod
@@ -533,25 +534,25 @@ def test_strappend_dollar(client):
533
534
"doc1" , "$" , {"a" : "foo" , "nested1" : {"a" : "hello" }, "nested2" : {"a" : 31 }}
534
535
)
535
536
# Test multi
536
- client .json ().strappend ("doc1" , "bar" , "$..a" ) == [6 , 8 , None ]
537
+ assert client .json ().strappend ("doc1" , "bar" , "$..a" ) == [6 , 8 , None ]
537
538
538
- # res = [{"a": "foobar", "nested1": {"a": "hellobar"}, "nested2": {"a": 31}}]
539
- # assert_resp_response(client, client.json().get("doc1", "$"), res, [res])
539
+ res = [{"a" : "foobar" , "nested1" : {"a" : "hellobar" }, "nested2" : {"a" : 31 }}]
540
+ assert_resp_response (client , client .json ().get ("doc1" , "$" ), res , [res ])
540
541
541
542
# Test single
542
- client .json ().strappend ("doc1" , "baz" , "$.nested1.a" ) == [11 ]
543
+ assert client .json ().strappend ("doc1" , "baz" , "$.nested1.a" ) == [11 ]
543
544
544
- # res = [{"a": "foobar", "nested1": {"a": "hellobarbaz"}, "nested2": {"a": 31}}]
545
- # assert_resp_response(client, client.json().get("doc1", "$"), res, [res])
545
+ res = [{"a" : "foobar" , "nested1" : {"a" : "hellobarbaz" }, "nested2" : {"a" : 31 }}]
546
+ assert_resp_response (client , client .json ().get ("doc1" , "$" ), res , [res ])
546
547
547
548
# Test missing key
548
549
with pytest .raises (exceptions .ResponseError ):
549
550
client .json ().strappend ("non_existing_doc" , "$..a" , "err" )
550
551
551
552
# Test multi
552
- client .json ().strappend ("doc1" , "bar" , ".*.a" ) == 8
553
- # res = [{"a": "foo ", "nested1": {"a": "hellobar "}, "nested2": {"a": 31}}]
554
- # assert_resp_response(client, client.json().get("doc1", "$"), res, [res])
553
+ assert client .json ().strappend ("doc1" , "bar" , ".*.a" ) == 14
554
+ res = [{"a" : "foobar " , "nested1" : {"a" : "hellobarbazbar " }, "nested2" : {"a" : 31 }}]
555
+ assert_resp_response (client , client .json ().get ("doc1" , "$" ), res , [res ])
555
556
556
557
# Test missing path
557
558
with pytest .raises (exceptions .ResponseError ):
@@ -571,8 +572,8 @@ def test_strlen_dollar(client):
571
572
assert res1 == res2
572
573
573
574
# Test single
574
- client .json ().strlen ("doc1" , "$.nested1.a" ) == [8 ]
575
- client .json ().strlen ("doc1" , "$.nested2.a" ) == [None ]
575
+ assert client .json ().strlen ("doc1" , "$.nested1.a" ) == [8 ]
576
+ assert client .json ().strlen ("doc1" , "$.nested2.a" ) == [None ]
576
577
577
578
# Test missing key
578
579
with pytest .raises (exceptions .ResponseError ):
@@ -591,7 +592,7 @@ def test_arrappend_dollar(client):
591
592
},
592
593
)
593
594
# Test multi
594
- client .json ().arrappend ("doc1" , "$..a" , "bar" , "racuda" ) == [3 , 5 , None ]
595
+ assert client .json ().arrappend ("doc1" , "$..a" , "bar" , "racuda" ) == [3 , 5 , None ]
595
596
res = [
596
597
{
597
598
"a" : ["foo" , "bar" , "racuda" ],
@@ -775,7 +776,7 @@ def test_arrpop_dollar(client):
775
776
},
776
777
)
777
778
# Test multi (all paths are updated, but return result of last path)
778
- client .json ().arrpop ("doc1" , "..a" , "1" ) is None
779
+ assert client .json ().arrpop ("doc1" , "..a" , "1" ) == "null"
779
780
res = [{"a" : [], "nested1" : {"a" : ["hello" , "world" ]}, "nested2" : {"a" : 31 }}]
780
781
assert_resp_response (client , client .json ().get ("doc1" , "$" ), res , [res ])
781
782
0 commit comments