def test_replaceErrorPage(self): """``replaceErrorPage`` should return the error-500.html page.""" request = DummyRequest(['']) exc = Exception("Under Maintenance") errorPage = server.replaceErrorPage(request, exc) self.assertSubstring(b"Internal Error", errorPage) self.assertNotSubstring("Under Maintenance".encode("utf-8"), errorPage)
def test_replaceErrorPage_matches_resource500(self): """``replaceErrorPage`` should return the error-500.html page.""" request = DummyRequest(['']) exc = Exception("Under Maintenance") errorPage = server.replaceErrorPage(request, exc) error500Page = server.resource500.render(request) self.assertEqual(errorPage, error500Page)
def test_replaceErrorPage(self): """``replaceErrorPage`` should return the error-500.html page.""" request = DummyRequest(['']) exc = Exception("vegan gümmibären") errorPage = server.replaceErrorPage(request, exc) self.assertSubstring(b"Bad News Bears", errorPage) self.assertNotSubstring("vegan gümmibären".encode("utf-8"), errorPage)
def test_replaceErrorPage_matches_resource500(self): """``replaceErrorPage`` should return the error-500.html page.""" request = DummyRequest(['']) exc = Exception("vegan gümmibären") errorPage = server.replaceErrorPage(request, exc) error500Page = server.resource500.render(request) self.assertEqual(errorPage, error500Page)
def test_replaceErrorPage(self): """``replaceErrorPage`` should return the error-500.html page.""" request = DummyRequest(['']) exc = Exception("vegan gümmibären") errorPage = server.replaceErrorPage(request, exc) self.assertSubstring("Bad News Bears", errorPage) self.assertNotSubstring("vegan gümmibären", errorPage)
def test_replaceErrorPage_no_resource500(self): """If ``server.resource500`` is missing/broken, then ``replaceErrorPage`` should return custom hardcoded HTML error text. """ request = DummyRequest(['']) exc = Exception("Error while rendering") server.resource500 = None errorPage = server.replaceErrorPage(request, exc) self.assertNotSubstring(b"Bad Request", errorPage) self.assertNotSubstring("Under Maintenance".encode("utf-8"), errorPage) self.assertSubstring(b"Sorry! Something went wrong with your request.", errorPage)
def test_replaceErrorPage_no_resource500(self): """If ``server.resource500`` is missing/broken, then ``replaceErrorPage`` should return custom hardcoded HTML error text. """ request = DummyRequest(['']) exc = Exception("vegan gümmibären") server.resource500 = None errorPage = server.replaceErrorPage(request, exc) self.assertNotSubstring("Bad News Bears", errorPage) self.assertNotSubstring("vegan gümmibären", errorPage) self.assertSubstring("Sorry! Something went wrong with your request.", errorPage)
def test_replaceErrorPage_no_resource500(self): """If ``server.resource500`` is missing/broken, then ``replaceErrorPage`` should return custom hardcoded HTML error text. """ request = DummyRequest(['']) exc = Exception("vegan gümmibären") server.resource500 = None errorPage = server.replaceErrorPage(request, exc) self.assertNotSubstring("Bad News Bears", errorPage) self.assertNotSubstring("vegan gümmibären", errorPage) self.assertSubstring("Sorry! Something went wrong with your request.", errorPage)
def test_render_GET_missingTemplate(self): """render_GET() with a missing template should raise an error and return the result of replaceErrorPage(). """ oldLookup = server.lookup try: server.lookup = None self.request.method = b'GET' page = self.captchaResource.render_GET(self.request) errorPage = server.replaceErrorPage(self.request, Exception('kablam')) self.assertEqual(page, errorPage) finally: server.lookup = oldLookup
def test_render_GET_missingTemplate(self): """render_GET() with a missing template should raise an error and return the result of replaceErrorPage(). """ oldLookup = server.lookup try: server.lookup = None self.request.method = b'GET' page = self.captchaResource.render_GET(self.request) errorPage = server.replaceErrorPage(self.request, Exception('kablam')) self.assertEqual(page, errorPage) finally: server.lookup = oldLookup