@@ -1882,10 +1882,30 @@ def test_cluster_zunion(self, r):
1882
1882
]
1883
1883
1884
1884
def test_cluster_zunionstore_sum (self , r ):
1885
+ assert r .zunionstore ("{foo}d" , ["{foo}" + str (i ) for i in range (0 , 256 )]) == 0
1886
+
1885
1887
r .zadd ("{foo}a" , {"a1" : 1 , "a2" : 1 , "a3" : 1 })
1886
1888
r .zadd ("{foo}b" , {"a1" : 2 , "a2" : 2 , "a3" : 2 })
1887
1889
r .zadd ("{foo}c" , {"a1" : 6 , "a3" : 5 , "a4" : 4 })
1890
+
1891
+ result_key = "{foo}d"
1892
+ failed_keys = ["{foo1}a" , "{foo}b" , "{foo}c" ]
1893
+ with pytest .raises (
1894
+ RedisClusterException ,
1895
+ match = "ZUNIONSTORE - all keys must map to the same key slot" ,
1896
+ ):
1897
+ r .zunionstore (result_key , failed_keys )
1898
+
1899
+ result_key = "{foo1}d"
1900
+ failed_keys = ["{foo}a" , "{foo}b" ]
1901
+ with pytest .raises (
1902
+ RedisClusterException ,
1903
+ match = "ZUNIONSTORE - all keys must map to the same key slot" ,
1904
+ ):
1905
+ r .zunionstore (result_key , failed_keys )
1906
+
1888
1907
assert r .zunionstore ("{foo}d" , ["{foo}a" , "{foo}b" , "{foo}c" ]) == 4
1908
+ assert r .zunionstore ("{foo}e" , ["{foo}a" ]) == 3
1889
1909
assert r .zrange ("{foo}d" , 0 , - 1 , withscores = True ) == [
1890
1910
(b"a2" , 3 ),
1891
1911
(b"a4" , 4 ),
0 commit comments