From e2b2decd1177654867f46cdb11529fbb1f5a4f30 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 2 Apr 2021 11:28:51 +0100 Subject: Fix --- tests/util/test_lrucache.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests/util/test_lrucache.py') diff --git a/tests/util/test_lrucache.py b/tests/util/test_lrucache.py index a739a6aaaf..dd8c46ee49 100644 --- a/tests/util/test_lrucache.py +++ b/tests/util/test_lrucache.py @@ -30,6 +30,23 @@ class LruCacheTestCase(unittest.HomeserverTestCase): self.assertEquals(cache.get("key"), "value") self.assertEquals(cache["key"], "value") + def test_time_evict(self): + self.reactor.advance(100 * 60) + + cache = LruCache(100, reactor=self.reactor) + cache["key"] = "value" + cache["key2"] = "value2" + + cache._on_resize() + self.assertEquals(cache.get("key"), "value") + + self.reactor.advance(20 * 60) + + print(self.reactor.seconds()) + + cache._on_resize() + self.assertEquals(cache.get("key"), None) + def test_eviction(self): cache = LruCache(2) cache[1] = 1 -- cgit 1.4.1