@@ -1882,10 +1882,30 @@ def test_cluster_zunion(self, r):
18821882 ]
18831883
18841884 def test_cluster_zunionstore_sum (self , r ):
1885+ assert r .zunionstore ("{foo}d" , ["{foo}" + str (i ) for i in range (0 , 256 )]) == 0
1886+
18851887 r .zadd ("{foo}a" , {"a1" : 1 , "a2" : 1 , "a3" : 1 })
18861888 r .zadd ("{foo}b" , {"a1" : 2 , "a2" : 2 , "a3" : 2 })
18871889 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+
18881907 assert r .zunionstore ("{foo}d" , ["{foo}a" , "{foo}b" , "{foo}c" ]) == 4
1908+ assert r .zunionstore ("{foo}e" , ["{foo}a" ]) == 3
18891909 assert r .zrange ("{foo}d" , 0 , - 1 , withscores = True ) == [
18901910 (b"a2" , 3 ),
18911911 (b"a4" , 4 ),
0 commit comments