| 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 server_instance import ServerInstance | 6 from server_instance import ServerInstance |
| 7 import svn_constants | |
| 8 from test_file_system import TestFileSystem | 7 from test_file_system import TestFileSystem |
| 9 import unittest | 8 import unittest |
| 10 | 9 |
| 11 _TEST_DATA = TestFileSystem.MoveTo(svn_constants.INTRO_PATH, { | 10 _TEST_DATA = { |
| 12 'test.html': '<h1>hello</h1>world<h2>first</h2><h3>inner</h3><h2>second</h2>' | 11 'api': { |
| 13 }) | 12 '_manifest_features.json': '{"manifest": "features"}', |
| 13 '_permission_features.json': '{"permission": "features"}' |
| 14 }, |
| 15 'docs': { |
| 16 'templates': { |
| 17 'intros': { |
| 18 'test.html': '<h1>hi</h1>you<h2>first</h2><h3>inner</h3><h2>second</h2>' |
| 19 }, |
| 20 'json': { |
| 21 'api_availabilities.json': '[{"name": "test", "availability": "none"}]', |
| 22 'intro_tables.json': '{"test": [{"Permissions": "blue"}]}' |
| 23 } |
| 24 } |
| 25 } |
| 26 } |
| 14 | 27 |
| 15 class IntroDataSourceTest(unittest.TestCase): | 28 class IntroDataSourceTest(unittest.TestCase): |
| 16 def setUp(self): | 29 def setUp(self): |
| 17 self._server = ServerInstance.CreateForTest(TestFileSystem(_TEST_DATA)) | 30 self._server = ServerInstance.CreateForTest(TestFileSystem(_TEST_DATA)) |
| 18 | 31 |
| 19 def testIntro(self): | 32 def testIntro(self): |
| 20 intro_data_source = self._server.intro_data_source_factory.Create() | 33 intro_data_source = self._server.intro_data_source_factory.Create() |
| 21 data = intro_data_source.get('test') | 34 data = intro_data_source.get('test') |
| 22 self.assertEqual('hello', data['title']) | 35 self.assertEqual('hi', data['title']) |
| 23 # TODO(kalman): test links. | 36 # TODO(kalman): test links. |
| 24 expected_toc = [{'subheadings': [{'link': '', 'title': u'inner'}], | 37 expected_toc = [{'subheadings': [{'link': '', 'title': u'inner'}], |
| 25 'link': '', | 38 'link': '', |
| 26 'title': u'first'}, | 39 'title': u'first'}, |
| 27 {'subheadings': [], 'link': '', 'title': u'second'}] | 40 {'subheadings': [], 'link': '', 'title': u'second'}] |
| 28 self.assertEqual(expected_toc, data['apps_toc']) | 41 self.assertEqual(expected_toc, data['apps_toc']) |
| 29 self.assertEqual(expected_toc, data['extensions_toc']) | 42 self.assertEqual(expected_toc, data['extensions_toc']) |
| 30 self.assertEqual('world<h2>first</h2><h3>inner</h3><h2>second</h2>', | 43 self.assertEqual('you<h2>first</h2><h3>inner</h3><h2>second</h2>', |
| 31 data['intro'].render().text) | 44 data['intro'].render().text) |
| 32 | 45 |
| 33 if __name__ == '__main__': | 46 if __name__ == '__main__': |
| 34 unittest.main() | 47 unittest.main() |
| OLD | NEW |