From 9381cbc3270725437475cae4da1b1271d438880e Mon Sep 17 00:00:00 2001 From: zhousheng06 Date: Thu, 12 Dec 2024 20:11:29 +0800 Subject: [PATCH] Fix incorrect attribute reuse Adjusting test cases for CacheProxyConnection, cache key should not reuse in different `read_response`. --- tests/test_connection.py | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/tests/test_connection.py b/tests/test_connection.py index a58703e3b5..ff8207d10b 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -468,24 +468,6 @@ def test_read_response_returns_cached_reply(self, mock_cache, mock_connection): status=CacheEntryStatus.IN_PROGRESS, connection_ref=mock_connection, ), - CacheEntry( - cache_key=CacheKey(command="GET", redis_keys=("foo",)), - cache_value=b"bar", - status=CacheEntryStatus.VALID, - connection_ref=mock_connection, - ), - CacheEntry( - cache_key=CacheKey(command="GET", redis_keys=("foo",)), - cache_value=b"bar", - status=CacheEntryStatus.VALID, - connection_ref=mock_connection, - ), - CacheEntry( - cache_key=CacheKey(command="GET", redis_keys=("foo",)), - cache_value=b"bar", - status=CacheEntryStatus.VALID, - connection_ref=mock_connection, - ), ] mock_connection.send_command.return_value = Any mock_connection.read_response.return_value = b"bar" @@ -496,6 +478,7 @@ def test_read_response_returns_cached_reply(self, mock_cache, mock_connection): ) proxy_connection.send_command(*["GET", "foo"], **{"keys": ["foo"]}) assert proxy_connection.read_response() == b"bar" + assert proxy_connection._current_command_cache_key == None assert proxy_connection.read_response() == b"bar" mock_connection.read_response.assert_called_once() @@ -525,9 +508,6 @@ def test_read_response_returns_cached_reply(self, mock_cache, mock_connection): call(CacheKey(command="GET", redis_keys=("foo",))), call(CacheKey(command="GET", redis_keys=("foo",))), call(CacheKey(command="GET", redis_keys=("foo",))), - call(CacheKey(command="GET", redis_keys=("foo",))), - call(CacheKey(command="GET", redis_keys=("foo",))), - call(CacheKey(command="GET", redis_keys=("foo",))), ] )