def test_include_args(self): view = RedirectView.as_view(url="/redirect/", query_string=True) request = Request("/test/") request.META = {"QUERY_STRING": "foo=bar"} response = view(request) self.assertEqual(response.status_code, 301) self.assertEqual(response.headers["Location"], "/redirect/?foo=bar")
def test_tempoary_redirect(self): view = RedirectView.as_view(url="/redirect/", permanent=False) request = Request() request.META = {"QUERY_STRING": ""} response = view(request) self.assertEqual(response.status_code, 302) self.assertEqual(response.headers["Location"], "/redirect/")