| Index: chrome/common/extensions/docs/server2/patch_servlet_test.py
|
| diff --git a/chrome/common/extensions/docs/server2/patch_servlet_test.py b/chrome/common/extensions/docs/server2/patch_servlet_test.py
|
| index 6bde0e1978b97a96fe354b5425b56c55e9c93ae8..ee4718dfe8d19c68af098278c631a94690a1f793 100755
|
| --- a/chrome/common/extensions/docs/server2/patch_servlet_test.py
|
| +++ b/chrome/common/extensions/docs/server2/patch_servlet_test.py
|
| @@ -17,14 +17,14 @@ from test_util import DisableLogging
|
| _ALLOWED_HOST = 'https://chrome-apps-doc.appspot.com'
|
|
|
| class _RenderServletDelegate(RenderServlet.Delegate):
|
| - def CreateServerInstanceForChannel(self, channel):
|
| + def CreateServerInstance(self):
|
| return ServerInstance.ForLocal()
|
|
|
| class _PatchServletDelegate(RenderServlet.Delegate):
|
| def CreateAppSamplesFileSystem(self, object_store_creator):
|
| return EmptyDirFileSystem()
|
|
|
| - def CreateHostFileSystemForBranch(self, channel):
|
| + def CreateHostFileSystem(self):
|
| return LocalFileSystem.Create()
|
|
|
| class PatchServletTest(unittest.TestCase):
|
| @@ -32,8 +32,8 @@ class PatchServletTest(unittest.TestCase):
|
| ConfigureFakeFetchers()
|
|
|
| def _RenderWithPatch(self, path, issue):
|
| - real_path = '%s/%s' % (issue, path)
|
| - return PatchServlet(Request.ForTest(real_path, host=_ALLOWED_HOST),
|
| + path_with_issue = '%s/%s' % (issue, path)
|
| + return PatchServlet(Request.ForTest(path_with_issue, host=_ALLOWED_HOST),
|
| _PatchServletDelegate()).Get()
|
|
|
| def _RenderWithoutPatch(self, path):
|
| @@ -64,8 +64,10 @@ class PatchServletTest(unittest.TestCase):
|
|
|
| @DisableLogging('warning')
|
| def _AssertNotFound(self, path, issue):
|
| - self.assertEqual(self._RenderWithPatch(path, issue).status, 404,
|
| - 'Path %s with issue %s should have been removed.' % (path, issue))
|
| + response = self._RenderWithPatch(path, issue)
|
| + self.assertEqual(response.status, 404,
|
| + 'Path %s with issue %s should have been removed for %s.' % (
|
| + path, issue, response))
|
|
|
| def _AssertOk(self, path, issue):
|
| response = self._RenderWithPatch(path, issue)
|
| @@ -75,17 +77,27 @@ class PatchServletTest(unittest.TestCase):
|
| 'Rendered result for path %s with issue %s should not be empty.' %
|
| (path, issue))
|
|
|
| + def _AssertRedirect(self, path, issue, redirect_path):
|
| + response = self._RenderWithPatch(path, issue)
|
| + self.assertEqual(302, response.status)
|
| + self.assertEqual('/_patch/%s/%s' % (issue, redirect_path),
|
| + response.headers['Location'])
|
| +
|
| def testRender(self):
|
| # '_patch' is not included in paths below because it's stripped by Handler.
|
| issue = '14096030'
|
|
|
| # extensions_sidenav.json is modified in the patch.
|
| self._RenderAndAssertNotEqual('extensions/index.html', issue)
|
| +
|
| # apps_sidenav.json is not patched.
|
| self._RenderAndAssertEqual('apps/about_apps.html', issue)
|
|
|
| - # extensions/runtime.html is removed in the patch.
|
| - self._AssertNotFound('extensions/runtime.html', issue)
|
| + # extensions/runtime.html is removed in the patch, should redirect to the
|
| + # apps version.
|
| + self._AssertRedirect('extensions/runtime.html', issue,
|
| + 'apps/runtime.html')
|
| +
|
| # apps/runtime.html is not removed.
|
| self._RenderAndAssertEqual('apps/runtime.html', issue)
|
|
|
|
|