@@ -428,7 +428,8 @@ def test_clears_cache_on_disconnect(self, mock_connection, cache_conf):
428
428
429
429
cache .set (
430
430
CacheEntry (
431
- cache_key = cache_key , cache_value = b"bar" , status = CacheEntryStatus .VALID
431
+ cache_key = cache_key , cache_value = b"bar" , status = CacheEntryStatus .VALID ,
432
+ connection_ref = mock_connection
432
433
)
433
434
)
434
435
assert cache .get (cache_key ).cache_value == b"bar"
@@ -438,7 +439,7 @@ def test_clears_cache_on_disconnect(self, mock_connection, cache_conf):
438
439
mock_connection .host = "mock"
439
440
mock_connection .port = "mock"
440
441
441
- proxy_connection = CacheProxyConnection (mock_connection , cache )
442
+ proxy_connection = CacheProxyConnection (mock_connection , cache , threading . Lock () )
442
443
proxy_connection .disconnect ()
443
444
444
445
assert len (cache .get_collection ()) == 0
@@ -456,28 +457,32 @@ def test_read_response_returns_cached_reply(self, mock_cache, mock_connection):
456
457
cache_key = CacheKey (command = "GET" , redis_keys = ("foo" ,)),
457
458
cache_value = CacheProxyConnection .DUMMY_CACHE_VALUE ,
458
459
status = CacheEntryStatus .IN_PROGRESS ,
460
+ connection_ref = mock_connection
459
461
),
460
462
CacheEntry (
461
463
cache_key = CacheKey (command = "GET" , redis_keys = ("foo" ,)),
462
464
cache_value = b"bar" ,
463
465
status = CacheEntryStatus .VALID ,
466
+ connection_ref = mock_connection
464
467
),
465
468
CacheEntry (
466
469
cache_key = CacheKey (command = "GET" , redis_keys = ("foo" ,)),
467
470
cache_value = b"bar" ,
468
471
status = CacheEntryStatus .VALID ,
472
+ connection_ref = mock_connection
469
473
),
470
474
CacheEntry (
471
475
cache_key = CacheKey (command = "GET" , redis_keys = ("foo" ,)),
472
476
cache_value = b"bar" ,
473
477
status = CacheEntryStatus .VALID ,
478
+ connection_ref = mock_connection
474
479
),
475
480
]
476
481
mock_connection .send_command .return_value = Any
477
482
mock_connection .read_response .return_value = b"bar"
478
483
mock_connection .can_read .return_value = False
479
484
480
- proxy_connection = CacheProxyConnection (mock_connection , mock_cache )
485
+ proxy_connection = CacheProxyConnection (mock_connection , mock_cache , threading . Lock () )
481
486
proxy_connection .send_command (* ["GET" , "foo" ], ** {"keys" : ["foo" ]})
482
487
assert proxy_connection .read_response () == b"bar"
483
488
assert proxy_connection .read_response () == b"bar"
@@ -490,13 +495,15 @@ def test_read_response_returns_cached_reply(self, mock_cache, mock_connection):
490
495
cache_key = CacheKey (command = "GET" , redis_keys = ("foo" ,)),
491
496
cache_value = CacheProxyConnection .DUMMY_CACHE_VALUE ,
492
497
status = CacheEntryStatus .IN_PROGRESS ,
498
+ connection_ref = mock_connection
493
499
)
494
500
),
495
501
call (
496
502
CacheEntry (
497
503
cache_key = CacheKey (command = "GET" , redis_keys = ("foo" ,)),
498
504
cache_value = b"bar" ,
499
505
status = CacheEntryStatus .VALID ,
506
+ connection_ref = mock_connection
500
507
)
501
508
),
502
509
]
0 commit comments