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 from cStringIO import StringIO | 6 from cStringIO import StringIO |
7 import json | 7 import json |
8 import unittest | 8 import unittest |
9 from zipfile import ZipFile | 9 from zipfile import ZipFile |
10 | 10 |
11 from compiled_file_system import CompiledFileSystem | 11 from compiled_file_system import CompiledFileSystem |
12 from content_provider import ContentProvider | 12 from content_provider import ContentProvider |
13 from file_system import FileNotFoundError | 13 from file_system import FileNotFoundError |
14 from object_store_creator import ObjectStoreCreator | 14 from object_store_creator import ObjectStoreCreator |
15 from path_canonicalizer import PathCanonicalizer | 15 from path_canonicalizer import PathCanonicalizer |
16 from test_file_system import TestFileSystem | 16 from test_file_system import TestFileSystem |
17 from third_party.handlebar import Handlebar | 17 from third_party.motemplate import Motemplate |
18 | 18 |
19 _REDIRECTS_JSON = json.dumps({ | 19 _REDIRECTS_JSON = json.dumps({ |
20 'oldfile.html': 'storage.html', | 20 'oldfile.html': 'storage.html', |
21 'index.html': 'https://developers.google.com/chrome', | 21 'index.html': 'https://developers.google.com/chrome', |
22 }) | 22 }) |
23 | 23 |
24 | 24 |
25 _MARKDOWN_CONTENT = ( | 25 _MARKDOWN_CONTENT = ( |
26 ('# Header 1 #', u'<h1 id="header-1">Header 1</h1>'), | 26 ('# Header 1 #', u'<h1 id="header-1">Header 1</h1>'), |
27 ('1. Foo\n', u'<ol>\n<li>Foo</li>\n</ol>'), | 27 ('1. Foo\n', u'<ol>\n<li>Foo</li>\n</ol>'), |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 supports_zip=supports_zip) | 92 supports_zip=supports_zip) |
93 | 93 |
94 def _assertContent(self, content, content_type, content_and_type): | 94 def _assertContent(self, content, content_type, content_and_type): |
95 # Assert type so that str is differentiated from unicode. | 95 # Assert type so that str is differentiated from unicode. |
96 self.assertEqual(type(content), type(content_and_type.content)) | 96 self.assertEqual(type(content), type(content_and_type.content)) |
97 self.assertEqual(content, content_and_type.content) | 97 self.assertEqual(content, content_and_type.content) |
98 self.assertEqual(content_type, content_and_type.content_type) | 98 self.assertEqual(content_type, content_and_type.content_type) |
99 | 99 |
100 def _assertTemplateContent(self, content, path, version): | 100 def _assertTemplateContent(self, content, path, version): |
101 content_and_type = self._content_provider.GetContentAndType(path).Get() | 101 content_and_type = self._content_provider.GetContentAndType(path).Get() |
102 self.assertEqual(Handlebar, type(content_and_type.content)) | 102 self.assertEqual(Motemplate, type(content_and_type.content)) |
103 content_and_type.content = content_and_type.content.source | 103 content_and_type.content = content_and_type.content.source |
104 self._assertContent(content, 'text/html', content_and_type) | 104 self._assertContent(content, 'text/html', content_and_type) |
105 self.assertEqual(version, self._content_provider.GetVersion(path).Get()) | 105 self.assertEqual(version, self._content_provider.GetVersion(path).Get()) |
106 | 106 |
107 def _assertMarkdownContent(self, content, path, version): | 107 def _assertMarkdownContent(self, content, path, version): |
108 content_and_type = self._content_provider.GetContentAndType(path).Get() | 108 content_and_type = self._content_provider.GetContentAndType(path).Get() |
109 content_and_type.content = content_and_type.content.source | 109 content_and_type.content = content_and_type.content.source |
110 self._assertContent(content, 'text/html', content_and_type) | 110 self._assertContent(content, 'text/html', content_and_type) |
111 self.assertEqual(version, self._content_provider.GetVersion(path).Get()) | 111 self.assertEqual(version, self._content_provider.GetVersion(path).Get()) |
112 | 112 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 FileNotFoundError, | 203 FileNotFoundError, |
204 self._content_provider.GetContentAndType('dir6').Get) | 204 self._content_provider.GetContentAndType('dir6').Get) |
205 | 205 |
206 def testCron(self): | 206 def testCron(self): |
207 # Not entirely sure what to test here, but get some code coverage. | 207 # Not entirely sure what to test here, but get some code coverage. |
208 self._content_provider.Cron().Get() | 208 self._content_provider.Cron().Get() |
209 | 209 |
210 | 210 |
211 if __name__ == '__main__': | 211 if __name__ == '__main__': |
212 unittest.main() | 212 unittest.main() |
OLD | NEW |