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.
6 from copy import deepcopy
10 from compiled_file_system import CompiledFileSystem
11 from features_bundle import FeaturesBundle
12 import manifest_data_source
13 from object_store_creator import ObjectStoreCreator
16 convert_and_annotate_docs = {
18 'example': "My {{title}}",
31 'annotations': ['not so important'],
46 'level': 'recommended',
60 class ManifestDataSourceTest(unittest.TestCase):
61 def testListifyAndSortDocs(self):
72 'annotations': ['not so important'],
84 'example': '"My App"',
89 'level': 'recommended',
106 self.assertEqual(expected_docs, manifest_data_source._ListifyAndSortDocs(
107 deepcopy(convert_and_annotate_docs), 'App'))
109 def testAnnotate(self):
120 'annotations': ['Optional', 'not so important'],
134 'example': '"My App"',
138 'annotations': ['Recommended'],
139 'level': 'recommended',
143 'annotations': ['Pick one (or none)'],
152 'annotations': ['Optional'],
159 annotated = manifest_data_source._ListifyAndSortDocs(
160 deepcopy(convert_and_annotate_docs), 'App')
161 manifest_data_source._AddLevelAnnotations(annotated)
162 self.assertEqual(expected_docs, annotated)
164 def testExpandedExamples(self):
171 'json_example': ['with', 'more', 'json']
189 'name': 'json_example',
190 'example': json.dumps(['with', 'more', 'json']),
202 expected_docs, manifest_data_source._ListifyAndSortDocs(docs, 'apps'))
204 def testManifestDataSource(self):
205 manifest_features = {
208 'platforms': ['apps', 'extensions'],
214 'platforms': ['apps'],
215 'annotations': ['important!'],
216 'level': 'recommended'
220 'platforms': ['extensions']
230 'platforms': ['apps', 'extensions'],
237 'level': 'recommended',
239 'platforms': ['apps'],
247 class FakeFeaturesBundle(object):
248 def GetManifestFeatures(self):
249 return manifest_features
251 class FakeServerInstance(object):
253 self.features_bundle = FakeFeaturesBundle()
254 self.object_store_creator = ObjectStoreCreator.ForTest()
256 mds = manifest_data_source.ManifestDataSource(FakeServerInstance(), None)
257 self.assertEqual(expected_app, mds.get('apps'))
259 if __name__ == '__main__':