cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / chrome / common / extensions / docs / server2 / instance_servlet_test.py
blob52e6063c11792abd9b378cc34f04e3a3d4926c1a
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
6 import unittest
8 from instance_servlet import InstanceServlet
9 from servlet import Request
10 from fail_on_access_file_system import FailOnAccessFileSystem
11 from test_branch_utility import TestBranchUtility
12 from test_util import DisableLogging
14 # NOTE(kalman): The ObjectStore created by the InstanceServlet is backed onto
15 # our fake AppEngine memcache/datastore, so the tests aren't isolated.
16 class _TestDelegate(InstanceServlet.Delegate):
17 def __init__(self, file_system_type):
18 self._file_system_type = file_system_type
20 def CreateBranchUtility(self, object_store_creator):
21 return TestBranchUtility.CreateWithCannedData()
23 def CreateGithubFileSystemProvider(self, object_store_creator):
24 return GithubFileSystemProvider.ForEmpty()
26 class InstanceServletTest(unittest.TestCase):
27 '''Tests that if the file systems underlying the docserver's data fail,
28 the instance servlet still returns 404s or 301s with a best-effort.
29 It should never return a 500 (i.e. crash).
30 '''
32 @DisableLogging('warning')
33 def testHostFileSystemNotAccessed(self):
34 delegate = _TestDelegate(FailOnAccessFileSystem)
35 constructor = InstanceServlet.GetConstructor(delegate_for_test=delegate)
36 def test_path(path, status=404):
37 response = constructor(Request.ForTest(path)).Get()
38 self.assertEqual(status, response.status)
39 test_path('extensions/storage.html')
40 test_path('apps/storage.html')
41 test_path('extensions/examples/foo.zip')
42 test_path('extensions/examples/foo.html')
43 test_path('static/foo.css')
44 test_path('beta/extensions/storage.html', status=301)
45 test_path('beta/apps/storage.html', status=301)
46 test_path('beta/extensions/examples/foo.zip', status=301)
47 test_path('beta/extensions/examples/foo.html', status=301)
48 test_path('beta/static/foo.css', status=301)
50 if __name__ == '__main__':
51 unittest.main()