Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 import os | 7 import os |
| 8 import sys | 8 import sys |
| 9 import unittest | 9 import unittest |
| 10 | 10 |
| 11 from api_data_source import APIDataSource | 11 from api_data_source import APIDataSource |
| 12 from compiled_file_system import CompiledFileSystem | 12 from compiled_file_system import CompiledFileSystem |
| 13 from local_file_system import LocalFileSystem | 13 from local_file_system import LocalFileSystem |
| 14 from local_renderer import LocalRenderer | |
| 14 from object_store_creator import ObjectStoreCreator | 15 from object_store_creator import ObjectStoreCreator |
| 15 from reference_resolver import ReferenceResolver | 16 from reference_resolver import ReferenceResolver |
| 17 import svn_constants | |
| 16 from template_data_source import TemplateDataSource | 18 from template_data_source import TemplateDataSource |
| 17 from test_util import DisableLogging | 19 from test_util import DisableLogging |
| 18 from third_party.handlebar import Handlebar | 20 from third_party.handlebar import Handlebar |
| 19 | 21 |
| 20 class _FakeRequest(object): | 22 class _FakeRequest(object): |
| 21 pass | 23 pass |
| 22 | 24 |
| 23 class _FakeFactory(object): | 25 class _FakeFactory(object): |
| 24 def __init__(self, input_dict=None): | 26 def __init__(self, input_dict=None): |
| 25 if input_dict is None: | 27 if input_dict is None: |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 'test1', | 129 'test1', |
| 128 self._CreateTemplateDataSource( | 130 self._CreateTemplateDataSource( |
| 129 compiled_fs_factory, | 131 compiled_fs_factory, |
| 130 api_data=json.loads(self._ReadLocalFile('test1.json')))) | 132 api_data=json.loads(self._ReadLocalFile('test1.json')))) |
| 131 self._RenderTest( | 133 self._RenderTest( |
| 132 'test2', | 134 'test2', |
| 133 self._CreateTemplateDataSource( | 135 self._CreateTemplateDataSource( |
| 134 compiled_fs_factory, | 136 compiled_fs_factory, |
| 135 api_data=json.loads(self._ReadLocalFile('test2.json')))) | 137 api_data=json.loads(self._ReadLocalFile('test2.json')))) |
| 136 | 138 |
| 139 def testJSONDocumentationSources(self): | |
|
not at google - send to devlin
2013/04/30 16:21:09
We should just fix https://code.google.com/p/chrom
jshumway
2013/05/03 03:44:39
Good point, I have been noticing a lot of comments
| |
| 140 # Make sure all of the documentation links in | |
| 141 # templates/json/(extensions|apps)_manifest.json can be rendered. This | |
| 142 # includes the template lookup through compiled_file_system_source. | |
| 143 from handler import Handler | |
| 144 _base_path = os.path.join(os.path.abspath( | |
| 145 os.path.dirname(__file__)), os.pardir, os.pardir, os.pardir) | |
| 146 renderer = LocalRenderer(_base_path) | |
| 147 | |
| 148 for f in ['extensions', 'apps']: | |
| 149 json_path = os.path.join( | |
| 150 _base_path, 'extensions', svn_constants.JSON_PATH, f + '_manifest.json') | |
| 151 # If the json is malformed, this well raise an error. | |
| 152 with open(json_path) as jsonfile: | |
| 153 data = json.loads(jsonfile.read()) | |
| 154 | |
| 155 for section in data.keys(): | |
| 156 for entry in data[section]: | |
| 157 link = entry['documentation'] | |
| 158 | |
| 159 # This doesn't work, apparently it doesn't create a true file_system, | |
| 160 # and therefore cannot render templates. Looking for a fix. | |
| 161 # _, render_status, __ = renderer.Render("/%s/%s" % (f, link)) | |
| 162 # assertEqual(200, render_status) | |
| 163 | |
| 164 # For now, just check if the public templates exist. | |
| 165 try: | |
| 166 path = os.path.join( | |
| 167 _base_path, 'extensions', svn_constants.PUBLIC_TEMPLATE_PATH, f) | |
| 168 os.stat(os.path.join(path, link)) | |
| 169 except OSError: | |
| 170 raise OSError("A required template %s could not be found " | |
| 171 "in %s." % (link, path)) | |
| 172 | |
| 173 | |
| 137 if __name__ == '__main__': | 174 if __name__ == '__main__': |
| 138 unittest.main() | 175 unittest.main() |
| OLD | NEW |