| 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 compiled_file_system import CompiledFileSystem | 10 from compiled_file_system import CompiledFileSystem |
| 11 from features_bundle import FeaturesBundle |
| 11 import manifest_data_source | 12 import manifest_data_source |
| 12 from object_store_creator import ObjectStoreCreator | 13 from object_store_creator import ObjectStoreCreator |
| 13 from test_file_system import TestFileSystem | 14 from test_file_system import TestFileSystem |
| 14 | 15 |
| 15 | 16 |
| 16 convert_and_annotate_docs = { | 17 convert_and_annotate_docs = { |
| 17 'name': { | 18 'name': { |
| 18 'example': "My {{title}}", | 19 'example': "My {{title}}", |
| 19 'name': 'name', | 20 'name': 'name', |
| 20 'level': 'required' | 21 'level': 'required' |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 } | 193 } |
| 193 ] | 194 ] |
| 194 } | 195 } |
| 195 ] | 196 ] |
| 196 } | 197 } |
| 197 ] | 198 ] |
| 198 } | 199 } |
| 199 ] | 200 ] |
| 200 | 201 |
| 201 self.assertEqual( | 202 self.assertEqual( |
| 202 expected_docs, manifest_data_source._ListifyAndSortDocs(docs, 'app')) | 203 expected_docs, manifest_data_source._ListifyAndSortDocs(docs, 'apps')) |
| 203 | 204 |
| 204 def testManifestDataSource(self): | 205 def testManifestDataSource(self): |
| 205 file_system = TestFileSystem({ | 206 file_system = TestFileSystem({ |
| 206 '_manifest_features.json': json.dumps({ | 207 '_manifest_features.json': json.dumps({ |
| 207 'doc1': { | 208 'doc1': { |
| 208 'extension_types': 'all' | 209 'extension_types': 'all' |
| 209 }, | 210 }, |
| 210 'doc1.sub1': { | 211 'doc1.sub1': { |
| 211 'extension_types': ['platform_app'] | 212 'extension_types': ['platform_app'] |
| 212 }, | 213 }, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 225 } | 226 } |
| 226 }) | 227 }) |
| 227 }) | 228 }) |
| 228 | 229 |
| 229 expected_app = [ | 230 expected_app = [ |
| 230 { | 231 { |
| 231 'example': '{...}', | 232 'example': '{...}', |
| 232 'has_example': True, | 233 'has_example': True, |
| 233 'level': 'required', | 234 'level': 'required', |
| 234 'name': 'doc1', | 235 'name': 'doc1', |
| 235 'platforms': ['app', 'extension'], | 236 'platforms': ['apps', 'extensions'], |
| 236 'children': [ | 237 'children': [ |
| 237 { | 238 { |
| 238 'annotations': [ | 239 'annotations': [ |
| 239 'Recommended', | 240 'Recommended', |
| 240 'important!' | 241 'important!' |
| 241 ], | 242 ], |
| 242 'level': 'recommended', | 243 'level': 'recommended', |
| 243 'name': 'sub1', | 244 'name': 'sub1', |
| 244 'platforms': ['app'], | 245 'platforms': ['apps'], |
| 245 'is_last': True | 246 'is_last': True |
| 246 } | 247 } |
| 247 ], | 248 ], |
| 248 'is_last': True | 249 'is_last': True |
| 249 } | 250 } |
| 250 ] | 251 ] |
| 251 | 252 |
| 252 class FakeServerInstance(object): | 253 class FakeServerInstance(object): |
| 253 def __init__(self): | 254 def __init__(self): |
| 254 self.host_file_system = file_system | 255 self.host_file_system = file_system |
| 255 self.compiled_host_fs_factory = CompiledFileSystem.Factory( | 256 self.compiled_host_fs_factory = CompiledFileSystem.Factory( |
| 256 file_system, ObjectStoreCreator.ForTest()) | 257 file_system, ObjectStoreCreator.ForTest()) |
| 257 self.manifest_json_path = 'manifest.json' | 258 self.features_bundle = FeaturesBundle( |
| 258 self.manifest_features_path = '_manifest_features.json' | 259 self.host_file_system, |
| 260 self.compiled_host_fs_factory, |
| 261 { 'manifest': ['_manifest_features.json', 'manifest.json'] }) |
| 259 | 262 |
| 260 mds = manifest_data_source.ManifestDataSource(FakeServerInstance(), None) | 263 mds = manifest_data_source.ManifestDataSource(FakeServerInstance(), None) |
| 261 self.assertEqual(expected_app, mds.get('apps')) | 264 self.assertEqual(expected_app, mds.get('apps')) |
| 262 | 265 |
| 263 if __name__ == '__main__': | 266 if __name__ == '__main__': |
| 264 unittest.main() | 267 unittest.main() |
| OLD | NEW |