@@ -771,3 +771,80 @@ def test_clear(self, cache: RedisCache):
771
771
cache .clear ()
772
772
value_from_cache_after_clear = cache .get ("foo" )
773
773
assert value_from_cache_after_clear is None
774
+
775
+ def test_sadd (self , cache : RedisCache ):
776
+ assert cache .sadd ("foo" , "bar" ) == 1
777
+ assert cache .smembers ("foo" ) == {"bar" }
778
+
779
+ def test_scard (self , cache : RedisCache ):
780
+ cache .sadd ("foo" , "bar" , "bar2" )
781
+ assert cache .scard ("foo" ) == 2
782
+
783
+ def test_sdiff (self , cache : RedisCache ):
784
+ cache .sadd ("foo1" , "bar1" , "bar2" )
785
+ cache .sadd ("foo2" , "bar2" , "bar3" )
786
+ assert cache .sdiff ("foo1" , "foo2" ) == {"bar1" }
787
+
788
+ def test_sdiffstore (self , cache : RedisCache ):
789
+ cache .sadd ("foo1" , "bar1" , "bar2" )
790
+ cache .sadd ("foo2" , "bar2" , "bar3" )
791
+ assert cache .sdiffstore ("foo3" , "foo1" , "foo2" ) == 1
792
+ assert cache .smembers ("foo3" ) == {"bar1" }
793
+
794
+ def test_sinter (self , cache : RedisCache ):
795
+ cache .sadd ("foo1" , "bar1" , "bar2" )
796
+ cache .sadd ("foo2" , "bar2" , "bar3" )
797
+ assert cache .sinter ("foo1" , "foo2" ) == {"bar2" }
798
+
799
+ def test_interstore (self , cache : RedisCache ):
800
+ cache .sadd ("foo1" , "bar1" , "bar2" )
801
+ cache .sadd ("foo2" , "bar2" , "bar3" )
802
+ assert cache .sinterstore ("foo3" , "foo1" , "foo2" ) == 1
803
+ assert cache .smembers ("foo3" ) == {"bar2" }
804
+
805
+ def test_sismember (self , cache : RedisCache ):
806
+ cache .sadd ("foo" , "bar" )
807
+ assert cache .sismember ("foo" , "bar" ) is True
808
+ assert cache .sismember ("foo" , "bar2" ) is False
809
+
810
+ def test_smove (self , cache : RedisCache ):
811
+ cache .sadd ("foo1" , "bar1" , "bar2" )
812
+ cache .sadd ("foo2" , "bar2" , "bar3" )
813
+ assert cache .smove ("foo1" , "foo2" , "bar1" ) is True
814
+ assert cache .smove ("foo1" , "foo2" , "bar4" ) is False
815
+ assert cache .smembers ("foo1" ) == {"bar2" }
816
+ assert cache .smembers ("foo2" ) == {"bar1" , "bar2" , "bar3" }
817
+
818
+ def test_spop_default_count (self , cache : RedisCache ):
819
+ cache .sadd ("foo" , "bar1" , "bar2" )
820
+ assert cache .spop ("foo" ) in {"bar1" , "bar2" }
821
+ assert cache .smembers ("foo" ) in {{"bar1" }, {"bar2" }}
822
+
823
+ def test_spop (self , cache : RedisCache ):
824
+ cache .sadd ("foo" , "bar1" , "bar2" )
825
+ assert cache .spop ("foo" , 1 ) in {{"bar1" }, {"bar2" }}
826
+ assert cache .smembers ("foo" ) in {{"bar1" }, {"bar2" }}
827
+
828
+ def test_srandmember_default_count (self , cache : RedisCache ):
829
+ cache .sadd ("foo" , "bar1" , "bar2" )
830
+ assert cache .srandmember ("foo" ) in {"bar1" , "bar2" }
831
+
832
+ def test_srandmember (self , cache : RedisCache ):
833
+ cache .sadd ("foo" , "bar1" , "bar2" )
834
+ assert cache .srandmember ("foo" , 1 ) in {{"bar1" }, {"bar2" }}
835
+
836
+ def test_srem (self , cache : RedisCache ):
837
+ cache .sadd ("foo" , "bar1" , "bar2" )
838
+ assert cache .srem ("foo" , "bar1" ) == 1
839
+ assert cache .srem ("foo" , "bar3" ) == 0
840
+
841
+ def test_sunion (self , cache : RedisCache ):
842
+ cache .sadd ("foo1" , "bar1" , "bar2" )
843
+ cache .sadd ("foo2" , "bar2" , "bar3" )
844
+ assert cache .sunion ("foo1" , "foo2" ) == {"bar1" , "bar2" , "bar3" }
845
+
846
+ def test_sunionstore (self , cache : RedisCache ):
847
+ cache .sadd ("foo1" , "bar1" , "bar2" )
848
+ cache .sadd ("foo2" , "bar2" , "bar3" )
849
+ assert cache .sunionstore ("foo3" , "foo1" , "foo2" ) == 3
850
+ assert cache .smembers ("foo3" ) == {"bar1" , "bar2" , "bar3" }
0 commit comments