summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-08-06 13:33:34 +0100
committerErik Johnston <erik@matrix.org>2015-08-06 13:33:34 +0100
commit7eea3e356ff58168f3525879a8eb684f0681ee68 (patch)
tree1b358647cced4da2e17e631715bbc85c5f39e735 /tests
parentAdd support for using keyword arguments with cached functions (diff)
downloadsynapse-7eea3e356ff58168f3525879a8eb684f0681ee68.tar.xz
Make @cached cache deferreds rather than the deferreds' values
Diffstat (limited to 'tests')
-rw-r--r--tests/storage/test__base.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/tests/storage/test__base.py b/tests/storage/test__base.py
index 8c3d2952bd..8fa305d18a 100644
--- a/tests/storage/test__base.py
+++ b/tests/storage/test__base.py
@@ -17,6 +17,8 @@
 from tests import unittest
 from twisted.internet import defer
 
+from synapse.util.async import ObservableDeferred
+
 from synapse.storage._base import Cache, cached
 
 
@@ -178,19 +180,20 @@ class CacheDecoratorTestCase(unittest.TestCase):
         self.assertTrue(callcount[0] >= 14,
             msg="Expected callcount >= 14, got %d" % (callcount[0]))
 
-    @defer.inlineCallbacks
     def test_prefill(self):
         callcount = [0]
 
+        d = defer.succeed(123)
+
         class A(object):
             @cached()
             def func(self, key):
                 callcount[0] += 1
-                return key
+                return d
 
         a = A()
 
-        a.func.prefill("foo", 123)
+        a.func.prefill("foo", ObservableDeferred(d))
 
-        self.assertEquals((yield a.func("foo")), 123)
+        self.assertEquals(a.func("foo").result, d.result)
         self.assertEquals(callcount[0], 0)