Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(342)

Side by Side Diff: chrome/common/extensions/docs/server2/permissions_data_source_test.py

Issue 68873003: Docserver: Serve docs out of src/ not src/chrome/common/extensions. This allows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix samples Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 collections import Mapping 6 from collections import Mapping
7 import json 7 import json
8 from operator import itemgetter 8 from operator import itemgetter
9 import unittest 9 import unittest
10 10
11 from compiled_file_system import CompiledFileSystem 11 from compiled_file_system import CompiledFileSystem
12 from extensions_paths import EXTENSIONS
12 from object_store_creator import ObjectStoreCreator 13 from object_store_creator import ObjectStoreCreator
13 from permissions_data_source import PermissionsDataSource 14 from permissions_data_source import PermissionsDataSource
14 from server_instance import ServerInstance 15 from server_instance import ServerInstance
15 from third_party.handlebar import Handlebar 16 from third_party.handlebar import Handlebar
16 from test_file_system import TestFileSystem 17 from test_file_system import TestFileSystem
17 18
18 19
19 _PERMISSION_FEATURES = { 20 _PERMISSION_FEATURES = {
20 # This will appear for extensions with a description as defined in the 21 # This will appear for extensions with a description as defined in the
21 # permissions.json file. 22 # permissions.json file.
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 'templates': { 140 'templates': {
140 'json': { 141 'json': {
141 'manifest.json': '{}', 142 'manifest.json': '{}',
142 'permissions.json': json.dumps(_PERMISSIONS_JSON), 143 'permissions.json': json.dumps(_PERMISSIONS_JSON),
143 }, 144 },
144 'private': { 145 'private': {
145 'permissions': _PERMISSIONS_PARTIALS 146 'permissions': _PERMISSIONS_PARTIALS
146 }, 147 },
147 } 148 }
148 } 149 }
149 }) 150 }, relative_to=EXTENSIONS)
150 151
151 permissions_data_source = PermissionsDataSource( 152 permissions_data_source = PermissionsDataSource(
152 ServerInstance.ForTest(test_file_system), None) 153 ServerInstance.ForTest(test_file_system), None)
153 154
154 actual_extensions = permissions_data_source.get('declare_extensions') 155 actual_extensions = permissions_data_source.get('declare_extensions')
155 actual_apps = permissions_data_source.get('declare_apps') 156 actual_apps = permissions_data_source.get('declare_apps')
156 157
157 # Normalise all test data. 158 # Normalise all test data.
158 # - Sort keys. Since the tests don't use OrderedDicts we can't make 159 # - Sort keys. Since the tests don't use OrderedDicts we can't make
159 # assertions about the order, which is unfortunate. Oh well. 160 # assertions about the order, which is unfortunate. Oh well.
160 # - Render all of the Handlerbar instances so that we can use ==. 161 # - Render all of the Handlerbar instances so that we can use ==.
161 # Handlebars don't implement __eq__, but they probably should. 162 # Handlebars don't implement __eq__, but they probably should.
162 for lst in (actual_apps, actual_extensions, 163 for lst in (actual_apps, actual_extensions,
163 expected_apps, expected_extensions): 164 expected_apps, expected_extensions):
164 lst.sort(key=itemgetter('name')) 165 lst.sort(key=itemgetter('name'))
165 for mapping in lst: 166 for mapping in lst:
166 for key, value in mapping.iteritems(): 167 for key, value in mapping.iteritems():
167 if isinstance(value, Handlebar): 168 if isinstance(value, Handlebar):
168 mapping[key] = value.Render().text 169 mapping[key] = value.Render().text
169 170
170 self.assertEqual(expected_extensions, actual_extensions) 171 self.assertEqual(expected_extensions, actual_extensions)
171 self.assertEqual(expected_apps, actual_apps) 172 self.assertEqual(expected_apps, actual_apps)
172 173
174
173 if __name__ == '__main__': 175 if __name__ == '__main__':
174 unittest.main() 176 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698