Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 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 | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 import json | |
| 7 import types | |
| 8 import unittest | |
| 9 | |
| 10 from compiled_file_system import CompiledFileSystem | |
| 11 from manifest_data_source import ManifestDataSource | |
| 12 from object_store_creator import ObjectStoreCreator | |
| 13 from test_file_system import TestFileSystem | |
| 14 | |
| 15 file_system = TestFileSystem({ | |
| 16 "_manifest_features.json": json.dumps({ | |
| 17 'req0': { | |
| 18 'channl': 'stable', | |
| 19 'extension_types': ['platform_app', 'extension'] | |
| 20 }, | |
| 21 'req1': { | |
| 22 'channel': 'dev', | |
| 23 'extension_types': 'all' | |
| 24 }, | |
| 25 'opt0': { | |
| 26 'channel': 'trunk', | |
| 27 'extension_types': ['extension'] | |
| 28 }, | |
| 29 'opt1': { | |
| 30 'channel': 'stable', | |
| 31 'extension_types': ['hosted_app'] | |
| 32 }, | |
| 33 'free0': { | |
| 34 'channel': 'stable', | |
| 35 'extension_types': ['platform_app'] | |
| 36 }, | |
| 37 'free1': { | |
| 38 'channel': 'dev', | |
| 39 'extension_types': ['platform_app', 'hosted_app', 'extension'] | |
| 40 } | |
| 41 }), | |
| 42 "manifest.json": json.dumps({ | |
| 43 'required': [ | |
| 44 {'name': 'req0'}, | |
| 45 {'name': 'req1'} | |
| 46 ], | |
| 47 'optional': [ | |
| 48 {'name': 'opt0'}, | |
| 49 {'name': 'opt1'} | |
| 50 ] | |
| 51 }) | |
| 52 }) | |
| 53 | |
| 54 def Nothing(self, _): | |
| 55 # Do nothing. We don't care what Apply{Apps,Extensions}Transformations methods | |
| 56 # do because they change depending on data. | |
| 57 pass | |
| 58 | |
| 59 class ManifestDataSourceTest(unittest.TestCase): | |
| 60 def testCreateManifestData(self): | |
| 61 expected_extensions = { | |
| 62 'required': [ | |
| 63 {'name': 'req0'}, | |
| 64 {'name': 'req1'} | |
| 65 ], | |
| 66 'optional': [ | |
| 67 {'name': 'free1'}, | |
| 68 {'name': 'opt0'} | |
| 69 ] | |
| 70 } | |
| 71 | |
| 72 expected_apps = { | |
| 73 'required': [ | |
| 74 {'name': 'req0'}, | |
| 75 {'name': 'req1'} | |
| 76 ], | |
| 77 'optional': [ | |
| 78 {'name': 'free0'}, | |
| 79 {'name': 'free1'} | |
| 80 ] | |
| 81 } | |
| 82 | |
| 83 mds = ManifestDataSource( | |
| 84 CompiledFileSystem.Factory(file_system, ObjectStoreCreator.ForTest()), | |
| 85 file_system, 'manifest.json', '_manifest_features.json', 'dev') | |
| 86 | |
| 87 # Prevent an actual file load by patching in our load function. | |
| 88 mds._ApplyAppsTransformations = types.MethodType(Nothing, mds) | |
| 89 mds._ApplyExtensionsTransformations = types.MethodType(Nothing, mds) | |
|
not at google - send to devlin
2013/05/11 18:32:01
pls never override private methods. it greatly red
jshumway
2013/05/11 22:08:20
Fixed that.
| |
| 90 | |
| 91 self.assertEqual(expected_extensions, dict(mds.get('extensions'))) | |
| 92 self.assertEqual(expected_apps, dict(mds.get('apps'))) | |
| 93 | |
| 94 if __name__ == '__main__': | |
| 95 unittest.main() | |
| OLD | NEW |