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

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

Issue 14267024: Devserver: have a separate ObjectStore namespace (both memcache and datastore) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove _CheckVersions Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/common/extensions/docs/server2/template_data_source.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 data_source.Render(template_name)) 51 data_source.Render(template_name))
52 52
53 def _CreateTemplateDataSource(self, compiled_fs_factory, api_data=None): 53 def _CreateTemplateDataSource(self, compiled_fs_factory, api_data=None):
54 if api_data is None: 54 if api_data is None:
55 api_data_factory = APIDataSource.Factory(compiled_fs_factory, 'fake_path') 55 api_data_factory = APIDataSource.Factory(compiled_fs_factory, 'fake_path')
56 else: 56 else:
57 api_data_factory = _FakeFactory(api_data) 57 api_data_factory = _FakeFactory(api_data)
58 reference_resolver_factory = ReferenceResolver.Factory( 58 reference_resolver_factory = ReferenceResolver.Factory(
59 api_data_factory, 59 api_data_factory,
60 self._fake_api_list_data_source_factory, 60 self._fake_api_list_data_source_factory,
61 ObjectStoreCreator.Factory()) 61 ObjectStoreCreator.TestFactory())
62 return (TemplateDataSource.Factory('fake_channel', 62 return (TemplateDataSource.Factory('fake_channel',
63 api_data_factory, 63 api_data_factory,
64 self._fake_api_list_data_source_factory, 64 self._fake_api_list_data_source_factory,
65 self._fake_intro_data_source_factory, 65 self._fake_intro_data_source_factory,
66 self._fake_samples_data_source_factory, 66 self._fake_samples_data_source_factory,
67 self._fake_sidenav_data_source_factory, 67 self._fake_sidenav_data_source_factory,
68 compiled_fs_factory, 68 compiled_fs_factory,
69 reference_resolver_factory, 69 reference_resolver_factory,
70 '.', 70 '.',
71 '.') 71 '.')
72 .Create(_FakeRequest(), 'extensions/foo')) 72 .Create(_FakeRequest(), 'extensions/foo'))
73 73
74 def testSimple(self): 74 def testSimple(self):
75 self._base_path = os.path.join(self._base_path, 'simple') 75 self._base_path = os.path.join(self._base_path, 'simple')
76 fetcher = LocalFileSystem(self._base_path) 76 fetcher = LocalFileSystem(self._base_path)
77 compiled_fs_factory = CompiledFileSystem.Factory( 77 compiled_fs_factory = CompiledFileSystem.Factory(
78 fetcher, 78 fetcher,
79 ObjectStoreCreator.Factory()) 79 ObjectStoreCreator.TestFactory())
80 t_data_source = self._CreateTemplateDataSource(compiled_fs_factory, 80 t_data_source = self._CreateTemplateDataSource(
81 ObjectStoreCreator.Factory()) 81 compiled_fs_factory,
82 ObjectStoreCreator.TestFactory())
82 template_a1 = Handlebar(self._ReadLocalFile('test1.html')) 83 template_a1 = Handlebar(self._ReadLocalFile('test1.html'))
83 self.assertEqual(template_a1.render({}, {'templates': {}}).text, 84 self.assertEqual(template_a1.render({}, {'templates': {}}).text,
84 t_data_source.get('test1').render({}, {'templates': {}}).text) 85 t_data_source.get('test1').render({}, {'templates': {}}).text)
85 86
86 template_a2 = Handlebar(self._ReadLocalFile('test2.html')) 87 template_a2 = Handlebar(self._ReadLocalFile('test2.html'))
87 self.assertEqual(template_a2.render({}, {'templates': {}}).text, 88 self.assertEqual(template_a2.render({}, {'templates': {}}).text,
88 t_data_source.get('test2').render({}, {'templates': {}}).text) 89 t_data_source.get('test2').render({}, {'templates': {}}).text)
89 90
90 self.assertEqual(None, t_data_source.get('junk.html')) 91 self.assertEqual(None, t_data_source.get('junk.html'))
91 92
92 def testPartials(self): 93 def testPartials(self):
93 self._base_path = os.path.join(self._base_path, 'partials') 94 self._base_path = os.path.join(self._base_path, 'partials')
94 fetcher = LocalFileSystem(self._base_path) 95 fetcher = LocalFileSystem(self._base_path)
95 compiled_fs_factory = CompiledFileSystem.Factory( 96 compiled_fs_factory = CompiledFileSystem.Factory(
96 fetcher, 97 fetcher,
97 ObjectStoreCreator.Factory()) 98 ObjectStoreCreator.TestFactory())
98 t_data_source = self._CreateTemplateDataSource(compiled_fs_factory) 99 t_data_source = self._CreateTemplateDataSource(compiled_fs_factory)
99 self.assertEqual( 100 self.assertEqual(
100 self._ReadLocalFile('test_expected.html'), 101 self._ReadLocalFile('test_expected.html'),
101 t_data_source.get('test_tmpl').render( 102 t_data_source.get('test_tmpl').render(
102 json.loads(self._ReadLocalFile('input.json')), t_data_source).text) 103 json.loads(self._ReadLocalFile('input.json')), t_data_source).text)
103 104
104 def testRender(self): 105 def testRender(self):
105 self._base_path = os.path.join(self._base_path, 'render') 106 self._base_path = os.path.join(self._base_path, 'render')
106 fetcher = LocalFileSystem(self._base_path) 107 fetcher = LocalFileSystem(self._base_path)
107 context = json.loads(self._ReadLocalFile('test1.json')) 108 context = json.loads(self._ReadLocalFile('test1.json'))
108 compiled_fs_factory = CompiledFileSystem.Factory( 109 compiled_fs_factory = CompiledFileSystem.Factory(
109 fetcher, 110 fetcher,
110 ObjectStoreCreator.Factory()) 111 ObjectStoreCreator.TestFactory())
111 self._RenderTest( 112 self._RenderTest(
112 'test1', 113 'test1',
113 self._CreateTemplateDataSource( 114 self._CreateTemplateDataSource(
114 compiled_fs_factory, 115 compiled_fs_factory,
115 api_data=json.loads(self._ReadLocalFile('test1.json')))) 116 api_data=json.loads(self._ReadLocalFile('test1.json'))))
116 self._RenderTest( 117 self._RenderTest(
117 'test2', 118 'test2',
118 self._CreateTemplateDataSource( 119 self._CreateTemplateDataSource(
119 compiled_fs_factory, 120 compiled_fs_factory,
120 api_data=json.loads(self._ReadLocalFile('test2.json')))) 121 api_data=json.loads(self._ReadLocalFile('test2.json'))))
121 122
122 if __name__ == '__main__': 123 if __name__ == '__main__':
123 unittest.main() 124 unittest.main()
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/template_data_source.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698