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 from intro_data_source import IntroDataSource | 6 from intro_data_source import IntroDataSource |
7 from server_instance import ServerInstance | 7 from server_instance import ServerInstance |
8 from test_data.canned_data import CANNED_TEST_FILE_SYSTEM_DATA | 8 from test_data.canned_data import CANNED_TEST_FILE_SYSTEM_DATA |
9 from test_file_system import TestFileSystem | 9 from test_file_system import TestFileSystem |
10 import unittest | 10 import unittest |
11 | 11 |
12 class IntroDataSourceTest(unittest.TestCase): | 12 class IntroDataSourceTest(unittest.TestCase): |
13 def setUp(self): | 13 def setUp(self): |
14 self._server_instance = ServerInstance.ForTest( | 14 self._server_instance = ServerInstance.ForTest( |
15 TestFileSystem(CANNED_TEST_FILE_SYSTEM_DATA)) | 15 TestFileSystem(CANNED_TEST_FILE_SYSTEM_DATA)) |
16 | 16 |
17 def testIntro(self): | 17 def testIntro(self): |
18 intro_data_source = IntroDataSource(self._server_instance, None) | 18 intro_data_source = IntroDataSource(self._server_instance, None) |
19 data = intro_data_source.get('test') | 19 data = intro_data_source.get('test') |
20 self.assertEqual('hi', data['title']) | 20 self.assertEqual('hi', data.get('title')) |
21 # TODO(kalman): test links. | 21 # TODO(kalman): test links. |
22 expected_toc = [{'subheadings': [{'link': '', 'title': u'inner'}], | 22 expected_toc = [{'subheadings': [{'link': '', 'title': u'inner'}], |
23 'link': '', | 23 'link': '', |
24 'title': u'first'}, | 24 'title': u'first'}, |
25 {'subheadings': [], 'link': '', 'title': u'second'}] | 25 {'subheadings': [], 'link': '', 'title': u'second'}] |
26 self.assertEqual(expected_toc, data['apps_toc']) | 26 self.assertEqual(expected_toc, data.get('toc')) |
27 self.assertEqual(expected_toc, data['extensions_toc']) | |
28 self.assertEqual('you<h2>first</h2><h3>inner</h3><h2>second</h2>', | 27 self.assertEqual('you<h2>first</h2><h3>inner</h3><h2>second</h2>', |
29 data['intro'].render().text) | 28 data.Render().text) |
| 29 |
30 | 30 |
31 if __name__ == '__main__': | 31 if __name__ == '__main__': |
32 unittest.main() | 32 unittest.main() |
OLD | NEW |