diff options
author | Paul "LeoNerd" Evans <paul@matrix.org> | 2015-02-23 15:41:54 +0000 |
---|---|---|
committer | Paul "LeoNerd" Evans <paul@matrix.org> | 2015-02-23 15:41:54 +0000 |
commit | e76d485e29498fce7412423e7a5b6ac6bc287ec3 (patch) | |
tree | 75bd25cbe34139c3cfbcc2d9790291e38d5a2d73 /tests/storage | |
parent | Squash out the now-redundant ApplicationServicesCache object class (diff) | |
download | synapse-e76d485e29498fce7412423e7a5b6ac6bc287ec3.tar.xz |
Allow @cached-wrapped functions to have a prefill method for setting entries
Diffstat (limited to 'tests/storage')
-rw-r--r-- | tests/storage/test__base.py | 14 |
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) |