Skip to content

Commit 9381cbc

Browse files
author
zhousheng06
committed
Fix incorrect attribute reuse
Adjusting test cases for CacheProxyConnection, cache key should not reuse in different `read_response`.
1 parent 1423037 commit 9381cbc

File tree

1 file changed

+1
-21
lines changed

1 file changed

+1
-21
lines changed

tests/test_connection.py

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -468,24 +468,6 @@ def test_read_response_returns_cached_reply(self, mock_cache, mock_connection):
468468
status=CacheEntryStatus.IN_PROGRESS,
469469
connection_ref=mock_connection,
470470
),
471-
CacheEntry(
472-
cache_key=CacheKey(command="GET", redis_keys=("foo",)),
473-
cache_value=b"bar",
474-
status=CacheEntryStatus.VALID,
475-
connection_ref=mock_connection,
476-
),
477-
CacheEntry(
478-
cache_key=CacheKey(command="GET", redis_keys=("foo",)),
479-
cache_value=b"bar",
480-
status=CacheEntryStatus.VALID,
481-
connection_ref=mock_connection,
482-
),
483-
CacheEntry(
484-
cache_key=CacheKey(command="GET", redis_keys=("foo",)),
485-
cache_value=b"bar",
486-
status=CacheEntryStatus.VALID,
487-
connection_ref=mock_connection,
488-
),
489471
]
490472
mock_connection.send_command.return_value = Any
491473
mock_connection.read_response.return_value = b"bar"
@@ -496,6 +478,7 @@ def test_read_response_returns_cached_reply(self, mock_cache, mock_connection):
496478
)
497479
proxy_connection.send_command(*["GET", "foo"], **{"keys": ["foo"]})
498480
assert proxy_connection.read_response() == b"bar"
481+
assert proxy_connection._current_command_cache_key == None
499482
assert proxy_connection.read_response() == b"bar"
500483

501484
mock_connection.read_response.assert_called_once()
@@ -525,9 +508,6 @@ def test_read_response_returns_cached_reply(self, mock_cache, mock_connection):
525508
call(CacheKey(command="GET", redis_keys=("foo",))),
526509
call(CacheKey(command="GET", redis_keys=("foo",))),
527510
call(CacheKey(command="GET", redis_keys=("foo",))),
528-
call(CacheKey(command="GET", redis_keys=("foo",))),
529-
call(CacheKey(command="GET", redis_keys=("foo",))),
530-
call(CacheKey(command="GET", redis_keys=("foo",))),
531511
]
532512
)
533513

0 commit comments

Comments
 (0)