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 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 return f.read() | 45 return f.read() |
46 | 46 |
47 def _RenderTest(self, name, data_source): | 47 def _RenderTest(self, name, data_source): |
48 template_name = name + '_tmpl.html' | 48 template_name = name + '_tmpl.html' |
49 template = Handlebar(self._ReadLocalFile(template_name)) | 49 template = Handlebar(self._ReadLocalFile(template_name)) |
50 self.assertEquals( | 50 self.assertEquals( |
51 self._ReadLocalFile(name + '_expected.html'), | 51 self._ReadLocalFile(name + '_expected.html'), |
52 data_source.Render(template_name)) | 52 data_source.Render(template_name)) |
53 | 53 |
54 def _CreateTemplateDataSource(self, compiled_fs_factory, api_data=None): | 54 def _CreateTemplateDataSource(self, compiled_fs_factory, api_data=None): |
55 fake_avail_factory = _FakeFactory() | |
not at google - send to devlin
2013/04/30 18:34:19
inline
epeterson
2013/05/13 02:38:10
Done.
| |
55 if api_data is None: | 56 if api_data is None: |
56 api_data_factory = APIDataSource.Factory(compiled_fs_factory, 'fake_path') | 57 api_data_factory = APIDataSource.Factory(compiled_fs_factory, |
58 'fake_path', | |
59 fake_avail_factory, | |
60 {}) # Unnecessary file system | |
not at google - send to devlin
2013/04/30 18:34:19
just create a TestFileSystem and avoid the comment
epeterson
2013/05/13 02:38:10
Done.
| |
57 else: | 61 else: |
58 api_data_factory = _FakeFactory(api_data) | 62 api_data_factory = _FakeFactory(api_data) |
59 reference_resolver_factory = ReferenceResolver.Factory( | 63 reference_resolver_factory = ReferenceResolver.Factory( |
60 api_data_factory, | 64 api_data_factory, |
61 self._fake_api_list_data_source_factory, | 65 self._fake_api_list_data_source_factory, |
62 ObjectStoreCreator.TestFactory()) | 66 ObjectStoreCreator.TestFactory()) |
63 @DisableLogging('error') # "was never set" error | 67 @DisableLogging('error') # "was never set" error |
64 def create_from_factory(factory): | 68 def create_from_factory(factory): |
65 return factory.Create(_FakeRequest(), 'extensions/foo') | 69 return factory.Create(_FakeRequest(), 'extensions/foo') |
66 return create_from_factory(TemplateDataSource.Factory( | 70 return create_from_factory(TemplateDataSource.Factory( |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 compiled_fs_factory, | 133 compiled_fs_factory, |
130 api_data=json.loads(self._ReadLocalFile('test1.json')))) | 134 api_data=json.loads(self._ReadLocalFile('test1.json')))) |
131 self._RenderTest( | 135 self._RenderTest( |
132 'test2', | 136 'test2', |
133 self._CreateTemplateDataSource( | 137 self._CreateTemplateDataSource( |
134 compiled_fs_factory, | 138 compiled_fs_factory, |
135 api_data=json.loads(self._ReadLocalFile('test2.json')))) | 139 api_data=json.loads(self._ReadLocalFile('test2.json')))) |
136 | 140 |
137 if __name__ == '__main__': | 141 if __name__ == '__main__': |
138 unittest.main() | 142 unittest.main() |
OLD | NEW |