Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(561)

Side by Side Diff: chrome/common/extensions/docs/server2/intro_data_source_test.py

Issue 12996003: Dynamically generate a heading for Extension Docs API pages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comments - Patch currently being broken up Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 import json
7 import os
8
6 from server_instance import ServerInstance 9 from server_instance import ServerInstance
7 import svn_constants 10 from test_data.canned_data import CANNED_TEST_FILE_SYSTEM_DATA
8 from test_file_system import TestFileSystem 11 from test_file_system import TestFileSystem
9 import unittest 12 import unittest
10 13
11 _TEST_DATA = TestFileSystem.MoveTo(svn_constants.INTRO_PATH, { 14 def _LoadJson(name, mode='rb'):
12 'test.html': '<h1>hello</h1>world<h2>first</h2><h3>inner</h3><h2>second</h2>' 15 return json.load(
13 }) 16 open(os.path.join('test_data', 'test_json', name), mode))
14 17
15 class IntroDataSourceTest(unittest.TestCase): 18 class IntroDataSourceTest(unittest.TestCase):
16 def setUp(self): 19 def setUp(self):
17 self._server = ServerInstance.ForTest(TestFileSystem(_TEST_DATA)) 20 self._server = ServerInstance.ForTest(
21 TestFileSystem(CANNED_TEST_FILE_SYSTEM_DATA))
18 22
19 def testIntro(self): 23 def testIntro(self):
20 intro_data_source = self._server.intro_data_source_factory.Create() 24 intro_data_source = self._server.intro_data_source_factory.Create()
21 data = intro_data_source.get('test') 25 data = intro_data_source.get('test')
22 self.assertEqual('hello', data['title']) 26 self.assertEqual('hi', data['title'])
23 # TODO(kalman): test links. 27 # TODO(kalman): test links.
24 expected_toc = [{'subheadings': [{'link': '', 'title': u'inner'}], 28 expected_toc = [{'subheadings': [{'link': '', 'title': u'inner'}],
25 'link': '', 29 'link': '',
26 'title': u'first'}, 30 'title': u'first'},
27 {'subheadings': [], 'link': '', 'title': u'second'}] 31 {'subheadings': [], 'link': '', 'title': u'second'}]
28 self.assertEqual(expected_toc, data['apps_toc']) 32 self.assertEqual(expected_toc, data['apps_toc'])
29 self.assertEqual(expected_toc, data['extensions_toc']) 33 self.assertEqual(expected_toc, data['extensions_toc'])
30 self.assertEqual('world<h2>first</h2><h3>inner</h3><h2>second</h2>', 34 self.assertEqual('you<h2>first</h2><h3>inner</h3><h2>second</h2>',
31 data['intro'].render().text) 35 data['intro'].render().text)
32 36
33 if __name__ == '__main__': 37 if __name__ == '__main__':
34 unittest.main() 38 unittest.main()
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/instance_servlet_test.py ('k') | chrome/common/extensions/docs/server2/patch_servlet.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698