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 from copy import deepcopy | 6 from copy import deepcopy |
7 import json | 7 import json |
8 import unittest | 8 import unittest |
9 | 9 |
10 from future import Future | 10 from future import Future |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 'name': 'doc1', | 242 'name': 'doc1', |
243 'platforms': ['apps', 'extensions'], | 243 'platforms': ['apps', 'extensions'], |
244 'example': {}, | 244 'example': {}, |
245 'level': 'required' | 245 'level': 'required' |
246 }, | 246 }, |
247 'doc1.sub1': { | 247 'doc1.sub1': { |
248 'name': 'doc1.sub1', | 248 'name': 'doc1.sub1', |
249 'platforms': ['apps'], | 249 'platforms': ['apps'], |
250 'annotations': ['important!'], | 250 'annotations': ['important!'], |
251 'level': 'recommended' | 251 'level': 'recommended' |
252 }, | |
253 'doc2': { | |
254 'name': 'doc2', | |
255 'platforms': ['extensions'] | |
256 } | 252 } |
257 } | 253 } |
258 | 254 |
259 expected_app = [ | 255 expected_app = [ |
260 { | 256 { |
261 'example': '{...}', | 257 'example': '{...}', |
262 'has_example': True, | 258 'has_example': True, |
263 'level': 'required', | 259 'level': 'required', |
264 'name': 'doc1', | 260 'name': 'doc1', |
265 'platforms': ['apps', 'extensions'], | 261 'platforms': ['apps', 'extensions'], |
266 'children': [ | 262 'children': [ |
267 { | 263 { |
268 'annotations': [ | 264 'annotations': [ |
269 'Recommended', | 265 'Recommended', |
270 'important!' | 266 'important!' |
271 ], | 267 ], |
272 'level': 'recommended', | 268 'level': 'recommended', |
273 'name': 'sub1', | 269 'name': 'sub1', |
274 'platforms': ['apps'], | 270 'platforms': ['apps'], |
275 'is_last': True | 271 'is_last': True |
276 } | 272 } |
277 ], | 273 ], |
278 'is_last': True | 274 'is_last': True |
279 } | 275 } |
280 ] | 276 ] |
281 | 277 |
| 278 class FakePlatformBundle(object): |
| 279 def GetFeaturesBundle(self, platform): |
| 280 return FakeFeaturesBundle() |
| 281 |
282 class FakeFeaturesBundle(object): | 282 class FakeFeaturesBundle(object): |
283 def GetManifestFeatures(self): | 283 def GetManifestFeatures(self): |
284 return Future(value=manifest_features) | 284 return Future(value=manifest_features) |
285 | 285 |
286 class FakeServerInstance(object): | 286 class FakeServerInstance(object): |
287 def __init__(self): | 287 def __init__(self): |
288 self.features_bundle = FakeFeaturesBundle() | 288 self.platform_bundle = FakePlatformBundle() |
289 self.object_store_creator = ObjectStoreCreator.ForTest() | 289 self.object_store_creator = ObjectStoreCreator.ForTest() |
290 | 290 |
291 mds = manifest_data_source.ManifestDataSource(FakeServerInstance(), None) | 291 mds = manifest_data_source.ManifestDataSource(FakeServerInstance(), None) |
292 self.assertEqual(expected_app, mds.get('apps')) | 292 self.assertEqual(expected_app, mds.get('apps')) |
293 | 293 |
294 if __name__ == '__main__': | 294 if __name__ == '__main__': |
295 unittest.main() | 295 unittest.main() |
OLD | NEW |