Beispiel #1
0
    def test_misconfigured(self):
        view_obj = ErrorView()

        with self.assertRaises(ImproperlyConfigured):
            view_obj.get_error_message()

        with self.assertRaises(ImproperlyConfigured):
            view_obj.get_error_code()
Beispiel #2
0
    def test_view(self):
        view_func = ErrorView.as_view(error_message="some message or other",
                                      error_code=499,
                                      headline="some headline")

        request = RequestFactory().get("/")
        response = view_func(request)

        self.assertEqual(response.status_code, 499)
        self.assertIn("some message or other", str(response.content))
        self.assertIn("some headline", str(response.content))
Beispiel #3
0
    def test_view(self):
        view_func = ErrorView.as_view(
            error_message="some message or other",
            error_code=499,
            headline="some headline"
        )

        request = RequestFactory().get("/")
        response = view_func(request)

        self.assertEqual(response.status_code, 499)
        self.assertIn("some message or other", str(response.content))
        self.assertIn("some headline", str(response.content))
Beispiel #4
0
    def test_misconfigured(self):
        view_obj = ErrorView()

        with self.assertRaises(ImproperlyConfigured):
            view_obj.get_error_message()

        with self.assertRaises(ImproperlyConfigured):
            view_obj.get_error_code()