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

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

Issue 15087006: Docserver: there is only one. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: epic rebase Created 7 years, 5 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 | 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 import unittest 6 import unittest
7 7
8 from local_file_system import LocalFileSystem 8 from local_file_system import LocalFileSystem
9 from render_servlet import RenderServlet 9 from render_servlet import RenderServlet
10 from server_instance import ServerInstance 10 from server_instance import ServerInstance
11 from servlet import Request 11 from servlet import Request, Response
12 from test_util import DisableLogging, ReadFile 12 from test_util import DisableLogging, ReadFile
13 13
14 class _RenderServletDelegate(RenderServlet.Delegate): 14 class _RenderServletDelegate(RenderServlet.Delegate):
15 def CreateServerInstanceForChannel(self, channel): 15 def CreateServerInstance(self):
16 return ServerInstance.ForTest(LocalFileSystem.Create()) 16 return ServerInstance.ForTest(LocalFileSystem.Create())
17 17
18 class RenderServletTest(unittest.TestCase): 18 class RenderServletTest(unittest.TestCase):
19 def testExtensionAppRedirect(self): 19 def testExtensionAppRedirect(self):
20 request = Request.ForTest('storage.html') 20 request = Request.ForTest('storage.html')
21 response = RenderServlet(request, _RenderServletDelegate()).Get() 21 self.assertEqual(
22 self.assertEqual(302, response.status) 22 Response.Redirect('/extensions/storage.html', permanent=False),
23 RenderServlet(request, _RenderServletDelegate()).Get())
23 24
24 def testDefaultChannel(self): 25 def testChannelRedirect(self):
25 request = Request.ForTest('stable/extensions/storage.html') 26 request = Request.ForTest('stable/extensions/storage.html')
26 response = RenderServlet(request, _RenderServletDelegate()).Get() 27 self.assertEqual(
27 self.assertEqual(302, response.status) 28 Response.Redirect('/extensions/storage.html', permanent=True),
29 RenderServlet(request, _RenderServletDelegate()).Get())
28 30
29 @DisableLogging('warning') 31 @DisableLogging('warning')
30 def testNotFound(self): 32 def testNotFound(self):
31 request = Request.ForTest('extensions/not_found.html') 33 request = Request.ForTest('extensions/not_found.html')
32 response = RenderServlet(request, _RenderServletDelegate()).Get() 34 response = RenderServlet(request, _RenderServletDelegate()).Get()
33 self.assertEqual(404, response.status) 35 self.assertEqual(404, response.status)
34 36
35 def testSampleFile(self): 37 def testSampleFile(self):
36 sample_file = 'extensions/talking_alarm_clock/background.js' 38 sample_file = 'extensions/talking_alarm_clock/background.js'
37 request = Request.ForTest('extensions/examples/%s' % sample_file) 39 request = Request.ForTest('extensions/examples/%s' % sample_file)
(...skipping 26 matching lines...) Expand all
64 request = Request.ForTest(html_file) 66 request = Request.ForTest(html_file)
65 response = RenderServlet(request, _RenderServletDelegate()).Get() 67 response = RenderServlet(request, _RenderServletDelegate()).Get()
66 self.assertEqual(200, response.status) 68 self.assertEqual(200, response.status)
67 self.assertEqual('text/html', response.headers.get('content-type')) 69 self.assertEqual('text/html', response.headers.get('content-type'))
68 # Can't really test rendering all that well. 70 # Can't really test rendering all that well.
69 self.assertTrue(len(response.content) > 71 self.assertTrue(len(response.content) >
70 len(ReadFile('docs/templates/public/%s' % html_file))) 72 len(ReadFile('docs/templates/public/%s' % html_file)))
71 73
72 if __name__ == '__main__': 74 if __name__ == '__main__':
73 unittest.main() 75 unittest.main()
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/render_servlet.py ('k') | chrome/common/extensions/docs/server2/rietveld_patcher.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698