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 appengine_wrappers import GetAppVersion | 8 from appengine_wrappers import GetAppVersion |
9 from app_yaml_helper import AppYamlHelper | 9 from app_yaml_helper import AppYamlHelper |
10 from cron_servlet import CronServlet | 10 from cron_servlet import CronServlet |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 'examples': { | 96 'examples': { |
97 'examples.txt': 'examples.txt contents' | 97 'examples.txt': 'examples.txt contents' |
98 }, | 98 }, |
99 'server2': { | 99 'server2': { |
100 'app.yaml': AppYamlHelper.GenerateAppYaml('2-0-8') | 100 'app.yaml': AppYamlHelper.GenerateAppYaml('2-0-8') |
101 }, | 101 }, |
102 'static': { | 102 'static': { |
103 'static.txt': 'static.txt contents' | 103 'static.txt': 'static.txt contents' |
104 }, | 104 }, |
105 'templates': { | 105 'templates': { |
| 106 'private': { |
| 107 'table_of_contents.html': 'table_of_contents.html contents', |
| 108 }, |
106 'public': { | 109 'public': { |
107 'apps': { | 110 'apps': { |
108 'storage.html': 'storage.html contents' | 111 'storage.html': '<h1>storage.html</h1> contents' |
109 }, | 112 }, |
110 'extensions': { | 113 'extensions': { |
111 'storage.html': 'storage.html contents' | 114 'storage.html': '<h1>storage.html</h1> contents' |
112 }, | 115 }, |
113 }, | 116 }, |
114 'json': { | 117 'json': { |
115 'content_providers.json': ReadFile(CONTENT_PROVIDERS), | 118 'content_providers.json': ReadFile(CONTENT_PROVIDERS), |
116 'manifest.json': '{}', | 119 'manifest.json': '{}', |
117 'permissions.json': '{}', | 120 'permissions.json': '{}', |
118 'strings.json': '{}', | 121 'strings.json': '{}', |
119 'apps_sidenav.json': '{}', | 122 'apps_sidenav.json': '{}', |
120 'extensions_sidenav.json': '{}', | 123 'extensions_sidenav.json': '{}', |
121 }, | 124 }, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 158 |
156 delegate = _TestDelegate(create_file_system) | 159 delegate = _TestDelegate(create_file_system) |
157 delegate.SetAppVersion('2-0-8') | 160 delegate.SetAppVersion('2-0-8') |
158 | 161 |
159 file_systems = delegate.file_systems | 162 file_systems = delegate.file_systems |
160 | 163 |
161 # No updates applied yet. | 164 # No updates applied yet. |
162 CronServlet(Request.ForTest('trunk'), delegate_for_test=delegate).Get() | 165 CronServlet(Request.ForTest('trunk'), delegate_for_test=delegate).Get() |
163 self.assertEqual(AppYamlHelper.GenerateAppYaml('2-0-8'), | 166 self.assertEqual(AppYamlHelper.GenerateAppYaml('2-0-8'), |
164 file_systems[-1].ReadSingle(APP_YAML).Get()) | 167 file_systems[-1].ReadSingle(APP_YAML).Get()) |
165 self.assertEqual('storage.html contents', | 168 self.assertEqual('<h1>storage.html</h1> contents', |
166 file_systems[-1].ReadSingle(storage_html_path).Get()) | 169 file_systems[-1].ReadSingle(storage_html_path).Get()) |
167 | 170 |
168 # Apply updates to storage.html. | 171 # Apply updates to storage.html. |
169 updates.append(storage_html_update('interim contents')) | 172 updates.append(storage_html_update('interim contents')) |
170 updates.append(storage_html_update('new contents')) | 173 updates.append(storage_html_update('<h1>new</h1> contents')) |
171 | 174 |
172 CronServlet(Request.ForTest('trunk'), delegate_for_test=delegate).Get() | 175 CronServlet(Request.ForTest('trunk'), delegate_for_test=delegate).Get() |
173 self.assertEqual(AppYamlHelper.GenerateAppYaml('2-0-8'), | 176 self.assertEqual(AppYamlHelper.GenerateAppYaml('2-0-8'), |
174 file_systems[-1].ReadSingle(APP_YAML).Get()) | 177 file_systems[-1].ReadSingle(APP_YAML).Get()) |
175 self.assertEqual('new contents', | 178 self.assertEqual('<h1>new</h1> contents', |
176 file_systems[-1].ReadSingle(storage_html_path).Get()) | 179 file_systems[-1].ReadSingle(storage_html_path).Get()) |
177 | 180 |
178 # Apply several updates to storage.html and app.yaml. The file system | 181 # Apply several updates to storage.html and app.yaml. The file system |
179 # should be pinned at the version before app.yaml changed. | 182 # should be pinned at the version before app.yaml changed. |
180 updates.append(storage_html_update('stuck here contents')) | 183 updates.append(storage_html_update('<h1>stuck here</h1> contents')) |
181 | 184 |
182 double_update = storage_html_update('newer contents') | 185 double_update = storage_html_update('<h1>newer</h1> contents') |
183 double_update.update(app_yaml_update('2-0-10')) | 186 double_update.update(app_yaml_update('2-0-10')) |
184 updates.append(double_update) | 187 updates.append(double_update) |
185 | 188 |
186 updates.append(storage_html_update('never gonna reach here')) | 189 updates.append(storage_html_update('never gonna reach here')) |
187 | 190 |
188 CronServlet(Request.ForTest('trunk'), delegate_for_test=delegate).Get() | 191 CronServlet(Request.ForTest('trunk'), delegate_for_test=delegate).Get() |
189 self.assertEqual(AppYamlHelper.GenerateAppYaml('2-0-8'), | 192 self.assertEqual(AppYamlHelper.GenerateAppYaml('2-0-8'), |
190 file_systems[-1].ReadSingle(APP_YAML).Get()) | 193 file_systems[-1].ReadSingle(APP_YAML).Get()) |
191 self.assertEqual('stuck here contents', | 194 self.assertEqual('<h1>stuck here</h1> contents', |
192 file_systems[-1].ReadSingle(storage_html_path).Get()) | 195 file_systems[-1].ReadSingle(storage_html_path).Get()) |
193 | 196 |
194 # Further pushes to storage.html will keep it pinned. | 197 # Further pushes to storage.html will keep it pinned. |
195 updates.append(storage_html_update('y u not update!')) | 198 updates.append(storage_html_update('<h1>y</h1> u not update!')) |
196 | 199 |
197 CronServlet(Request.ForTest('trunk'), delegate_for_test=delegate).Get() | 200 CronServlet(Request.ForTest('trunk'), delegate_for_test=delegate).Get() |
198 self.assertEqual(AppYamlHelper.GenerateAppYaml('2-0-8'), | 201 self.assertEqual(AppYamlHelper.GenerateAppYaml('2-0-8'), |
199 file_systems[-1].ReadSingle(APP_YAML).Get()) | 202 file_systems[-1].ReadSingle(APP_YAML).Get()) |
200 self.assertEqual('stuck here contents', | 203 self.assertEqual('<h1>stuck here</h1> contents', |
201 file_systems[-1].ReadSingle(storage_html_path).Get()) | 204 file_systems[-1].ReadSingle(storage_html_path).Get()) |
202 | 205 |
203 # Likewise app.yaml. | 206 # Likewise app.yaml. |
204 updates.append(app_yaml_update('2-1-0')) | 207 updates.append(app_yaml_update('2-1-0')) |
205 | 208 |
206 CronServlet(Request.ForTest('trunk'), delegate_for_test=delegate).Get() | 209 CronServlet(Request.ForTest('trunk'), delegate_for_test=delegate).Get() |
207 self.assertEqual(AppYamlHelper.GenerateAppYaml('2-0-8'), | 210 self.assertEqual(AppYamlHelper.GenerateAppYaml('2-0-8'), |
208 file_systems[-1].ReadSingle(APP_YAML).Get()) | 211 file_systems[-1].ReadSingle(APP_YAML).Get()) |
209 self.assertEqual('stuck here contents', | 212 self.assertEqual('<h1>stuck here</h1> contents', |
210 file_systems[-1].ReadSingle(storage_html_path).Get()) | 213 file_systems[-1].ReadSingle(storage_html_path).Get()) |
211 | 214 |
212 # And updates to other content won't happen either. | 215 # And updates to other content won't happen either. |
213 updates.append(static_txt_update('important content!')) | 216 updates.append(static_txt_update('important content!')) |
214 | 217 |
215 CronServlet(Request.ForTest('trunk'), delegate_for_test=delegate).Get() | 218 CronServlet(Request.ForTest('trunk'), delegate_for_test=delegate).Get() |
216 self.assertEqual(AppYamlHelper.GenerateAppYaml('2-0-8'), | 219 self.assertEqual(AppYamlHelper.GenerateAppYaml('2-0-8'), |
217 file_systems[-1].ReadSingle(APP_YAML).Get()) | 220 file_systems[-1].ReadSingle(APP_YAML).Get()) |
218 self.assertEqual('stuck here contents', | 221 self.assertEqual('<h1>stuck here</h1> contents', |
219 file_systems[-1].ReadSingle(storage_html_path).Get()) | 222 file_systems[-1].ReadSingle(storage_html_path).Get()) |
220 self.assertEqual('static.txt contents', | 223 self.assertEqual('static.txt contents', |
221 file_systems[-1].ReadSingle(static_txt_path).Get()) | 224 file_systems[-1].ReadSingle(static_txt_path).Get()) |
222 | 225 |
223 # Lastly - when the app version changes, everything should no longer be | 226 # Lastly - when the app version changes, everything should no longer be |
224 # pinned. | 227 # pinned. |
225 delegate.SetAppVersion('2-1-0') | 228 delegate.SetAppVersion('2-1-0') |
226 CronServlet(Request.ForTest('trunk'), delegate_for_test=delegate).Get() | 229 CronServlet(Request.ForTest('trunk'), delegate_for_test=delegate).Get() |
227 self.assertEqual(AppYamlHelper.GenerateAppYaml('2-1-0'), | 230 self.assertEqual(AppYamlHelper.GenerateAppYaml('2-1-0'), |
228 file_systems[-1].ReadSingle(APP_YAML).Get()) | 231 file_systems[-1].ReadSingle(APP_YAML).Get()) |
229 self.assertEqual('y u not update!', | 232 self.assertEqual('<h1>y</h1> u not update!', |
230 file_systems[-1].ReadSingle(storage_html_path).Get()) | 233 file_systems[-1].ReadSingle(storage_html_path).Get()) |
231 self.assertEqual('important content!', | 234 self.assertEqual('important content!', |
232 file_systems[-1].ReadSingle(static_txt_path).Get()) | 235 file_systems[-1].ReadSingle(static_txt_path).Get()) |
233 | 236 |
234 if __name__ == '__main__': | 237 if __name__ == '__main__': |
235 unittest.main() | 238 unittest.main() |
OLD | NEW |