Skip to content

Commit

Permalink
test scan
Browse files Browse the repository at this point in the history
  • Loading branch information
amirreza8002 committed Dec 21, 2024
1 parent f77437d commit ac1be3f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,23 @@ def test_iter_keys_generator(self, cache: ValkeyCache):
next_value = next(result)
assert next_value is not None

def test_scan(self, cache: ValkeyCache):
if isinstance(cache.client, ShardClient):
pytest.skip("ShardClient doesn't support scan")

cache.set("foo", "bar")
cursor, result = cache.scan()
assert result == ["foo"]
assert cursor == 0

def test_scan_with_match(self, cache: ValkeyCache):
if isinstance(cache.client, ShardClient):
pytest.skip("ShardClient doesn't support scan")

cache.set("foo", "bar")
_, result = cache.scan(match="f*")
assert result == ["foo"]

def test_primary_replica_switching(self, cache: ValkeyCache):
if isinstance(cache.client, ShardClient):
pytest.skip("ShardClient doesn't support get_client")
Expand Down
11 changes: 11 additions & 0 deletions tests/tests_async/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,17 @@ async def test_primary_replica_switching(self, cache: AsyncValkeyCache):
assert await client.get_client(write=True) == "Foo"
assert await client.get_client(write=False) == "Bar"

async def test_scan(self, cache: AsyncValkeyCache):
await cache.aset("foo", "bar")
cursor, result = await cache.ascan()
assert result == ["foo"]
assert cursor == 0

async def test_scan_with_match(self, cache: AsyncValkeyCache):
await cache.aset("foo", "bar")
_, result = await cache.ascan(match="f*")
assert result == ["foo"]

async def test_primary_replica_switching_with_index(self, cache: AsyncValkeyCache):
# if isinstance(cache.client, ShardClient):
# pytest.skip("ShardClient doesn't support get_client")
Expand Down

0 comments on commit ac1be3f

Please sign in to comment.