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 servlet import Request |
8 from test_data.canned_data import CANNED_TEST_FILE_SYSTEM_DATA | 9 from test_data.canned_data import CANNED_TEST_FILE_SYSTEM_DATA |
9 from test_file_system import TestFileSystem | 10 from test_file_system import TestFileSystem |
10 import unittest | 11 import unittest |
11 | 12 |
12 class IntroDataSourceTest(unittest.TestCase): | 13 class IntroDataSourceTest(unittest.TestCase): |
13 def setUp(self): | 14 def setUp(self): |
14 self._server_instance = ServerInstance.ForTest( | 15 self._server_instance = ServerInstance.ForTest( |
15 TestFileSystem(CANNED_TEST_FILE_SYSTEM_DATA)) | 16 TestFileSystem(CANNED_TEST_FILE_SYSTEM_DATA)) |
16 | 17 |
17 def testIntro(self): | 18 def testIntro(self): |
18 intro_data_source = IntroDataSource(self._server_instance, None) | 19 intro_data_source = IntroDataSource( |
| 20 self._server_instance, Request.ForTest('')) |
19 intro_data = intro_data_source.get('test_intro') | 21 intro_data = intro_data_source.get('test_intro') |
20 article_data = intro_data_source.get('test_article') | 22 article_data = intro_data_source.get('test_article') |
21 | 23 |
22 self.assertEqual('hi', article_data.get('title')) | 24 self.assertEqual('hi', article_data.get('title')) |
23 self.assertEqual(None, intro_data.get('title')) | 25 self.assertEqual(None, intro_data.get('title')) |
24 | 26 |
25 # TODO(kalman): test links. | 27 # TODO(kalman): test links. |
26 expected_toc = [{ | 28 expected_toc = [{ |
27 'link': '', | 29 'link': '', |
28 'subheadings': [{'link': '', 'subheadings': [], 'title': u'inner'}], | 30 'subheadings': [{'link': '', 'subheadings': [], 'title': u'inner'}], |
29 'title': u'first', | 31 'title': u'first', |
30 }, { | 32 }, { |
31 'link': '', | 33 'link': '', |
32 'subheadings': [], | 34 'subheadings': [], |
33 'title': u'second' | 35 'title': u'second' |
34 } | 36 } |
35 ] | 37 ] |
36 self.assertEqual(expected_toc, article_data.get('toc')) | 38 self.assertEqual(expected_toc, article_data.get('toc')) |
37 self.assertEqual(expected_toc, intro_data.get('toc')) | 39 self.assertEqual(expected_toc, intro_data.get('toc')) |
38 | 40 |
39 expected_text = 'you<h2>first</h2><h3>inner</h3><h2>second</h2>' | 41 expected_text = 'you<h2>first</h2><h3>inner</h3><h2>second</h2>' |
40 self.assertEqual(expected_text, article_data.Render().text) | 42 self.assertEqual(expected_text, article_data.Render().text) |
41 self.assertEqual(expected_text, intro_data.Render().text) | 43 self.assertEqual(expected_text, intro_data.Render().text) |
42 | 44 |
43 | 45 |
44 if __name__ == '__main__': | 46 if __name__ == '__main__': |
45 unittest.main() | 47 unittest.main() |
OLD | NEW |