| OLD | NEW |
| 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 Loading... |
| 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() |
| OLD | NEW |