Ejemplo n.º 1
0
 def test_direct_instantiation(self):
     """
     It should be possible to use the view without going through .as_view()
     (#21564).
     """
     view = RedirectView()
     response = view.dispatch(self.rf.head('/foo/'))
     self.assertEqual(response.status_code, 410)
Ejemplo n.º 2
0
 def test_direct_instantiation(self):
     """
     It should be possible to use the view without going through .as_view()
     (#21564).
     """
     view = RedirectView()
     response = view.dispatch(self.rf.head('/foo/'))
     self.assertEqual(response.status_code, 410)
Ejemplo n.º 3
0
    def test_deprecation_warning_init(self):
        with warnings.catch_warnings(record=True) as warns:
            warnings.simplefilter('always')

            view = RedirectView()
            response = view.dispatch(self.rf.head('/python/'))

        self.assertEqual(response.status_code, 410)
        self.assertEqual(len(warns), 1)
        self.assertIs(warns[0].category, RemovedInDjango19Warning)
        self.assertEqual(
            six.text_type(warns[0].message),
            "Default value of 'RedirectView.permanent' will change "
            "from True to False in Django 1.9. Set an explicit value "
            "to silence this warning.",
        )
Ejemplo n.º 4
0
    def test_deprecation_warning_init(self):
        with warnings.catch_warnings(record=True) as warns:
            warnings.simplefilter('always')

            view = RedirectView()
            response = view.dispatch(self.rf.head('/python/'))

        self.assertEqual(response.status_code, 410)
        self.assertEqual(len(warns), 1)
        self.assertIs(warns[0].category, RemovedInDjango19Warning)
        self.assertEqual(
            six.text_type(warns[0].message),
            "Default value of 'RedirectView.permanent' will change "
            "from True to False in Django 1.9. Set an explicit value "
            "to silence this warning.",
        )
Ejemplo n.º 5
0
 def dispatch(self, request, *args, **kwargs):
     return RedirectView.dispatch(self, request, *args, **kwargs)