diff options
author | Richard van der Hoff <richard@matrix.org> | 2020-10-16 12:34:55 +0100 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2020-10-21 15:39:25 +0100 |
commit | 1f4269700c2353263a605856f28ded28501368e1 (patch) | |
tree | 7295f1ee0ca491ff765c7ffbe6290bdc8e49d556 /tests/util/caches/test_deferred_cache.py | |
parent | Combine the two sets of tests for CacheDescriptor (diff) | |
download | synapse-1f4269700c2353263a605856f28ded28501368e1.tar.xz |
Push some deferred wrangling down into DeferredCache
Diffstat (limited to 'tests/util/caches/test_deferred_cache.py')
-rw-r--r-- | tests/util/caches/test_deferred_cache.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/tests/util/caches/test_deferred_cache.py b/tests/util/caches/test_deferred_cache.py index 8a08ab6661..68d26128c1 100644 --- a/tests/util/caches/test_deferred_cache.py +++ b/tests/util/caches/test_deferred_cache.py @@ -13,15 +13,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -import unittest from functools import partial from twisted.internet import defer from synapse.util.caches.deferred_cache import DeferredCache +from tests.unittest import TestCase -class DeferredCacheTestCase(unittest.TestCase): + +class DeferredCacheTestCase(TestCase): def test_empty(self): cache = DeferredCache("test") failed = False @@ -36,7 +37,7 @@ class DeferredCacheTestCase(unittest.TestCase): cache = DeferredCache("test") cache.prefill("foo", 123) - self.assertEquals(cache.get("foo"), 123) + self.assertEquals(self.successResultOf(cache.get("foo")), 123) def test_get_immediate(self): cache = DeferredCache("test") @@ -82,16 +83,15 @@ class DeferredCacheTestCase(unittest.TestCase): d2 = defer.Deferred() cache.set("key2", d2, partial(record_callback, 1)) - # lookup should return observable deferreds - self.assertFalse(cache.get("key1").has_called()) - self.assertFalse(cache.get("key2").has_called()) + # lookup should return pending deferreds + self.assertFalse(cache.get("key1").called) + self.assertFalse(cache.get("key2").called) # let one of the lookups complete d2.callback("result2") - # for now at least, the cache will return real results rather than an - # observabledeferred - self.assertEqual(cache.get("key2"), "result2") + # now the cache will return a completed deferred + self.assertEqual(self.successResultOf(cache.get("key2")), "result2") # now do the invalidation cache.invalidate_all() |