| 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 | 7 |
| 8 from chained_compiled_file_system import ChainedCompiledFileSystem | 8 from chained_compiled_file_system import ChainedCompiledFileSystem |
| 9 from compiled_file_system import CompiledFileSystem | 9 from compiled_file_system import CompiledFileSystem |
| 10 from object_store_creator import ObjectStoreCreator | 10 from object_store_creator import ObjectStoreCreator |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 'a.txt': 'new a.txt', | 21 'a.txt': 'new a.txt', |
| 22 'new.txt': 'a new file', | 22 'new.txt': 'a new file', |
| 23 'dir': { | 23 'dir': { |
| 24 'b.txt': 'new b.txt', | 24 'b.txt': 'new b.txt', |
| 25 'new.txt': 'new file in dir', | 25 'new.txt': 'new file in dir', |
| 26 }, | 26 }, |
| 27 } | 27 } |
| 28 | 28 |
| 29 class ChainedCompiledFileSystemTest(unittest.TestCase): | 29 class ChainedCompiledFileSystemTest(unittest.TestCase): |
| 30 def setUp(self): | 30 def setUp(self): |
| 31 self._object_store_creator = ObjectStoreCreator( | 31 object_store_creator = ObjectStoreCreator(start_empty=False) |
| 32 'chained', start_empty=False) | |
| 33 self._base_object_store_creator = ObjectStoreCreator( | |
| 34 'base', start_empty=False) | |
| 35 base_file_system = TestFileSystem(_TEST_DATA_BASE) | 32 base_file_system = TestFileSystem(_TEST_DATA_BASE) |
| 36 self._base_factory = CompiledFileSystem.Factory( | 33 self._base_factory = CompiledFileSystem.Factory(base_file_system, |
| 37 base_file_system, | 34 object_store_creator) |
| 38 self._base_object_store_creator) | |
| 39 self._file_system = TestFileSystem(_TEST_DATA_NEW) | 35 self._file_system = TestFileSystem(_TEST_DATA_NEW) |
| 40 self._patched_factory = CompiledFileSystem.Factory( | 36 self._patched_factory = CompiledFileSystem.Factory(self._file_system, |
| 41 self._file_system, | 37 object_store_creator) |
| 42 self._object_store_creator) | |
| 43 self._chained_factory = ChainedCompiledFileSystem.Factory( | 38 self._chained_factory = ChainedCompiledFileSystem.Factory( |
| 44 [(self._patched_factory, self._file_system), | 39 [(self._patched_factory, self._file_system), |
| 45 (self._base_factory, base_file_system)]) | 40 (self._base_factory, base_file_system)]) |
| 46 self._base_compiled_fs = self._base_factory.CreateIdentity(TestFileSystem) | 41 self._base_compiled_fs = self._base_factory.CreateIdentity(TestFileSystem) |
| 47 self._chained_compiled_fs = self._chained_factory.CreateIdentity( | 42 self._chained_compiled_fs = self._chained_factory.CreateIdentity( |
| 48 TestFileSystem) | 43 TestFileSystem) |
| 49 | 44 |
| 50 def testGetFromFile(self): | 45 def testGetFromFile(self): |
| 51 self.assertEqual(self._chained_compiled_fs.GetFromFile('a.txt'), | 46 self.assertEqual(self._chained_compiled_fs.GetFromFile('a.txt'), |
| 52 self._base_compiled_fs.GetFromFile('a.txt')) | 47 self._base_compiled_fs.GetFromFile('a.txt')) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 64 self.assertEqual(self._chained_compiled_fs.GetFromFile('dir/'), | 59 self.assertEqual(self._chained_compiled_fs.GetFromFile('dir/'), |
| 65 self._base_compiled_fs.GetFromFile('dir/')) | 60 self._base_compiled_fs.GetFromFile('dir/')) |
| 66 self._file_system.IncrementStat('dir/') | 61 self._file_system.IncrementStat('dir/') |
| 67 self.assertNotEqual(self._chained_compiled_fs.GetFromFileListing('dir/'), | 62 self.assertNotEqual(self._chained_compiled_fs.GetFromFileListing('dir/'), |
| 68 self._base_compiled_fs.GetFromFileListing('dir/')) | 63 self._base_compiled_fs.GetFromFileListing('dir/')) |
| 69 self.assertEqual(self._chained_compiled_fs.GetFromFileListing('dir/'), | 64 self.assertEqual(self._chained_compiled_fs.GetFromFileListing('dir/'), |
| 70 self._file_system.ReadSingle('dir/')) | 65 self._file_system.ReadSingle('dir/')) |
| 71 | 66 |
| 72 if __name__ == '__main__': | 67 if __name__ == '__main__': |
| 73 unittest.main() | 68 unittest.main() |
| OLD | NEW |