Ejemplo n.º 1
0
    def test_no_content_type_set(self):
        "Request does not have a Content-Type set"
        test_request = DummyRequest()

        outer_wrap = webapi.json_arguments([("arg1", unicode)])
        inner_wrap = outer_wrap(self.dummy_render_func)
        self.assertEqual(str(webapi.ContentTypeError(test_request)),
                         inner_wrap(self, test_request))
Ejemplo n.º 2
0
    def test_no_content_type_set(self):
        "Request does not have a Content-Type set"
        test_request = DummyRequest()

        outer_wrap = webapi.url_arguments(["arg1"], "application/json")
        inner_wrap = outer_wrap(self.dummy_render_func)
        self.assertEqual(str(webapi.ContentTypeError(test_request)),
                         inner_wrap(self, test_request))
Ejemplo n.º 3
0
 def test_content_type_content_type_mismatch(self):
     "Request Content-Type doesn't match expected type."
     test_request = DummyRequest()
     test_request.setHeader("Content-Type", "image/jpeg; charset=utf-8")
     outer_wrap = webapi.json_arguments([("arg1", unicode)],
                                        content_type="application/json")
     inner_wrap = outer_wrap(self.dummy_render_func)
     self.assertEqual(str(webapi.ContentTypeError(test_request)),
                      inner_wrap(self, test_request))
Ejemplo n.º 4
0
    def test_content_type_error(self):
        "Validate ContentTypeError"
        request = DummyRequest()
        obj_error = webapi.ContentTypeError(request)

        self.assertEquals(obj_error.error_code, 503)
        self.assertEquals(obj_error.exception_class, "ContentTypeError")
        self.assertEquals(obj_error.exception_text , "The Content-Type of the API request was not of the expected " + \
                                        "format...or the API/version requested does not exist.")
        self.assertEquals(request.response_code, 406)