| 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 app_yaml_helper import AppYamlHelper | 8 from app_yaml_helper import AppYamlHelper |
| 9 from content_providers import IgnoreMissingContentProviders | 9 from content_providers import IgnoreMissingContentProviders |
| 10 from cron_servlet import CronServlet | 10 from cron_servlet import CronServlet |
| 11 from empty_dir_file_system import EmptyDirFileSystem | 11 from empty_dir_file_system import EmptyDirFileSystem |
| 12 from environment import GetAppVersion | 12 from environment import GetAppVersion |
| 13 from extensions_paths import ( | 13 from extensions_paths import ( |
| 14 APP_YAML, CONTENT_PROVIDERS, CHROME_EXTENSIONS, PUBLIC_TEMPLATES, SERVER2, | 14 APP_YAML, CONTENT_PROVIDERS, CHROME_EXTENSIONS, PUBLIC_TEMPLATES, SERVER2, |
| 15 STATIC_DOCS) | 15 STATIC_DOCS) |
| 16 from fake_fetchers import ConfigureFakeFetchers |
| 16 from gcs_file_system_provider import CloudStorageFileSystemProvider | 17 from gcs_file_system_provider import CloudStorageFileSystemProvider |
| 17 from github_file_system_provider import GithubFileSystemProvider | 18 from github_file_system_provider import GithubFileSystemProvider |
| 18 from host_file_system_provider import HostFileSystemProvider | 19 from host_file_system_provider import HostFileSystemProvider |
| 19 from local_file_system import LocalFileSystem | 20 from local_file_system import LocalFileSystem |
| 20 from mock_file_system import MockFileSystem | 21 from mock_file_system import MockFileSystem |
| 21 from servlet import Request | 22 from servlet import Request |
| 22 from test_branch_utility import TestBranchUtility | 23 from test_branch_utility import TestBranchUtility |
| 23 from test_file_system import MoveTo, TestFileSystem | 24 from test_file_system import MoveTo, TestFileSystem |
| 24 from test_util import EnableLogging, ReadFile | 25 from test_util import EnableLogging, ReadFile |
| 25 | 26 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 87 |
| 87 self.assertEqual(len(first_run_file_systems), len(delegate.file_systems)) | 88 self.assertEqual(len(first_run_file_systems), len(delegate.file_systems)) |
| 88 for i, second_run_file_system in enumerate(delegate.file_systems): | 89 for i, second_run_file_system in enumerate(delegate.file_systems): |
| 89 self.assertTrue(*second_run_file_system.CheckAndReset( | 90 self.assertTrue(*second_run_file_system.CheckAndReset( |
| 90 read_count=0, | 91 read_count=0, |
| 91 stat_count=first_run_file_systems[i].GetStatCount())) | 92 stat_count=first_run_file_systems[i].GetStatCount())) |
| 92 | 93 |
| 93 @IgnoreMissingContentProviders | 94 @IgnoreMissingContentProviders |
| 94 def testSafeRevision(self): | 95 def testSafeRevision(self): |
| 95 test_data = { | 96 test_data = { |
| 96 'api': { | 97 'extensions': { |
| 97 '_api_features.json': '{}', | 98 'browser': { |
| 98 '_manifest_features.json': '{}', | 99 'api': {} |
| 99 '_permission_features.json': '{}', | 100 } |
| 100 }, | 101 }, |
| 101 'docs': { | 102 'chrome': { |
| 102 'examples': { | 103 'browser': { |
| 103 'examples.txt': 'examples.txt contents' | 104 'extensions': { |
| 105 'OWNERS': '', |
| 106 'api': {} |
| 107 } |
| 104 }, | 108 }, |
| 105 'server2': { | 109 'common': { |
| 106 'app.yaml': AppYamlHelper.GenerateAppYaml('2-0-8') | 110 'extensions': { |
| 107 }, | 111 'api': { |
| 108 'static': { | 112 '_api_features.json': '{}', |
| 109 'static.txt': 'static.txt contents' | 113 '_manifest_features.json': '{}', |
| 110 }, | 114 '_permission_features.json': '{}', |
| 111 'templates': { | |
| 112 'articles': { | |
| 113 'activeTab.html': 'activeTab.html contents' | |
| 114 }, | |
| 115 'intros': { | |
| 116 'browserAction.html': 'activeTab.html contents' | |
| 117 }, | |
| 118 'private': { | |
| 119 'table_of_contents.html': 'table_of_contents.html contents', | |
| 120 }, | |
| 121 'public': { | |
| 122 'apps': { | |
| 123 'storage.html': '<h1>storage.html</h1> contents' | |
| 124 }, | 115 }, |
| 125 'extensions': { | 116 'docs': { |
| 126 'storage.html': '<h1>storage.html</h1> contents' | 117 'examples': { |
| 127 }, | 118 'examples.txt': 'examples.txt contents' |
| 128 }, | 119 }, |
| 129 'json': { | 120 'server2': { |
| 130 'chrome_sidenav.json': '{}', | 121 'app.yaml': AppYamlHelper.GenerateAppYaml('2-0-8') |
| 131 'content_providers.json': ReadFile(CONTENT_PROVIDERS), | 122 }, |
| 132 'manifest.json': '{}', | 123 'static': { |
| 133 'permissions.json': '{}', | 124 'static.txt': 'static.txt contents' |
| 134 'strings.json': '{}', | 125 }, |
| 135 'whats_new.json': '{}', | 126 'templates': { |
| 136 }, | 127 'articles': { |
| 128 'activeTab.html': 'activeTab.html contents' |
| 129 }, |
| 130 'intros': { |
| 131 'browserAction.html': 'activeTab.html contents' |
| 132 }, |
| 133 'private': { |
| 134 'table_of_contents.html': 'table_of_contents.html contents', |
| 135 }, |
| 136 'public': { |
| 137 'apps': { |
| 138 'storage.html': '<h1>storage.html</h1> contents' |
| 139 }, |
| 140 'extensions': { |
| 141 'storage.html': '<h1>storage.html</h1> contents' |
| 142 }, |
| 143 }, |
| 144 'json': { |
| 145 'chrome_sidenav.json': '{}', |
| 146 'content_providers.json': ReadFile(CONTENT_PROVIDERS), |
| 147 'manifest.json': '{}', |
| 148 'permissions.json': '{}', |
| 149 'strings.json': '{}', |
| 150 'whats_new.json': '{}', |
| 151 }, |
| 152 } |
| 153 } |
| 154 } |
| 137 } | 155 } |
| 138 } | 156 } |
| 139 } | 157 } |
| 140 | 158 |
| 141 updates = [] | 159 updates = [] |
| 142 | 160 |
| 143 def app_yaml_update(version): | 161 def app_yaml_update(version): |
| 144 return MoveTo(SERVER2, { | 162 return MoveTo(SERVER2, { |
| 145 'app.yaml': AppYamlHelper.GenerateAppYaml(version) | 163 'app.yaml': AppYamlHelper.GenerateAppYaml(version) |
| 146 }) | 164 }) |
| 147 def storage_html_update(update): | 165 def storage_html_update(update): |
| 148 return MoveTo(PUBLIC_TEMPLATES, { | 166 return MoveTo(PUBLIC_TEMPLATES, { |
| 149 'apps': {'storage.html': update} | 167 'apps': {'storage.html': update} |
| 150 }) | 168 }) |
| 151 def static_txt_update(update): | 169 def static_txt_update(update): |
| 152 return MoveTo(STATIC_DOCS, { | 170 return MoveTo(STATIC_DOCS, { |
| 153 'static.txt': update | 171 'static.txt': update |
| 154 }) | 172 }) |
| 155 | 173 |
| 156 storage_html_path = PUBLIC_TEMPLATES + 'apps/storage.html' | 174 storage_html_path = PUBLIC_TEMPLATES + 'apps/storage.html' |
| 157 static_txt_path = STATIC_DOCS + 'static.txt' | 175 static_txt_path = STATIC_DOCS + 'static.txt' |
| 158 | 176 |
| 159 def create_file_system(revision=None): | 177 def create_file_system(revision=None): |
| 160 '''Creates a MockFileSystem at |revision| by applying that many |updates| | 178 '''Creates a MockFileSystem at |revision| by applying that many |updates| |
| 161 to it. | 179 to it. |
| 162 ''' | 180 ''' |
| 163 mock_file_system = MockFileSystem( | 181 mock_file_system = MockFileSystem(TestFileSystem(test_data)) |
| 164 TestFileSystem(test_data, relative_to=CHROME_EXTENSIONS)) | |
| 165 updates_for_revision = ( | 182 updates_for_revision = ( |
| 166 updates if revision is None else updates[:int(revision)]) | 183 updates if revision is None else updates[:int(revision)]) |
| 167 for update in updates_for_revision: | 184 for update in updates_for_revision: |
| 168 mock_file_system.Update(update) | 185 mock_file_system.Update(update) |
| 169 return mock_file_system | 186 return mock_file_system |
| 170 | 187 |
| 171 delegate = _TestDelegate(create_file_system) | 188 delegate = _TestDelegate(create_file_system) |
| 172 delegate.SetAppVersion('2-0-8') | 189 delegate.SetAppVersion('2-0-8') |
| 173 | 190 |
| 174 file_systems = delegate.file_systems | 191 file_systems = delegate.file_systems |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 self.assertEqual(AppYamlHelper.GenerateAppYaml('2-1-0'), | 259 self.assertEqual(AppYamlHelper.GenerateAppYaml('2-1-0'), |
| 243 file_systems[-1].ReadSingle(APP_YAML).Get()) | 260 file_systems[-1].ReadSingle(APP_YAML).Get()) |
| 244 self.assertEqual('<h1>y</h1> u not update!', | 261 self.assertEqual('<h1>y</h1> u not update!', |
| 245 file_systems[-1].ReadSingle(storage_html_path).Get()) | 262 file_systems[-1].ReadSingle(storage_html_path).Get()) |
| 246 self.assertEqual('important content!', | 263 self.assertEqual('important content!', |
| 247 file_systems[-1].ReadSingle(static_txt_path).Get()) | 264 file_systems[-1].ReadSingle(static_txt_path).Get()) |
| 248 | 265 |
| 249 | 266 |
| 250 if __name__ == '__main__': | 267 if __name__ == '__main__': |
| 251 unittest.main() | 268 unittest.main() |
| OLD | NEW |