Chromium Code Reviews| Index: chrome/common/extensions/docs/server2/chained_compiled_file_system_test.py |
| =================================================================== |
| --- chrome/common/extensions/docs/server2/chained_compiled_file_system_test.py (revision 0) |
| +++ chrome/common/extensions/docs/server2/chained_compiled_file_system_test.py (revision 0) |
| @@ -0,0 +1,70 @@ |
| +#!/usr/bin/env python |
| +# Copyright 2013 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +import unittest |
| + |
| +from chained_compiled_file_system import ChainedCompiledFileSystem |
| +from compiled_file_system import CompiledFileSystem |
| +from object_store_creator import ObjectStoreCreator |
| +from test_file_system import TestFileSystem |
| + |
| +_TEST_DATA_BASE = { |
| + 'a.txt': 'base a.txt', |
| + 'dir': { |
| + 'b.txt': 'base b.txt' |
| + }, |
| +} |
| + |
| +_TEST_DATA_NEW = { |
| + 'a.txt': 'new a.txt', |
| + 'new.txt': 'a new file', |
| + 'dir': { |
| + 'b.txt': 'new b.txt', |
| + 'new.txt': 'new file in dir', |
| + }, |
| +} |
| + |
| +class ChainedCompiledFileSystemTest(unittest.TestCase): |
| + def setUp(self): |
| + self._object_store_creator = ObjectStoreCreator( |
| + 'chained', start_empty=False) |
| + self._base_object_store_creator = ObjectStoreCreator( |
| + 'base', start_empty=False) |
| + self._base_factory = CompiledFileSystem.Factory( |
| + TestFileSystem(_TEST_DATA_BASE), |
| + self._base_object_store_creator) |
| + self._file_system = TestFileSystem(_TEST_DATA_NEW) |
| + self._chained_factory = ChainedCompiledFileSystem.Factory( |
| + self._file_system, |
| + self._object_store_creator, |
| + self._base_factory) |
| + self._base_compiled_fs = self._base_factory.CreateIdentity(TestFileSystem) |
| + self._chained_compiled_fs = self._chained_factory.CreateIdentity( |
| + TestFileSystem) |
| + |
| + def testGetFromFile(self): |
| + self.assertEqual(self._chained_compiled_fs.GetFromFile('a.txt'), |
| + self._base_compiled_fs.GetFromFile('a.txt')) |
| + self.assertEqual(self._chained_compiled_fs.GetFromFile('new.txt'), |
| + 'a new file') |
| + self.assertEqual(self._chained_compiled_fs.GetFromFile('dir/new.txt'), |
| + 'new file in dir') |
| + self._file_system.IncrementStat('a.txt') |
| + self.assertNotEqual(self._chained_compiled_fs.GetFromFile('a.txt'), |
| + self._base_compiled_fs.GetFromFile('a.txt')) |
| + self.assertEqual(self._chained_compiled_fs.GetFromFile('a.txt'), |
| + self._file_system.ReadSingle('a.txt')) |
| + |
| + def testGetFromFileListing(self): |
| + self.assertEqual(self._chained_compiled_fs.GetFromFile('dir/'), |
| + self._base_compiled_fs.GetFromFile('dir/')) |
| + self._file_system.IncrementStat('dir/') |
| + self.assertNotEqual(self._chained_compiled_fs.GetFromFile('dir/'), |
| + self._base_compiled_fs.GetFromFile('dir/')) |
| + self.assertEqual(self._chained_compiled_fs.GetFromFile('dir/'), |
| + self._file_system.ReadSingle('dir/')) |
| + |
|
not at google - send to devlin
2013/05/11 20:39:53
test binary here as well?
方觉(Fang Jue)
2013/05/12 03:01:47
But ChainedCompiledFileSystem does not do anything
|
| +if __name__ == '__main__': |
| + unittest.main() |
| Property changes on: chrome/common/extensions/docs/server2/chained_compiled_file_system_test.py |
| ___________________________________________________________________ |
| Added: svn:executable |
| + * |
| Added: svn:eol-style |
| + LF |