Andriy Kornatskyy avatar Andriy Kornatskyy committed a7c6d1d

Added cache pattern test case for get or set multi if data result is not available but there are some items cached.

Comments (0)

Files changed (1)


             {'k1': 'a'}, 10, '', 'ns')
+    def test_some_cache_miss_create_factory_no_result(self):
+        """ Some items are missed in cache and factory returns
+            no results.
+        """
+        from wheezy.caching.patterns import Cached
+        mk = lambda i: 'k%d' % i
+        cached = Cached(self.mock_cache, time=10, namespace='ns')
+        self.mock_cache.get_multi.return_value = {'k2': 'b'}
+        self.mock_create_factory.return_value = {}
+        r = cached.get_or_set_multi(
+            mk, self.mock_create_factory, [1, 2])
+        assert [(2, 'b')] == r.items()
+        self.mock_create_factory.assert_called_once_with([1])
+        assert not self.mock_cache.set_multi.called
 class WrapsGetOrSetMultiTestCase(GetOrSetMultiTestCase):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.