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

Side by Side Diff: appengine/findit/util_scripts/test/local_cache_test.py

Issue 2557553002: [Culprit-Finder] Seperate gae related part in cache_decorator and gitile repository to gae_libs/ (Closed)
Patch Set: Fix nits. Created 4 years 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 unified diff | Download patch
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import __builtin__ 5 import __builtin__
6 import mock 6 import mock
7 import os 7 import os
8 import pickle 8 import pickle
9 import zlib 9 import zlib
10 10
11 from testing_utils import testing 11 from testing_utils import testing
12 12
13 import local_cache 13 import local_cache
14 14
15 15
16 class LocalCacheTest(testing.AppengineTestCase): 16 class LocalCacheTest(testing.AppengineTestCase):
17 17
18 def testLocalCacher(self): 18 def testLocalCache(self):
19 fake_dir = 'fake_dir' 19 fake_dir = 'fake_dir'
20 cacher = local_cache.LocalCacher(cache_dir=fake_dir) 20 cacher = local_cache.LocalCache(cache_dir=fake_dir)
21 def _MockPathExists(path, *_): 21 def _MockPathExists(path, *_):
22 return False if path == os.path.join( 22 return False if path == os.path.join(
23 fake_dir, 'uncached_key') else True 23 fake_dir, 'uncached_key') else True
24 self.mock(os.path, 'exists', _MockPathExists) 24 self.mock(os.path, 'exists', _MockPathExists)
25 25
26 value = 'val' 26 value = 'val'
27 with mock.patch('__builtin__.open', mock.mock_open( 27 with mock.patch('__builtin__.open', mock.mock_open(
28 read_data=zlib.compress(pickle.dumps(value)))) as m: 28 read_data=zlib.compress(pickle.dumps(value)))) as m:
29 cacher.Set('a', 'b') 29 cacher.Set('a', 'b')
30 m.assert_called_once_with(os.path.join(fake_dir, 'a'), 'wb') 30 m.assert_called_once_with(os.path.join(fake_dir, 'a'), 'wb')
31 self.assertEqual(value, cacher.Get('key')) 31 self.assertEqual(value, cacher.Get('key'))
32 self.assertIsNone(cacher.Get('uncached_key')) 32 self.assertIsNone(cacher.Get('uncached_key'))
OLDNEW
« no previous file with comments | « appengine/findit/util_scripts/script_util.py ('k') | appengine/findit/waterfall/build_failure_analysis.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698