| OLD | NEW |
| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 'templates': { | 132 'templates': { |
| 133 'json': { | 133 'json': { |
| 134 'manifest.json': '{}', | 134 'manifest.json': '{}', |
| 135 'permissions.json': json.dumps(_PERMISSIONS_JSON), | 135 'permissions.json': json.dumps(_PERMISSIONS_JSON), |
| 136 }, | 136 }, |
| 137 'private': { | 137 'private': { |
| 138 'permissions': _PERMISSIONS_PARTIALS | 138 'permissions': _PERMISSIONS_PARTIALS |
| 139 }, | 139 }, |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 }, relative_to=EXTENSIONS) | 142 }, relative_to=CHROME_EXTENSIONS) |
| 143 | 143 |
| 144 permissions_data_source = PermissionsDataSource( | 144 permissions_data_source = PermissionsDataSource( |
| 145 ServerInstance.ForTest(test_file_system), None) | 145 ServerInstance.ForTest(test_file_system), None) |
| 146 | 146 |
| 147 actual_extensions = permissions_data_source.get('declare_extensions') | 147 actual_extensions = permissions_data_source.get('declare_extensions') |
| 148 actual_apps = permissions_data_source.get('declare_apps') | 148 actual_apps = permissions_data_source.get('declare_apps') |
| 149 | 149 |
| 150 # Normalise all test data. | 150 # Normalise all test data. |
| 151 # - Sort keys. Since the tests don't use OrderedDicts we can't make | 151 # - Sort keys. Since the tests don't use OrderedDicts we can't make |
| 152 # assertions about the order, which is unfortunate. Oh well. | 152 # assertions about the order, which is unfortunate. Oh well. |
| 153 # - Render all of the Handlerbar instances so that we can use ==. | 153 # - Render all of the Handlerbar instances so that we can use ==. |
| 154 # Handlebars don't implement __eq__, but they probably should. | 154 # Handlebars don't implement __eq__, but they probably should. |
| 155 for lst in (actual_apps, actual_extensions, | 155 for lst in (actual_apps, actual_extensions, |
| 156 expected_apps, expected_extensions): | 156 expected_apps, expected_extensions): |
| 157 lst.sort(key=itemgetter('name')) | 157 lst.sort(key=itemgetter('name')) |
| 158 for mapping in lst: | 158 for mapping in lst: |
| 159 for key, value in mapping.iteritems(): | 159 for key, value in mapping.iteritems(): |
| 160 if isinstance(value, Handlebar): | 160 if isinstance(value, Handlebar): |
| 161 mapping[key] = value.Render().text | 161 mapping[key] = value.Render().text |
| 162 | 162 |
| 163 self.assertEqual(expected_extensions, actual_extensions) | 163 self.assertEqual(expected_extensions, actual_extensions) |
| 164 self.assertEqual(expected_apps, actual_apps) | 164 self.assertEqual(expected_apps, actual_apps) |
| 165 | 165 |
| 166 | 166 |
| 167 if __name__ == '__main__': | 167 if __name__ == '__main__': |
| 168 unittest.main() | 168 unittest.main() |
| OLD | NEW |