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

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

Issue 11315018: Extensions Docs Server: Generalize $ref's to work for any schema node (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 8 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
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 .Create(_FakeRequest(), 'extensions/foo')) 63 .Create(_FakeRequest(), 'extensions/foo'))
64 64
65 def testSimple(self): 65 def testSimple(self):
66 self._base_path = os.path.join(self._base_path, 'simple') 66 self._base_path = os.path.join(self._base_path, 'simple')
67 fetcher = LocalFileSystem(self._base_path) 67 fetcher = LocalFileSystem(self._base_path)
68 cache_factory = CompiledFileSystem.Factory(fetcher, self._object_store) 68 cache_factory = CompiledFileSystem.Factory(fetcher, self._object_store)
69 t_data_source = self._CreateTemplateDataSource( 69 t_data_source = self._CreateTemplateDataSource(
70 self._fake_api_data_source_factory, cache_factory) 70 self._fake_api_data_source_factory, cache_factory)
71 template_a1 = Handlebar(self._ReadLocalFile('test1.html')) 71 template_a1 = Handlebar(self._ReadLocalFile('test1.html'))
72 self.assertEqual(template_a1.render({}, {'templates': {}}).text, 72 self.assertEqual(template_a1.render({}, {'templates': {}}).text,
73 t_data_source['test1'].render({}, {'templates': {}}).text) 73 t_data_source.get('test1').render({}, {'templates': {}}).text)
74 74
75 template_a2 = Handlebar(self._ReadLocalFile('test2.html')) 75 template_a2 = Handlebar(self._ReadLocalFile('test2.html'))
76 self.assertEqual(template_a2.render({}, {'templates': {}}).text, 76 self.assertEqual(template_a2.render({}, {'templates': {}}).text,
77 t_data_source['test2'].render({}, {'templates': {}}).text) 77 t_data_source.get('test2').render({}, {'templates': {}}).text)
78 78
79 self.assertEqual(None, t_data_source['junk.html']) 79 self.assertEqual(None, t_data_source.get('junk.html'))
80 80
81 def testPartials(self): 81 def testPartials(self):
82 self._base_path = os.path.join(self._base_path, 'partials') 82 self._base_path = os.path.join(self._base_path, 'partials')
83 fetcher = LocalFileSystem(self._base_path) 83 fetcher = LocalFileSystem(self._base_path)
84 cache_factory = CompiledFileSystem.Factory(fetcher, self._object_store) 84 cache_factory = CompiledFileSystem.Factory(fetcher, self._object_store)
85 t_data_source = self._CreateTemplateDataSource( 85 t_data_source = self._CreateTemplateDataSource(
86 self._fake_api_data_source_factory, cache_factory) 86 self._fake_api_data_source_factory, cache_factory)
87 self.assertEqual( 87 self.assertEqual(
88 self._ReadLocalFile('test_expected.html'), 88 self._ReadLocalFile('test_expected.html'),
89 t_data_source['test_tmpl'].render( 89 t_data_source.get('test_tmpl').render(
90 json.loads(self._ReadLocalFile('input.json')), t_data_source).text) 90 json.loads(self._ReadLocalFile('input.json')), t_data_source).text)
91 91
92 def testRender(self): 92 def testRender(self):
93 self._base_path = os.path.join(self._base_path, 'render') 93 self._base_path = os.path.join(self._base_path, 'render')
94 fetcher = LocalFileSystem(self._base_path) 94 fetcher = LocalFileSystem(self._base_path)
95 context = json.loads(self._ReadLocalFile('test1.json')) 95 context = json.loads(self._ReadLocalFile('test1.json'))
96 cache_factory = CompiledFileSystem.Factory(fetcher, self._object_store) 96 cache_factory = CompiledFileSystem.Factory(fetcher, self._object_store)
97 self._RenderTest( 97 self._RenderTest(
98 'test1', 98 'test1',
99 self._CreateTemplateDataSource( 99 self._CreateTemplateDataSource(
100 json.loads(self._ReadLocalFile('test1.json')), 100 json.loads(self._ReadLocalFile('test1.json')),
101 cache_factory)) 101 cache_factory))
102 self._RenderTest( 102 self._RenderTest(
103 'test2', 103 'test2',
104 self._CreateTemplateDataSource( 104 self._CreateTemplateDataSource(
105 json.loads(self._ReadLocalFile('test2.json')), 105 json.loads(self._ReadLocalFile('test2.json')),
106 cache_factory)) 106 cache_factory))
107 107
108 if __name__ == '__main__': 108 if __name__ == '__main__':
109 unittest.main() 109 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698