Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2588)

Unified Diff: appengine/findit/common/test/cache_decorator_test.py

Issue 2456603003: [Predator] Add local cache for get command output. (Closed)
Patch Set: . Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: appengine/findit/common/test/cache_decorator_test.py
diff --git a/appengine/findit/common/test/cache_decorator_test.py b/appengine/findit/common/test/cache_decorator_test.py
index a3a2fd467c7e0b29790a484bd2e45b31d958614c..092507caef14607863288cfe040bd0f1eed46236 100644
--- a/appengine/findit/common/test/cache_decorator_test.py
+++ b/appengine/findit/common/test/cache_decorator_test.py
@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import os
import pickle
import zlib
@@ -11,6 +12,8 @@ from testing_utils import testing
from common import cache_decorator
+_LOCAL_CACHE_TEST_DIR = os.path.join(os.path.expanduser('~'), '.test_cache')
Martin Barbella 2016/10/26 23:21:20 Could you use https://pypi.python.org/pypi/pyfakef
Sharu Jiang 2016/10/27 21:59:05 The pyfakefs is third_party libs, use mock instead
+
class _DummyCacher(cache_decorator.Cacher):
def __init__(self, cached_data):
@@ -162,3 +165,11 @@ class CacheDecoratorTest(testing.AppengineTestCase):
a2 = A('http://test', 5)
self.assertEqual('http://test/p1', a2.Func('p1'))
self.assertEqual(0, a2.runs)
+
+ def testLocalCacher(self):
+ cacher = cache_decorator.LocalCacher(cache_dir=_LOCAL_CACHE_TEST_DIR)
+ cacher.Set('a', 'b')
+ self.assertEqual('b', cacher.Get('a'))
+ cacher.Set('c', 'd')
+ self.assertEqual('d', cacher.Get('c'))
+ self.assertIsNone(cacher.Get('uncached_key'))

Powered by Google App Engine
This is Rietveld 408576698