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

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

Issue 93743005: Support markdown template for html editor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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
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 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 test_file_system import TestFileSystem 15 from test_file_system import TestFileSystem
16 from third_party.handlebar import Handlebar 16 from third_party.handlebar import Handlebar
17 17
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
not at google - send to devlin 2013/12/20 03:56:43 leave this
hukun 2013/12/20 07:41:53 Done
25 # Test file system data which exercises many different mimetypes. 24 # Test file system data which exercises many different mimetypes.
26 _TEST_DATA = { 25 _TEST_DATA = {
27 'dir': { 26 'dir': {
28 'a.txt': 'a.txt content', 27 'a.txt': 'a.txt content',
29 'b.txt': 'b.txt content', 28 'b.txt': 'b.txt content',
30 'c': { 29 'c': {
31 'd.txt': 'd.txt content', 30 'd.txt': 'd.txt content',
32 }, 31 },
33 }, 32 },
34 'dir2': { 33 'dir2': {
35 'dir3': { 34 'dir3': {
36 'a.txt': 'a.txt content', 35 'a.txt': 'a.txt content',
37 'b.txt': 'b.txt content', 36 'b.txt': 'b.txt content',
38 'c': { 37 'c': {
39 'd.txt': 'd.txt content', 38 'd.txt': 'd.txt content',
40 }, 39 },
41 }, 40 },
42 }, 41 },
43 'img.png': 'img.png content', 42 'img.png': 'img.png content',
44 'read.txt': 'read.txt content', 43 'read.txt': 'read.txt content',
45 'redirects.json': _REDIRECTS_JSON, 44 'redirects.json': _REDIRECTS_JSON,
46 'run.js': 'run.js content', 45 'run.js': 'run.js content',
47 'site.css': 'site.css content', 46 'site.css': 'site.css content',
48 'storage.html': 'storage.html content', 47 'storage.html': 'storage.html content',
48 'markdown.md': 'markdown content'
49 } 49 }
50 50
51 51
52 class ContentProviderUnittest(unittest.TestCase): 52 class ContentProviderUnittest(unittest.TestCase):
53 def setUp(self): 53 def setUp(self):
54 self._content_provider = self._CreateContentProvider() 54 self._content_provider = self._CreateContentProvider()
55 55
56 def _CreateContentProvider(self, supports_zip=False): 56 def _CreateContentProvider(self, supports_zip=False):
57 test_file_system = TestFileSystem(_TEST_DATA) 57 test_file_system = TestFileSystem(_TEST_DATA)
58 return ContentProvider( 58 return ContentProvider(
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 def testZip2ndLevel(self): 113 def testZip2ndLevel(self):
114 zip_content_provider = self._CreateContentProvider(supports_zip=True) 114 zip_content_provider = self._CreateContentProvider(supports_zip=True)
115 content_and_type = zip_content_provider.GetContentAndType( 115 content_and_type = zip_content_provider.GetContentAndType(
116 'dir2/dir3.zip').Get() 116 'dir2/dir3.zip').Get()
117 zipfile = ZipFile(StringIO(content_and_type.content)) 117 zipfile = ZipFile(StringIO(content_and_type.content))
118 content_and_type.content = zipfile.namelist() 118 content_and_type.content = zipfile.namelist()
119 self._assertContent( 119 self._assertContent(
120 ['dir3/a.txt', 'dir3/b.txt', 'dir3/c/d.txt'], 'application/zip', 120 ['dir3/a.txt', 'dir3/b.txt', 'dir3/c/d.txt'], 'application/zip',
121 content_and_type) 121 content_and_type)
122 122
123 def testMarkdown(self):
124 content_and_type = self._content_provider.GetContentAndType(
125 'markdown.html').Get()
126 content_and_type.content = content_and_type.content.source
127 self._assertContent(u'<p>markdown content</p>', 'text/html',
128 content_and_type)
129
123 def testNotFound(self): 130 def testNotFound(self):
124 self.assertRaises( 131 self.assertRaises(
125 FileNotFoundError, 132 FileNotFoundError,
126 self._content_provider.GetContentAndType('oops').Get) 133 self._content_provider.GetContentAndType('oops').Get)
127 134
128 135
129 if __name__ == '__main__': 136 if __name__ == '__main__':
130 unittest.main() 137 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698