Skip to content

Commit 08e04c5

Browse files
committed
adjust tests with new shard logic
(cherry picked from commit 4df4565)
1 parent 772b417 commit 08e04c5

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

tests/test_backend.py

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def test_set_int(self, cache: ValkeyCache):
4040
if not isinstance(cache.client, ShardClient):
4141
raw_client = cache.client._get_client(write=False, client=None)
4242
else:
43-
raw_client = cache.client.get_server(":1:test_key")
43+
raw_client = cache.client._get_client(key=":1:test_key")
4444
assert raw_client.get(":1:test_key") == b"1"
4545

4646
def test_set_float(self, cache: ValkeyCache):
@@ -52,7 +52,7 @@ def test_set_float(self, cache: ValkeyCache):
5252
if not isinstance(cache.client, ShardClient):
5353
raw_client = cache.client._get_client(write=False, client=None)
5454
else:
55-
raw_client = cache.client.get_server(":1:test_key2")
55+
raw_client = cache.client._get_client(key=":1:test_key2")
5656
assert raw_client.get(":1:test_key2") == b"1.1"
5757

5858
def test_setnx(self, cache: ValkeyCache):
@@ -766,8 +766,7 @@ def test_iter_keys_generator(self, cache: ValkeyCache):
766766

767767
def test_primary_replica_switching(self, cache: ValkeyCache):
768768
if isinstance(cache.client, ShardClient):
769-
pytest.skip("ShardClient doesn't support get_client")
770-
769+
pytest.skip("shard client handles connections differently")
771770
cache = cast(ValkeyCache, caches["sample"])
772771
client = cache.client
773772
client._server = ["foo", "bar"]
@@ -842,7 +841,7 @@ def test_clear(self, cache: ValkeyCache):
842841

843842
def test_hset(self, cache: ValkeyCache):
844843
if isinstance(cache.client, ShardClient):
845-
pytest.skip("ShardClient doesn't support get_client")
844+
pytest.skip("ShardClient doesn't support hash operations")
846845
cache.hset("foo_hash1", "foo1", "bar1")
847846
cache.hset("foo_hash1", "foo2", "bar2")
848847
assert cache.hlen("foo_hash1") == 2
@@ -851,7 +850,7 @@ def test_hset(self, cache: ValkeyCache):
851850

852851
def test_hdel(self, cache: ValkeyCache):
853852
if isinstance(cache.client, ShardClient):
854-
pytest.skip("ShardClient doesn't support get_client")
853+
pytest.skip("ShardClient doesn't support hash operations")
855854
cache.hset("foo_hash2", "foo1", "bar1")
856855
cache.hset("foo_hash2", "foo2", "bar2")
857856
assert cache.hlen("foo_hash2") == 2
@@ -863,7 +862,7 @@ def test_hdel(self, cache: ValkeyCache):
863862

864863
def test_hlen(self, cache: ValkeyCache):
865864
if isinstance(cache.client, ShardClient):
866-
pytest.skip("ShardClient doesn't support get_client")
865+
pytest.skip("ShardClient doesn't support hash operations")
867866
assert cache.hlen("foo_hash3") == 0
868867
cache.hset("foo_hash3", "foo1", "bar1")
869868
assert cache.hlen("foo_hash3") == 1
@@ -872,7 +871,7 @@ def test_hlen(self, cache: ValkeyCache):
872871

873872
def test_hkeys(self, cache: ValkeyCache):
874873
if isinstance(cache.client, ShardClient):
875-
pytest.skip("ShardClient doesn't support get_client")
874+
pytest.skip("ShardClient doesn't support hash operations")
876875
cache.hset("foo_hash4", "foo1", "bar1")
877876
cache.hset("foo_hash4", "foo2", "bar2")
878877
cache.hset("foo_hash4", "foo3", "bar3")
@@ -883,7 +882,7 @@ def test_hkeys(self, cache: ValkeyCache):
883882

884883
def test_hexists(self, cache: ValkeyCache):
885884
if isinstance(cache.client, ShardClient):
886-
pytest.skip("ShardClient doesn't support get_client")
885+
pytest.skip("ShardClient doesn't support hash operations")
887886
cache.hset("foo_hash5", "foo1", "bar1")
888887
assert cache.hexists("foo_hash5", "foo1")
889888
assert not cache.hexists("foo_hash5", "foo")
@@ -898,7 +897,7 @@ def test_sadd_int(self, cache: ValkeyCache):
898897
if not isinstance(cache.client, ShardClient):
899898
raw_client = cache.client._get_client(write=False, client=None)
900899
else:
901-
raw_client = cache.client.get_server(":1:foo")
900+
raw_client = cache.client._get_client(key=":1:foo")
902901
assert raw_client.smembers(":1:foo") == [b"1"]
903902

904903
def test_sadd_float(self, cache: ValkeyCache):
@@ -907,7 +906,7 @@ def test_sadd_float(self, cache: ValkeyCache):
907906
if not isinstance(cache.client, ShardClient):
908907
raw_client = cache.client._get_client(write=False, client=None)
909908
else:
910-
raw_client = cache.client.get_server(":1:foo")
909+
raw_client = cache.client._get_client(key=":1:foo")
911910
assert raw_client.smembers(":1:foo") == [b"1.2"]
912911

