OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 os | 6 import os |
7 import sys | 7 import sys |
8 import unittest | 8 import unittest |
9 | 9 |
10 from caching_file_system import CachingFileSystem | 10 from caching_file_system import CachingFileSystem |
(...skipping 19 matching lines...) Expand all Loading... |
30 def store_type_constructor(namespace, start_empty=False): | 30 def store_type_constructor(namespace, start_empty=False): |
31 '''Returns an ObjectStore backed onto test-lifetime-persistent objects | 31 '''Returns an ObjectStore backed onto test-lifetime-persistent objects |
32 in |_object_store_dbs|. | 32 in |_object_store_dbs|. |
33 ''' | 33 ''' |
34 if namespace not in self._object_store_dbs: | 34 if namespace not in self._object_store_dbs: |
35 self._object_store_dbs[namespace] = {} | 35 self._object_store_dbs[namespace] = {} |
36 db = self._object_store_dbs[namespace] | 36 db = self._object_store_dbs[namespace] |
37 if start_empty: | 37 if start_empty: |
38 db.clear() | 38 db.clear() |
39 return TestObjectStore(namespace, init=db) | 39 return TestObjectStore(namespace, init=db) |
40 object_store_creator = ObjectStoreCreator('test', | 40 object_store_creator = ObjectStoreCreator(start_empty=start_empty, |
41 start_empty=start_empty, | |
42 store_type=store_type_constructor) | 41 store_type=store_type_constructor) |
43 return CachingFileSystem(fs, object_store_creator) | 42 return CachingFileSystem(fs, object_store_creator) |
44 | 43 |
45 def testReadFiles(self): | 44 def testReadFiles(self): |
46 file_system = self._CreateCachingFileSystem( | 45 file_system = self._CreateCachingFileSystem( |
47 _CreateLocalFs(), start_empty=False) | 46 _CreateLocalFs(), start_empty=False) |
48 expected = { | 47 expected = { |
49 './test1.txt': 'test1\n', | 48 './test1.txt': 'test1\n', |
50 './test2.txt': 'test2\n', | 49 './test2.txt': 'test2\n', |
51 './test3.txt': 'test3\n', | 50 './test3.txt': 'test3\n', |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 self.assertTrue(*mock_fs.CheckAndReset()) | 190 self.assertTrue(*mock_fs.CheckAndReset()) |
192 run() | 191 run() |
193 run() | 192 run() |
194 | 193 |
195 run_expecting_stat('0') | 194 run_expecting_stat('0') |
196 test_fs.IncrementStat() | 195 test_fs.IncrementStat() |
197 run_expecting_stat('1') | 196 run_expecting_stat('1') |
198 | 197 |
199 if __name__ == '__main__': | 198 if __name__ == '__main__': |
200 unittest.main() | 199 unittest.main() |
OLD | NEW |