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 extensions_paths import EXAMPLES, PUBLIC_TEMPLATES, STATIC_DOCS | 8 from extensions_paths import EXAMPLES, PUBLIC_TEMPLATES, STATIC_DOCS |
9 from local_file_system import LocalFileSystem | 9 from local_file_system import LocalFileSystem |
10 from render_servlet import RenderServlet | 10 from render_servlet import RenderServlet |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 def testHtmlTemplate(self): | 88 def testHtmlTemplate(self): |
89 html_file = 'extensions/storage' | 89 html_file = 'extensions/storage' |
90 response = self._Render(html_file) | 90 response = self._Render(html_file) |
91 self.assertEqual(200, response.status) | 91 self.assertEqual(200, response.status) |
92 self.assertEqual('text/html; charset=utf-8', | 92 self.assertEqual('text/html; charset=utf-8', |
93 response.headers.get('Content-Type')) | 93 response.headers.get('Content-Type')) |
94 # Can't really test rendering all that well. | 94 # Can't really test rendering all that well. |
95 self.assertTrue(len(response.content) > | 95 self.assertTrue(len(response.content) > |
96 len(ReadFile('%s%s.html' % (PUBLIC_TEMPLATES, html_file)))) | 96 len(ReadFile('%s%s.html' % (PUBLIC_TEMPLATES, html_file)))) |
97 | 97 |
98 def testIndexRedirect(self): | 98 def testIndexRender(self): |
99 response = self._Render('extensions') | 99 response = self._Render('extensions') |
100 self.assertEqual(('/extensions/index', False), | 100 self.assertEqual(200, response.status) |
101 response.GetRedirect()) | 101 self.assertEqual(self._Render('extensions/index').content.ToString(), |
| 102 response.content.ToString()) |
102 | 103 |
103 def testOtherRedirectsJsonRedirect(self): | 104 def testOtherRedirectsJsonRedirect(self): |
104 response = self._Render('apps/webview_tag') | 105 response = self._Render('apps/webview_tag') |
105 self.assertEqual(('/apps/tags/webview', False), | 106 self.assertEqual(('/apps/tags/webview', False), |
106 response.GetRedirect()) | 107 response.GetRedirect()) |
107 | 108 |
108 def testDirectories(self): | 109 def testDirectories(self): |
109 # Directories should be redirected to a URL that doesn't end in a '/' | 110 # Directories should be redirected to a URL that doesn't end in a '/' |
110 # whether or not that exists. | 111 # whether or not that exists. |
111 self.assertEqual(('/dir', False), self._Render('dir/').GetRedirect()) | 112 self.assertEqual(('/dir', False), self._Render('dir/').GetRedirect()) |
(...skipping 23 matching lines...) Expand all Loading... |
135 self.assertEqual(content_type, response.headers.get('Content-Type')) | 136 self.assertEqual(content_type, response.headers.get('Content-Type')) |
136 self.assertEqual(etag, response.headers.get('ETag')) | 137 self.assertEqual(etag, response.headers.get('ETag')) |
137 | 138 |
138 # Test with a static path and a dynamic path. | 139 # Test with a static path and a dynamic path. |
139 test_path('static/css/out/site.css', 'text/css; charset=utf-8') | 140 test_path('static/css/out/site.css', 'text/css; charset=utf-8') |
140 test_path('extensions/storage', 'text/html; charset=utf-8') | 141 test_path('extensions/storage', 'text/html; charset=utf-8') |
141 | 142 |
142 | 143 |
143 if __name__ == '__main__': | 144 if __name__ == '__main__': |
144 unittest.main() | 145 unittest.main() |
OLD | NEW |