summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2015-02-23 15:41:54 +0000
committerPaul "LeoNerd" Evans <paul@matrix.org>2015-02-23 15:41:54 +0000
commite76d485e29498fce7412423e7a5b6ac6bc287ec3 (patch)
tree75bd25cbe34139c3cfbcc2d9790291e38d5a2d73 /tests
parentSquash out the now-redundant ApplicationServicesCache object class (diff)
downloadsynapse-e76d485e29498fce7412423e7a5b6ac6bc287ec3.tar.xz
Allow @cached-wrapped functions to have a prefill method for setting entries
Diffstat (limited to 'tests')
-rw-r--r--tests/storage/test__base.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/storage/test__base.py b/tests/storage/test__base.py
index 057f798640..fb306cb784 100644
--- a/tests/storage/test__base.py
+++ b/tests/storage/test__base.py
@@ -87,3 +87,17 @@ 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]
+
+        @cached()
+        def func(self, key):
+            callcount[0] += 1
+            return key
+
+        func.prefill("foo", 123)
+
+        self.assertEquals((yield func(self, "foo")), 123)
+        self.assertEquals(callcount[0], 0)