Chromium Code Reviews| Index: chrome/common/extensions/docs/server2/manifest_data_source_test.py |
| diff --git a/chrome/common/extensions/docs/server2/manifest_data_source_test.py b/chrome/common/extensions/docs/server2/manifest_data_source_test.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..d47c74ad87f84e232a5b96f826e194444101d513 |
| --- /dev/null |
| +++ b/chrome/common/extensions/docs/server2/manifest_data_source_test.py |
| @@ -0,0 +1,104 @@ |
| +#!/usr/bin/env python |
| +# Copyright 2013 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +import json |
| +import unittest |
| + |
| +from compiled_file_system import CompiledFileSystem |
| +from manifest_data_source import ManifestDataSource |
| +from object_store_creator import ObjectStoreCreator |
| +from test_file_system import TestFileSystem |
| + |
| +file_system = TestFileSystem({ |
| + "_manifest_features.json": json.dumps({ |
| + 'req0': { |
| + 'channl': 'stable', |
| + 'extension_types': ['platform_app', 'extension'] |
| + }, |
| + 'req1': { |
| + 'channel': 'dev', |
| + 'extension_types': 'all' |
| + }, |
| + 'opt0': { |
| + 'channel': 'trunk', |
| + 'extension_types': ['extension'] |
| + }, |
| + 'opt1': { |
| + 'channel': 'stable', |
| + 'extension_types': ['hosted_app'] |
| + }, |
| + 'free0': { |
| + 'channel': 'stable', |
| + 'extension_types': ['platform_app'] |
| + }, |
| + 'free1': { |
| + 'channel': 'dev', |
| + 'extension_types': ['platform_app', 'hosted_app', 'extension'] |
| + } |
| + }), |
| + "manifest.json": json.dumps({ |
| + 'required': [ |
| + { |
| + 'name': 'req0', |
| + 'example': 'Extension' |
| + }, |
| + {'name': 'req1'} |
| + ], |
| + 'optional': [ |
| + {'name': 'opt0'}, |
| + {'name': 'opt1'} |
| + ] |
| + }) |
| +}) |
| + |
| +class ManifestDataSourceTest(unittest.TestCase): |
| + def testCreateManifestData(self): |
| + expected_extensions = { |
| + 'required': [ |
| + { |
| + 'name': 'req0', |
| + 'example': 'Extension' |
| + }, |
| + {'name': 'req1'} |
| + ], |
| + 'recommended': [], |
| + 'only_one': [], |
| + 'optional': [ |
| + {'name': 'free1'}, |
| + { |
| + 'name': 'opt0', |
| + 'is_last': True |
| + } |
| + ] |
| + } |
| + |
| + expected_apps = { |
| + 'required': [ |
| + { |
| + 'name': 'req0', |
| + 'example': 'Application' |
| + }, |
| + {'name': 'req1'} |
| + ], |
| + 'recommended': [], |
| + 'only_one': [], |
| + 'optional': [ |
| + {'name': 'free0'}, |
| + { |
| + 'name': 'free1', |
| + 'is_last': True |
| + } |
| + ] |
| + } |
|
not at google - send to devlin
2013/05/11 22:19:04
pls augment the test so that all of the cases are
jshumway
2013/05/11 22:50:42
Done, I removed the channel attributes in the fake
|
| + |
| + mds = ManifestDataSource( |
| + CompiledFileSystem.Factory(file_system, ObjectStoreCreator.ForTest()), |
| + file_system, 'manifest.json', '_manifest_features.json', 'dev') |
| + |
| + self.assertEqual(expected_extensions, mds.get('extensions')) |
| + self.assertEqual(expected_apps, mds.get('apps')) |
| + |
| +if __name__ == '__main__': |
| + unittest.main() |