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

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

Issue 176973009: Doc server: support interfaces in src/extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rename path constants, update APIModels.GetModel Created 6 years, 9 months 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 import json 6 import json
7 from operator import itemgetter 7 from operator import itemgetter
8 import unittest 8 import unittest
9 9
10 from extensions_paths import EXTENSIONS 10 from extensions_paths import CHROME_EXTENSIONS
11 from permissions_data_source import PermissionsDataSource 11 from permissions_data_source import PermissionsDataSource
12 from server_instance import ServerInstance 12 from server_instance import ServerInstance
13 from third_party.handlebar import Handlebar 13 from third_party.handlebar import Handlebar
14 from test_file_system import TestFileSystem 14 from test_file_system import TestFileSystem
15 15
16 16
17 _PERMISSION_FEATURES = { 17 _PERMISSION_FEATURES = {
18 # This will appear for extensions with a description as defined in the 18 # This will appear for extensions with a description as defined in the
19 # permissions.json file. 19 # permissions.json file.
20 'activeTab': { 20 'activeTab': {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 'templates': { 137 'templates': {
138 'json': { 138 'json': {
139 'manifest.json': '{}', 139 'manifest.json': '{}',
140 'permissions.json': json.dumps(_PERMISSIONS_JSON), 140 'permissions.json': json.dumps(_PERMISSIONS_JSON),
141 }, 141 },
142 'private': { 142 'private': {
143 'permissions': _PERMISSIONS_PARTIALS 143 'permissions': _PERMISSIONS_PARTIALS
144 }, 144 },
145 } 145 }
146 } 146 }
147 }, relative_to=EXTENSIONS) 147 }, relative_to=CHROME_EXTENSIONS)
148 148
149 permissions_data_source = PermissionsDataSource( 149 permissions_data_source = PermissionsDataSource(
150 ServerInstance.ForTest(test_file_system), None) 150 ServerInstance.ForTest(test_file_system), None)
151 151
152 actual_extensions = permissions_data_source.get('declare_extensions') 152 actual_extensions = permissions_data_source.get('declare_extensions')
153 actual_apps = permissions_data_source.get('declare_apps') 153 actual_apps = permissions_data_source.get('declare_apps')
154 154
155 # Normalise all test data. 155 # Normalise all test data.
156 # - Sort keys. Since the tests don't use OrderedDicts we can't make 156 # - Sort keys. Since the tests don't use OrderedDicts we can't make
157 # assertions about the order, which is unfortunate. Oh well. 157 # assertions about the order, which is unfortunate. Oh well.
158 # - Render all of the Handlerbar instances so that we can use ==. 158 # - Render all of the Handlerbar instances so that we can use ==.
159 # Handlebars don't implement __eq__, but they probably should. 159 # Handlebars don't implement __eq__, but they probably should.
160 for lst in (actual_apps, actual_extensions, 160 for lst in (actual_apps, actual_extensions,
161 expected_apps, expected_extensions): 161 expected_apps, expected_extensions):
162 lst.sort(key=itemgetter('name')) 162 lst.sort(key=itemgetter('name'))
163 for mapping in lst: 163 for mapping in lst:
164 for key, value in mapping.iteritems(): 164 for key, value in mapping.iteritems():
165 if isinstance(value, Handlebar): 165 if isinstance(value, Handlebar):
166 mapping[key] = value.Render().text 166 mapping[key] = value.Render().text
167 167
168 self.assertEqual(expected_extensions, actual_extensions) 168 self.assertEqual(expected_extensions, actual_extensions)
169 self.assertEqual(expected_apps, actual_apps) 169 self.assertEqual(expected_apps, actual_apps)
170 170
171 171
172 if __name__ == '__main__': 172 if __name__ == '__main__':
173 unittest.main() 173 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698