From f61f3f9d7b8c577e3a6055bf198798fb4882fbd8 Mon Sep 17 00:00:00 2001 From: amirreza Date: Tue, 17 Dec 2024 13:48:49 +0330 Subject: [PATCH] test hincrbyfloat --- tests/test_backend.py | 10 ++++++++++ tests/tests_async/test_backend.py | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/tests/test_backend.py b/tests/test_backend.py index bc5325b..965decb 100644 --- a/tests/test_backend.py +++ b/tests/test_backend.py @@ -938,6 +938,16 @@ def test_hincrby(self, cache: ValkeyCache): assert cache.hget("foo_hash1", "foo1") == 3 assert result == 3 + def test_hincrbyfloat(self, cache: ValkeyCache): + if isinstance(cache.client, ShardClient): + pytest.skip("ShardClient doesn't support get_client") + + cache.hset("foo_hash1", "foo1", 1.0) + assert cache.hget("foo_hash1", "foo1") == 1.0 + result = cache.hincrbyfloat("foo_hash1", "foo1", amount=2.2) + assert cache.hget("foo_hash1", "foo1") == 3.2 + assert result == 3.2 + def test_hlen(self, cache: ValkeyCache): if isinstance(cache.client, ShardClient): pytest.skip("ShardClient doesn't support get_client") diff --git a/tests/tests_async/test_backend.py b/tests/tests_async/test_backend.py index 63dec8d..41523aa 100644 --- a/tests/tests_async/test_backend.py +++ b/tests/tests_async/test_backend.py @@ -942,6 +942,13 @@ async def test_hincrby(self, cache: AsyncValkeyCache): assert await cache.ahget("foo_hash1", "foo1") == 3 assert result == 3 + async def test_hincrbyfloat(self, cache: AsyncValkeyCache): + await cache.ahset("foo_hash1", "foo1", 1.0) + assert await cache.ahget("foo_hash1", "foo1") == 1.0 + result = await cache.ahincrbyfloat("foo_hash1", "foo1", amount=2.2) + assert await cache.ahget("foo_hash1", "foo1") == 3.2 + assert result == 3.2 + async def test_hlen(self, cache: AsyncValkeyCache): # if isinstance(cache.client, ShardClient): # pytest.skip("ShardClient doesn't support get_client")