def test_redirect_exceptions(self): """ Unit tests for handling of Redirect exceptions. """ request = RequestFactory().get("dummy_url") test_url = '/test_url' exception = Redirect(test_url) response = RedirectMiddleware().process_exception(request, exception) self.assertEqual(response.status_code, 302) target_url = response._headers['location'][1] self.assertTrue(target_url.endswith(test_url))
def test_redirect_exceptions(self): """ Unit tests for handling of Redirect exceptions. """ request = RequestFactory().get("dummy_url") test_url = '/test_url' exception = Redirect(test_url) response = RedirectMiddleware().process_exception(request, exception) assert response.status_code == 302 target_url = response._headers['location'][1] # lint-amnesty, pylint: disable=protected-access assert target_url.endswith(test_url)
def test_redirect_exceptions(self): """ Unit tests for handling of Redirect exceptions. """ request = RequestFactory().get("dummy_url") test_url = '/test_url' exception = Redirect(test_url) response = RedirectMiddleware().process_exception(request, exception) assert response.status_code == 302 headers = self.get_headers(response) target_url = headers['location'][1] assert target_url.endswith(test_url)
def test_process_404(self): """A 404 should not trigger anything""" request = RequestFactory().get("dummy_url") response = RedirectMiddleware().process_exception(request, Http404()) self.assertIsNone(response)