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

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

Issue 68873003: Docserver: Serve docs out of src/ not src/chrome/common/extensions. This allows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix samples Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 6 import json
7 import os 7 import os
8 import sys 8 import sys
9 import unittest 9 import unittest
10 10
11 from extensions_paths import SERVER2
11 from server_instance import ServerInstance 12 from server_instance import ServerInstance
12 from template_data_source import TemplateDataSource 13 from template_data_source import TemplateDataSource
13 from test_util import DisableLogging, ReadFile 14 from test_util import DisableLogging, ReadFile
14 from third_party.handlebar import Handlebar 15 from third_party.handlebar import Handlebar
15 16
16 17
17 class TemplateDataSourceTest(unittest.TestCase): 18 class TemplateDataSourceTest(unittest.TestCase):
18 19
19 def setUp(self): 20 def setUp(self):
20 self._base_path = os.path.join(sys.path[0], 21 self._base_path = os.path.join(sys.path[0],
21 'test_data', 22 'test_data',
22 'template_data_source') 23 'template_data_source')
23 24
24 def _CreateTemplateDataSource(self, partial_dir): 25 def _CreateTemplateDataSource(self, partial_dir):
25 return TemplateDataSource( 26 return TemplateDataSource(
26 ServerInstance.ForLocal(), 27 ServerInstance.ForLocal(),
27 None, # Request 28 None, # Request
28 partial_dir='docs/server2/test_data/template_data_source/%s' % 29 partial_dir='%s/test_data/template_data_source/%s' %
29 partial_dir) 30 (SERVER2, partial_dir))
30 31
31 def testSimple(self): 32 def testSimple(self):
32 template_data_source = self._CreateTemplateDataSource('simple') 33 template_data_source = self._CreateTemplateDataSource('simple')
33 template_a1 = Handlebar(ReadFile(self._base_path, 'simple', 'test1.html')) 34 template_a1 = Handlebar(ReadFile(self._base_path, 'simple', 'test1.html'))
34 context = [{}, {'templates': {}}] 35 context = [{}, {'templates': {}}]
35 self.assertEqual( 36 self.assertEqual(
36 template_a1.Render(*context).text, 37 template_a1.Render(*context).text,
37 template_data_source.get('test1').Render(*context).text) 38 template_data_source.get('test1').Render(*context).text)
38 template_a2 = Handlebar(ReadFile(self._base_path, 'simple', 'test2.html')) 39 template_a2 = Handlebar(ReadFile(self._base_path, 'simple', 'test2.html'))
39 self.assertEqual( 40 self.assertEqual(
(...skipping 10 matching lines...) Expand all
50 template_data_source = self._CreateTemplateDataSource('partials') 51 template_data_source = self._CreateTemplateDataSource('partials')
51 context = json.loads(ReadFile(self._base_path, 'partials', 'input.json')) 52 context = json.loads(ReadFile(self._base_path, 'partials', 'input.json'))
52 self.assertEqual( 53 self.assertEqual(
53 ReadFile(self._base_path, 'partials', 'test_expected.html'), 54 ReadFile(self._base_path, 'partials', 'test_expected.html'),
54 template_data_source.get('test_tmpl').Render( 55 template_data_source.get('test_tmpl').Render(
55 context, template_data_source).text) 56 context, template_data_source).text)
56 57
57 58
58 if __name__ == '__main__': 59 if __name__ == '__main__':
59 unittest.main() 60 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698