Skip to content

Commit

Permalink
test hdel_many
Browse files Browse the repository at this point in the history
  • Loading branch information
amirreza8002 committed Dec 12, 2024
1 parent 67f7402 commit ae43fca
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,18 @@ def test_hdel(self, cache: ValkeyCache):
assert not cache.hexists("foo_hash2", "foo1")
assert cache.hexists("foo_hash2", "foo2")

def test_hdel_many(self, cache: ValkeyCache):
if isinstance(cache.client, ShardClient):
pytest.skip("ShardClient doesn't support get_client")
cache.hset("foo_hash3", "foo1", "bar1")
cache.hset("foo_hash3", "foo2", "bar2")
assert cache.hlen("foo_hash3") == 2
deleted_count = cache.hdel_many("foo_hash3", ["foo1", "foo2"])
assert deleted_count == 2
assert cache.hlen("foo_hash3") == 0
assert not cache.hexists("foo_hash3", "foo1")
assert not cache.hexists("foo_hash3", "foo2")

def test_hlen(self, cache: ValkeyCache):
if isinstance(cache.client, ShardClient):
pytest.skip("ShardClient doesn't support get_client")
Expand Down
10 changes: 10 additions & 0 deletions tests/tests_async/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,16 @@ async def test_hdel(self, cache: AsyncValkeyCache):
assert not await cache.ahexists("foo_hash2", "foo1")
assert await cache.ahexists("foo_hash2", "foo2")

async def test_hdel_many(self, cache: AsyncValkeyCache):
await cache.ahset("foo_hash3", "foo1", "bar1")
await cache.ahset("foo_hash3", "foo2", "bar2")
assert await cache.ahlen("foo_hash3") == 2
deleted_count = await cache.ahdel_many("foo_hash3", ["foo1", "foo2"])
assert deleted_count == 2
assert await cache.ahlen("foo_hash3") == 0
assert not await cache.ahexists("foo_hash3", "foo1")
assert not await cache.ahexists("foo_hash3", "foo2")

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

0 comments on commit ae43fca

Please sign in to comment.