| 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 from copy import deepcopy | 6 from copy import deepcopy |
| 7 import unittest | 7 import unittest |
| 8 | 8 |
| 9 from extensions_paths import API | 9 from extensions_paths import CHROME_API |
| 10 from file_system import FileNotFoundError | 10 from file_system import FileNotFoundError |
| 11 from host_file_system_provider import HostFileSystemProvider | 11 from host_file_system_provider import HostFileSystemProvider |
| 12 from object_store_creator import ObjectStoreCreator | 12 from object_store_creator import ObjectStoreCreator |
| 13 from test_data.canned_data import CANNED_API_FILE_SYSTEM_DATA | 13 from test_data.canned_data import CANNED_API_FILE_SYSTEM_DATA |
| 14 from test_file_system import TestFileSystem | 14 from test_file_system import TestFileSystem |
| 15 | 15 |
| 16 class HostFileSystemProviderTest(unittest.TestCase): | 16 class HostFileSystemProviderTest(unittest.TestCase): |
| 17 def setUp(self): | 17 def setUp(self): |
| 18 self._idle_path = API + 'idle.json' | 18 self._idle_path = CHROME_API + 'idle.json' |
| 19 self._canned_data = deepcopy(CANNED_API_FILE_SYSTEM_DATA) | 19 self._canned_data = deepcopy(CANNED_API_FILE_SYSTEM_DATA) |
| 20 | 20 |
| 21 def _constructor_for_test(self, branch, **optargs): | 21 def _constructor_for_test(self, branch, **optargs): |
| 22 return TestFileSystem(self._canned_data[branch]) | 22 return TestFileSystem(self._canned_data[branch]) |
| 23 | 23 |
| 24 def testWithCaching(self): | 24 def testWithCaching(self): |
| 25 creator = HostFileSystemProvider( | 25 creator = HostFileSystemProvider( |
| 26 ObjectStoreCreator.ForTest(), | 26 ObjectStoreCreator.ForTest(), |
| 27 constructor_for_test=self._constructor_for_test) | 27 constructor_for_test=self._constructor_for_test) |
| 28 | 28 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 39 ObjectStoreCreator.ForTest(), | 39 ObjectStoreCreator.ForTest(), |
| 40 offline=True, | 40 offline=True, |
| 41 constructor_for_test=self._constructor_for_test) | 41 constructor_for_test=self._constructor_for_test) |
| 42 | 42 |
| 43 fs = creator.GetBranch('1500') | 43 fs = creator.GetBranch('1500') |
| 44 # Offline file system should raise a FileNotFoundError if read is attempted. | 44 # Offline file system should raise a FileNotFoundError if read is attempted. |
| 45 self.assertRaises(FileNotFoundError, fs.ReadSingle(self._idle_path).Get) | 45 self.assertRaises(FileNotFoundError, fs.ReadSingle(self._idle_path).Get) |
| 46 | 46 |
| 47 if __name__ == '__main__': | 47 if __name__ == '__main__': |
| 48 unittest.main() | 48 unittest.main() |
| OLD | NEW |