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

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

Issue 216943006: Remove ReferenceResolver dependency in APIDataSource. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
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 unittest 6 import unittest
7 7
8 from document_renderer import DocumentRenderer 8 from document_renderer import DocumentRenderer
9 from server_instance import ServerInstance 9 from server_instance import ServerInstance
10 from test_file_system import TestFileSystem 10 from test_file_system import TestFileSystem
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 109
110 text, warnings = self._renderer.Render(document, path) 110 text, warnings = self._renderer.Render(document, path)
111 self.assertEqual(expected_document, text) 111 self.assertEqual(expected_document, text)
112 self.assertEqual([], warnings) 112 self.assertEqual([], warnings)
113 113
114 text, warnings = self._renderer.Render(document, path, render_title=True) 114 text, warnings = self._renderer.Render(document, path, render_title=True)
115 self.assertEqual(expected_document, text) 115 self.assertEqual(expected_document, text)
116 self.assertEqual(['Expected a title'], warnings) 116 self.assertEqual(['Expected a title'], warnings)
117 117
118 def testInvalidRef(self): 118 def testInvalidRef(self):
119 # There needs to be more than 100 characters between the invalid ref 119 # DocumentRenderer attempts to detect unclosed $(ref:...) tags by limiting
120 # and the next ref 120 # how far it looks ahead. Lorem Ipsum should be long enough to trigger that.
121 document = ('An invalid $(ref:foo.foo_t3 a title with some long ' 121 _LOREM_IPSUM = (
122 'text containing a valid reference pointing to ' 122 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do '
123 'eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim '
124 'ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut '
125 'aliquip ex ea commodo consequat. Duis aute irure dolor in '
126 'reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla '
127 'pariatur. Excepteur sint occaecat cupidatat non proident, sunt in '
128 'culpa qui officia deserunt mollit anim id est laborum.')
129 document = ('An invalid $(ref:foo.foo_t3 a title ' + _LOREM_IPSUM +
123 '$(ref:baz.baz_e1) here') 130 '$(ref:baz.baz_e1) here')
124 expected_document = ('An invalid $(ref:foo.foo_t3 a title with some long ' 131 expected_document = ('An invalid $(ref:foo.foo_t3 a title ' + _LOREM_IPSUM +
125 'text containing a valid reference pointing to <a' 132 '<a href=#type-baz_e1>baz.baz_e1</a> here')
126 ' href=#type-baz_e1>baz.baz_e1</a> here')
127 path = 'some/path/to/document_api.html' 133 path = 'some/path/to/document_api.html'
128 134
129 text, warnings = self._renderer.Render(document, path) 135 text, warnings = self._renderer.Render(document, path)
130 self.assertEqual(expected_document, text) 136 self.assertEqual(expected_document, text)
131 self.assertEqual([], warnings) 137 self.assertEqual([], warnings)
132 138
133 text, warnings = self._renderer.Render(document, path, render_title=True) 139 text, warnings = self._renderer.Render(document, path, render_title=True)
134 self.assertEqual(expected_document, text) 140 self.assertEqual(expected_document, text)
135 self.assertEqual(['Expected a title'], warnings) 141 self.assertEqual(['Expected a title'], warnings)
136 142
137 143
138 if __name__ == '__main__': 144 if __name__ == '__main__':
139 unittest.main() 145 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698