Skip to content

Commit

Permalink
Fix incorrect attribute reuse
Browse files Browse the repository at this point in the history
Adjusting test cases for CacheProxyConnection, cache key should not reuse in different `read_response`.
  • Loading branch information
zhousheng06 committed Dec 16, 2024
1 parent 1423037 commit 9381cbc
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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()
Expand Down Expand Up @@ -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",))),
]
)

Expand Down

0 comments on commit 9381cbc

Please sign in to comment.