| 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 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 def _CreateTemplateDataSource(self, input_dict, cache_builder): | 48 def _CreateTemplateDataSource(self, input_dict, cache_builder): |
| 49 return (TemplateDataSource.Factory('fake_branch', | 49 return (TemplateDataSource.Factory('fake_branch', |
| 50 _FakeApiDataSourceFactory(input_dict), | 50 _FakeApiDataSourceFactory(input_dict), |
| 51 self._fake_api_list_data_source, | 51 self._fake_api_list_data_source, |
| 52 self._fake_intro_data_source, | 52 self._fake_intro_data_source, |
| 53 self._fake_samples_data_source, | 53 self._fake_samples_data_source, |
| 54 cache_builder, | 54 cache_builder, |
| 55 '.', | 55 '.', |
| 56 '.') | 56 '.') |
| 57 .Create(_FakeRequest())) | 57 .Create(_FakeRequest(), 'fake_branch')) |
| 58 | 58 |
| 59 def testSimple(self): | 59 def testSimple(self): |
| 60 self._base_path = os.path.join(self._base_path, 'simple') | 60 self._base_path = os.path.join(self._base_path, 'simple') |
| 61 fetcher = LocalFileSystem(self._base_path) | 61 fetcher = LocalFileSystem(self._base_path) |
| 62 cache_builder = FileSystemCache.Builder(fetcher) | 62 cache_builder = FileSystemCache.Builder(fetcher) |
| 63 t_data_source = self._CreateTemplateDataSource( | 63 t_data_source = self._CreateTemplateDataSource( |
| 64 self._fake_api_data_source_factory, cache_builder) | 64 self._fake_api_data_source_factory, cache_builder) |
| 65 template_a1 = Handlebar(self._ReadLocalFile('test1.html')) | 65 template_a1 = Handlebar(self._ReadLocalFile('test1.html')) |
| 66 self.assertEqual(template_a1.render({}, {'templates': {}}).text, | 66 self.assertEqual(template_a1.render({}, {'templates': {}}).text, |
| 67 t_data_source['test1'].render({}, {'templates': {}}).text) | 67 t_data_source['test1'].render({}, {'templates': {}}).text) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 94 json.loads(self._ReadLocalFile('test1.json')), | 94 json.loads(self._ReadLocalFile('test1.json')), |
| 95 cache_builder)) | 95 cache_builder)) |
| 96 self._RenderTest( | 96 self._RenderTest( |
| 97 'test2', | 97 'test2', |
| 98 self._CreateTemplateDataSource( | 98 self._CreateTemplateDataSource( |
| 99 json.loads(self._ReadLocalFile('test2.json')), | 99 json.loads(self._ReadLocalFile('test2.json')), |
| 100 cache_builder)) | 100 cache_builder)) |
| 101 | 101 |
| 102 if __name__ == '__main__': | 102 if __name__ == '__main__': |
| 103 unittest.main() | 103 unittest.main() |
| OLD | NEW |