Chromium Code Reviews| Index: chrome/common/extensions/docs/server2/compiled_file_system_test.py |
| diff --git a/chrome/common/extensions/docs/server2/compiled_file_system_test.py b/chrome/common/extensions/docs/server2/compiled_file_system_test.py |
| index 65dacfc123522174d961449e634bd254a9207bd5..89ba465d4e6df489e3b165b6a098b9d5680cbf78 100755 |
| --- a/chrome/common/extensions/docs/server2/compiled_file_system_test.py |
| +++ b/chrome/common/extensions/docs/server2/compiled_file_system_test.py |
| @@ -39,19 +39,23 @@ _TEST_DATA = { |
| identity = lambda _, x: x |
| -def _CreateFactory(): |
| - return CompiledFileSystem.Factory( |
| - TestFileSystem(deepcopy(_TEST_DATA)), |
| - ObjectStoreCreator(start_empty=False, |
| - store_type=TestObjectStore, |
| - disable_wrappers=True)) |
| +def _CreateTestObjects(): |
|
Jeffrey Yasskin
2013/10/14 18:52:31
Instead of returning an obscure tuple, how about r
not at google - send to devlin
2013/10/14 21:03:34
Done.
|
| + '''Returns a tuple (CompiledFileSystem.Factory, FileSystem) configured for |
| + this test. |
| + ''' |
| + return ( |
| + CompiledFileSystem.Factory( |
| + ObjectStoreCreator(start_empty=False, |
| + store_type=TestObjectStore, |
| + disable_wrappers=True)), |
| + TestFileSystem(deepcopy(_TEST_DATA))) |
| class CompiledFileSystemTest(unittest.TestCase): |
| def testPopulateNamespace(self): |
| def CheckNamespace(expected_file, expected_list, fs): |
| self.assertEqual(expected_file, fs._file_object_store.namespace) |
| self.assertEqual(expected_list, fs._list_object_store.namespace) |
| - factory = _CreateFactory() |
| + factory, fs = _CreateTestObjects() |
| f = lambda x: x |
| CheckNamespace( |
| 'class=CompiledFileSystem&' |
| @@ -60,7 +64,7 @@ class CompiledFileSystemTest(unittest.TestCase): |
| 'class=CompiledFileSystem&' |
| 'category=CompiledFileSystemTest/TestFileSystem/list&' |
| 'app_version=%s' % GetAppVersion(), |
| - factory.Create(f, CompiledFileSystemTest)) |
| + factory.Create(fs, f, CompiledFileSystemTest)) |
| CheckNamespace( |
| 'class=CompiledFileSystem&' |
| 'category=CompiledFileSystemTest/TestFileSystem/foo/file&' |
| @@ -68,12 +72,13 @@ class CompiledFileSystemTest(unittest.TestCase): |
| 'class=CompiledFileSystem&' |
| 'category=CompiledFileSystemTest/TestFileSystem/foo/list&' |
| 'app_version=%s' % GetAppVersion(), |
| - factory.Create(f, CompiledFileSystemTest, category='foo')) |
| + factory.Create(fs, f, CompiledFileSystemTest, category='foo')) |
| def testPopulateFromFile(self): |
| def Sleepy(key, val): |
| return '%s%s' % ('Z' * len(key), 'z' * len(val)) |
| - compiled_fs = _CreateFactory().Create(Sleepy, CompiledFileSystemTest) |
| + factory, fs = _CreateTestObjects() |
| + compiled_fs = factory.Create(fs, Sleepy, CompiledFileSystemTest) |
| self.assertEqual('ZZZZZZZZzzzzzzzzzzzzzzzzz', |
| compiled_fs.GetFromFile('404.html').Get()) |
| self.assertEqual('ZZZZZZZZZZZZZZzzzzzzzzzzzzzzzzzz', |
| @@ -85,7 +90,8 @@ class CompiledFileSystemTest(unittest.TestCase): |
| def strip_ext(path, files): |
| return [os.path.splitext(f)[0] for f in files] |
| - compiled_fs = _CreateFactory().Create(strip_ext, CompiledFileSystemTest) |
| + factory, fs = _CreateTestObjects() |
| + compiled_fs = factory.Create(fs, strip_ext, CompiledFileSystemTest) |
| expected_top_listing = [ |
| '404', |
| 'apps/a11y', |
| @@ -129,7 +135,8 @@ class CompiledFileSystemTest(unittest.TestCase): |
| 'apps/deepdir/deeper/').Get()) |
| def testCaching(self): |
| - compiled_fs = _CreateFactory().Create(identity, CompiledFileSystemTest) |
| + factory, fs = _CreateTestObjects() |
| + compiled_fs = factory.Create(fs, identity, CompiledFileSystemTest) |
| self.assertEqual('404.html contents', |
| compiled_fs.GetFromFile('404.html').Get()) |
| self.assertEqual(set(('file.html',)), |
| @@ -148,7 +155,8 @@ class CompiledFileSystemTest(unittest.TestCase): |
| set(compiled_fs.GetFromFileListing('apps/fakedir').Get())) |
| def testFailures(self): |
| - compiled_fs = _CreateFactory().Create(identity, CompiledFileSystemTest) |
| + factory, fs = _CreateTestObjects() |
| + compiled_fs = factory.Create(fs, identity, CompiledFileSystemTest) |
| self.assertRaises(FileNotFoundError, |
| compiled_fs.GetFromFile('405.html').Get) |
| # TODO(kalman): would be nice to test this fails since apps/ is a dir. |
| @@ -166,8 +174,8 @@ class CompiledFileSystemTest(unittest.TestCase): |
| # resolved until Get is. |
| mock_fs = MockFileSystem(TestFileSystem(_TEST_DATA)) |
| compiled_fs = CompiledFileSystem.Factory( |
| - mock_fs, ObjectStoreCreator.ForTest()).Create( |
| - lambda path, contents: contents, type(self)) |
| + ObjectStoreCreator.ForTest()).Create( |
| + mock_fs, lambda path, contents: contents, type(self)) |
| self.assertTrue(*mock_fs.CheckAndReset()) |
| future = compiled_fs.GetFromFile('404.html') |