示例#1
0
    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")
示例#2
0
    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/")