Skip to content

Commit 9e3135f

Browse files
committed
Test FanoutCache timeout tuple for expire_time/tag
1 parent 38ede08 commit 9e3135f

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

‎tests/test_fanout.py‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,34 @@ def test_pop_timeout(cache):
316316
assert cache.pop(0) is None
317317

318318

319+
def test_get_timeout_expire_time(cache):
320+
shards = mock.Mock()
321+
shard = mock.Mock()
322+
get_func = mock.Mock()
323+
324+
shards.__getitem__ = mock.Mock(side_effect=lambda key: shard)
325+
shard.get = get_func
326+
get_func.side_effect = dc.Timeout
327+
328+
with mock.patch.object(cache, '_shards', shards):
329+
assert cache.get(0, expire_time=True) == (None, None)
330+
assert cache.get(0, default=1, expire_time=True, tag=True) == (1, None, None)
331+
332+
333+
def test_pop_timeout_expire_time(cache):
334+
shards = mock.Mock()
335+
shard = mock.Mock()
336+
pop_func = mock.Mock()
337+
338+
shards.__getitem__ = mock.Mock(side_effect=lambda key: shard)
339+
shard.pop = pop_func
340+
pop_func.side_effect = dc.Timeout
341+
342+
with mock.patch.object(cache, '_shards', shards):
343+
assert cache.pop(0, expire_time=True) == (None, None)
344+
assert cache.pop(0, default=1, expire_time=True, tag=True) == (1, None, None)
345+
346+
319347
def test_delete_timeout(cache):
320348
shards = mock.Mock()
321349
shard = mock.Mock()

0 commit comments

Comments
 (0)