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 unittest | 8 import unittest |
9 | 9 |
10 from file_system_cache import FileSystemCache | 10 from file_system_cache import FileSystemCache |
11 from local_file_system import LocalFileSystem | 11 from local_file_system import LocalFileSystem |
12 from template_data_source import TemplateDataSource | 12 from template_data_source import TemplateDataSource |
13 from third_party.handlebar import Handlebar | 13 from third_party.handlebar import Handlebar |
14 | 14 |
15 class _FakeRequest(object): | 15 class _FakeRequest(object): |
16 pass | 16 pass |
17 | 17 |
18 class _FakeApiDataSource(object): | |
19 pass | |
20 | |
18 class _FakeSamplesDataSource(object): | 21 class _FakeSamplesDataSource(object): |
19 def Create(self, request): | 22 def Create(self, request): |
20 return {} | 23 return {} |
21 | 24 |
22 class TemplateDataSourceTest(unittest.TestCase): | 25 class TemplateDataSourceTest(unittest.TestCase): |
23 def setUp(self): | 26 def setUp(self): |
24 self._base_path = os.path.join('test_data', 'template_data_source') | 27 self._base_path = os.path.join('test_data', 'template_data_source') |
25 self._fake_api_data_source = {} | 28 self._fake_api_data_source = _FakeApiDataSource() |
chebert
2012/07/26 20:36:39
ignore.
| |
26 self._fake_api_list_data_source = {} | 29 self._fake_api_list_data_source = {} |
27 self._fake_intro_data_source = {} | 30 self._fake_intro_data_source = {} |
28 self._fake_samples_data_source = _FakeSamplesDataSource() | 31 self._fake_samples_data_source = _FakeSamplesDataSource() |
29 | 32 |
30 def _ReadLocalFile(self, filename): | 33 def _ReadLocalFile(self, filename): |
31 with open(os.path.join(self._base_path, filename), 'r') as f: | 34 with open(os.path.join(self._base_path, filename), 'r') as f: |
32 return f.read() | 35 return f.read() |
33 | 36 |
34 def _RenderTest(self, name, data_source): | 37 def _RenderTest(self, name, data_source): |
35 template_name = name + '_tmpl.html' | 38 template_name = name + '_tmpl.html' |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 json.loads(self._ReadLocalFile('test1.json')), | 90 json.loads(self._ReadLocalFile('test1.json')), |
88 cache_builder)) | 91 cache_builder)) |
89 self._RenderTest( | 92 self._RenderTest( |
90 'test2', | 93 'test2', |
91 self._CreateTemplateDataSource( | 94 self._CreateTemplateDataSource( |
92 json.loads(self._ReadLocalFile('test2.json')), | 95 json.loads(self._ReadLocalFile('test2.json')), |
93 cache_builder)) | 96 cache_builder)) |
94 | 97 |
95 if __name__ == '__main__': | 98 if __name__ == '__main__': |
96 unittest.main() | 99 unittest.main() |
OLD | NEW |