OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import unittest | 6 import unittest |
7 from caching_rietveld_patcher import (CachingRietveldPatcher, | 7 from caching_rietveld_patcher import (CachingRietveldPatcher, |
8 _VERSION_CACHE_MAXAGE) | 8 _VERSION_CACHE_MAXAGE) |
9 from datetime import datetime | 9 from datetime import datetime |
10 from file_system import FileNotFoundError | 10 from file_system import FileNotFoundError |
(...skipping 19 matching lines...) Expand all Loading... |
30 class CachingRietveldPatcherTest(unittest.TestCase): | 30 class CachingRietveldPatcherTest(unittest.TestCase): |
31 def setUp(self): | 31 def setUp(self): |
32 self._datetime = FakeDateTime() | 32 self._datetime = FakeDateTime() |
33 # CachingRietveldPatcher should always call Apply with binary=True. | 33 # CachingRietveldPatcher should always call Apply with binary=True. |
34 self._test_patcher = TestPatcher(_TEST_PATCH_VERSION, | 34 self._test_patcher = TestPatcher(_TEST_PATCH_VERSION, |
35 _TEST_PATCH_FILES, | 35 _TEST_PATCH_FILES, |
36 _TEST_PATCH_DATA, | 36 _TEST_PATCH_DATA, |
37 assert_binary=True) | 37 assert_binary=True) |
38 self._patcher = CachingRietveldPatcher( | 38 self._patcher = CachingRietveldPatcher( |
39 self._test_patcher, | 39 self._test_patcher, |
40 ObjectStoreCreator('test', start_empty=False), | 40 ObjectStoreCreator(start_empty=False), |
41 self._datetime) | 41 self._datetime) |
42 | 42 |
43 def testGetVersion(self): | 43 def testGetVersion(self): |
44 # Invalidate cache. | 44 # Invalidate cache. |
45 self._datetime.time += _VERSION_CACHE_MAXAGE | 45 self._datetime.time += _VERSION_CACHE_MAXAGE |
46 # Fill cache. | 46 # Fill cache. |
47 self._patcher.GetVersion() | 47 self._patcher.GetVersion() |
48 count = self._test_patcher.get_version_count | 48 count = self._test_patcher.get_version_count |
49 # Should read from cache. | 49 # Should read from cache. |
50 self._patcher.GetVersion() | 50 self._patcher.GetVersion() |
(...skipping 23 matching lines...) Expand all Loading... |
74 # Make sure RietveldPatcher handles |binary| correctly. | 74 # Make sure RietveldPatcher handles |binary| correctly. |
75 self.assertTrue(isinstance(self._patcher.Apply(['add.txt'], None, True). | 75 self.assertTrue(isinstance(self._patcher.Apply(['add.txt'], None, True). |
76 Get()['add.txt'], str), | 76 Get()['add.txt'], str), |
77 'Expected result is binary. It was text.') | 77 'Expected result is binary. It was text.') |
78 self.assertTrue(isinstance(self._patcher.Apply(['add.txt'], None). | 78 self.assertTrue(isinstance(self._patcher.Apply(['add.txt'], None). |
79 Get()['add.txt'], unicode), | 79 Get()['add.txt'], unicode), |
80 'Expected result is text. It was binary.') | 80 'Expected result is text. It was binary.') |
81 | 81 |
82 if __name__ == '__main__': | 82 if __name__ == '__main__': |
83 unittest.main() | 83 unittest.main() |
OLD | NEW |