| 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 json | 6 import json |
| 7 import unittest | 7 import unittest |
| 8 | 8 |
| 9 from compiled_file_system import CompiledFileSystem | 9 from compiled_file_system import CompiledFileSystem |
| 10 from content_providers import ContentProviders | 10 from content_providers import ContentProviders |
| 11 from extensions_paths import EXTENSIONS | 11 from extensions_paths import CHROME_EXTENSIONS |
| 12 from gcs_file_system_provider import CloudStorageFileSystemProvider | 12 from gcs_file_system_provider import CloudStorageFileSystemProvider |
| 13 from object_store_creator import ObjectStoreCreator | 13 from object_store_creator import ObjectStoreCreator |
| 14 from test_file_system import TestFileSystem | 14 from test_file_system import TestFileSystem |
| 15 from test_util import DisableLogging | 15 from test_util import DisableLogging |
| 16 | 16 |
| 17 | 17 |
| 18 _CONTENT_PROVIDERS = { | 18 _CONTENT_PROVIDERS = { |
| 19 'apples': { | 19 'apples': { |
| 20 'chromium': { | 20 'chromium': { |
| 21 'dir': 'chrome/common/extensions/apples' | 21 'dir': 'chrome/common/extensions/apples' |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 def GetAndReset(self): | 96 def GetAndReset(self): |
| 97 calls = self._calls | 97 calls = self._calls |
| 98 self._calls = [] | 98 self._calls = [] |
| 99 return calls | 99 return calls |
| 100 | 100 |
| 101 | 101 |
| 102 class ContentProvidersTest(unittest.TestCase): | 102 class ContentProvidersTest(unittest.TestCase): |
| 103 def setUp(self): | 103 def setUp(self): |
| 104 object_store_creator = ObjectStoreCreator.ForTest() | 104 object_store_creator = ObjectStoreCreator.ForTest() |
| 105 test_file_system = TestFileSystem(_FILE_SYSTEM_DATA, relative_to=EXTENSIONS) | 105 test_file_system = TestFileSystem(_FILE_SYSTEM_DATA, |
| 106 relative_to=CHROME_EXTENSIONS) |
| 106 self._github_fs_provider = _MockGithubFileSystemProvider(test_file_system) | 107 self._github_fs_provider = _MockGithubFileSystemProvider(test_file_system) |
| 107 object_store_creator = ObjectStoreCreator.ForTest() | 108 object_store_creator = ObjectStoreCreator.ForTest() |
| 108 # TODO(mangini): create tests for GCS | 109 # TODO(mangini): create tests for GCS |
| 109 self._gcs_fs_provider = CloudStorageFileSystemProvider(object_store_creator) | 110 self._gcs_fs_provider = CloudStorageFileSystemProvider(object_store_creator) |
| 110 self._content_providers = ContentProviders( | 111 self._content_providers = ContentProviders( |
| 111 object_store_creator, | 112 object_store_creator, |
| 112 CompiledFileSystem.Factory(object_store_creator), | 113 CompiledFileSystem.Factory(object_store_creator), |
| 113 test_file_system, | 114 test_file_system, |
| 114 self._github_fs_provider, | 115 self._github_fs_provider, |
| 115 self._gcs_fs_provider) | 116 self._gcs_fs_provider) |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 self.assertEqual('gh2', serve_from) | 202 self.assertEqual('gh2', serve_from) |
| 202 self.assertEqual('fruit/cherry.txt', path) | 203 self.assertEqual('fruit/cherry.txt', path) |
| 203 self.assertEqual([('SomeOwner', 'some-repo')], | 204 self.assertEqual([('SomeOwner', 'some-repo')], |
| 204 self._github_fs_provider.GetAndReset()) | 205 self._github_fs_provider.GetAndReset()) |
| 205 self.assertEqual( | 206 self.assertEqual( |
| 206 'cherry tomatoes', | 207 'cherry tomatoes', |
| 207 provider.GetContentAndType(path).Get().content) | 208 provider.GetContentAndType(path).Get().content) |
| 208 | 209 |
| 209 if __name__ == '__main__': | 210 if __name__ == '__main__': |
| 210 unittest.main() | 211 unittest.main() |
| OLD | NEW |