| 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 expected_intro = 'you<h2>first</h2><h3>inner</h3><h2>second</h2>' | 24 expected_intro = 'you<h2>first</h2><h3>inner</h3><h2>second</h2>' |
| 23 # Article still has the header. | 25 # Article still has the header. |
| 24 expected_article = '<h1>hi</h1>' + expected_intro | 26 expected_article = '<h1>hi</h1>' + expected_intro |
| 25 | 27 |
| 26 self.assertEqual(expected_intro, intro_data.Render().text) | 28 self.assertEqual(expected_intro, intro_data.Render().text) |
| 27 self.assertEqual(expected_article, article_data.Render().text) | 29 self.assertEqual(expected_article, article_data.Render().text) |
| 28 | 30 |
| 29 | 31 |
| 30 if __name__ == '__main__': | 32 if __name__ == '__main__': |
| 31 unittest.main() | 33 unittest.main() |
| OLD | NEW |