913912
def test_scard(self, cache: ValkeyCache):
@@ -916,15 +915,15 @@ def test_scard(self, cache: ValkeyCache):
916915

917916
def test_sdiff(self, cache: ValkeyCache):
918917
if isinstance(cache.client, ShardClient):
919-
pytest.skip("ShardClient doesn't support get_client")
918+
pytest.skip("ShardClient doesn't support sdiff")
920919

921920
cache.sadd("foo1", "bar1", "bar2")
922921
cache.sadd("foo2", "bar2", "bar3")
923922
assert cache.sdiff("foo1", "foo2") == {"bar1"}
924923

925924
def test_sdiffstore(self, cache: ValkeyCache):
926925
if isinstance(cache.client, ShardClient):
927-
pytest.skip("ShardClient doesn't support get_client")
926+
pytest.skip("ShardClient doesn't support sdiffstore")
928927

929928
cache.sadd("foo1", "bar1", "bar2")
930929
cache.sadd("foo2", "bar2", "bar3")
@@ -933,7 +932,7 @@ def test_sdiffstore(self, cache: ValkeyCache):
933932

934933
def test_sdiffstore_with_keys_version(self, cache: ValkeyCache):
935934
if isinstance(cache.client, ShardClient):
936-
pytest.skip("ShardClient doesn't support get_client")
935+
pytest.skip("ShardClient doesn't support sdiffstore")
937936

938937
cache.sadd("foo1", "bar1", "bar2", version=2)
939938
cache.sadd("foo2", "bar2", "bar3", version=2)
@@ -944,7 +943,7 @@ def test_sdiffstore_with_different_keys_versions_without_initial_set_in_version(
944943
self, cache: ValkeyCache
945944
):
946945
if isinstance(cache.client, ShardClient):
947-
pytest.skip("ShardClient doesn't support get_client")
946+
pytest.skip("ShardClient doesn't support sdiffstore")
948947

949948
cache.sadd("foo1", "bar1", "bar2", version=1)
950949
cache.sadd("foo2", "bar2", "bar3", version=2)
@@ -954,23 +953,23 @@ def test_sdiffstore_with_different_keys_versions_with_initial_set_in_version(
954953
self, cache: ValkeyCache
955954
):
956955
if isinstance(cache.client, ShardClient):
957-
pytest.skip("ShardClient doesn't support get_client")
956+
pytest.skip("ShardClient doesn't support sdiffstore")
958957

959958
cache.sadd("foo1", "bar1", "bar2", version=2)
960959
cache.sadd("foo2", "bar2", "bar3", version=1)
961960
assert cache.sdiffstore("foo3", "foo1", "foo2", version_keys=2) == 2
962961

963962
def test_sinter(self, cache: ValkeyCache):
964963
if isinstance(cache.client, ShardClient):
965-
pytest.skip("ShardClient doesn't support get_client")
964+
pytest.skip("ShardClient doesn't support sinter")
966965

967966
cache.sadd("foo1", "bar1", "bar2")
968967
cache.sadd("foo2", "bar2", "bar3")
969968
assert cache.sinter("foo1", "foo2") == {"bar2"}
970969

971970
def test_interstore(self, cache: ValkeyCache):
972971
if isinstance(cache.client, ShardClient):
973-
pytest.skip("ShardClient doesn't support get_client")
972+
pytest.skip("ShardClient doesn't support sinterstore")
974973

975974
cache.sadd("foo1", "bar1", "bar2")
976975
cache.sadd("foo2", "bar2", "bar3")
@@ -1063,8 +1062,8 @@ def test_sismember_bool(self, cache: ValkeyCache):
10631062
assert cache.sismember("foo", False) is False
10641063

10651064
def test_smove(self, cache: ValkeyCache):
1066-
if isinstance(cache.client, ShardClient):
1067-
pytest.skip("ShardClient doesn't support get_client")
1065+
# if isinstance(cache.client, ShardClient):
1066+
# pytest.skip("ShardClient doesn't support get_client")
10681067

10691068
cache.sadd("foo1", "bar1", "bar2")
10701069
cache.sadd("foo2", "bar2", "bar3")
@@ -1128,15 +1127,15 @@ def test_smismember(self, cache: ValkeyCache):
11281127

11291128
def test_sunion(self, cache: ValkeyCache):
11301129
if isinstance(cache.client, ShardClient):
1131-
pytest.skip("ShardClient doesn't support get_client")
1130+
pytest.skip("ShardClient doesn't support sunion")
11321131

11331132
cache.sadd("foo1", "bar1", "bar2")
11341133
cache.sadd("foo2", "bar2", "bar3")
11351134
assert cache.sunion("foo1", "foo2") == {"bar1", "bar2", "bar3"}
11361135

11371136
def test_sunionstore(self, cache: ValkeyCache):
11381137
if isinstance(cache.client, ShardClient):
1139-
pytest.skip("ShardClient doesn't support get_client")
1138+
pytest.skip("ShardClient doesn't support sunionstore")
11401139

11411140
cache.sadd("foo1", "bar1", "bar2")
11421141
cache.sadd("foo2", "bar2", "bar3")

0 commit comments

Comments
 (0)