Esempio n. 1
0
    def test_request_deserializer_get_action_args(self):
        self.request_deserializer = wsgi.RequestDeserializer()
        request_environment = []
        result = self.request_deserializer.get_action_args(request_environment)
        self.assertEqual({}, result)

        request_environment = {'wsgiorg.routing_args': ["", {}]}
        result = self.request_deserializer.get_action_args(request_environment)
        self.assertEqual({}, result)
Esempio n. 2
0
def create_resource():
    specific_content_types = {
        'get_ui': ['text/plain'],
        'download': ['application/octet-stream'],
        'get_logo': ['application/octet-stream'],
        'get_supplier_logo': ['application/octet-stream']
    }
    deserializer = wsgi.RequestDeserializer(
        specific_content_types=specific_content_types)
    return wsgi.Resource(Controller(), deserializer=deserializer)
Esempio n. 3
0
    def test_request_deserializer_deserialize_body(self):
        self.request_deserializer = wsgi.RequestDeserializer()
        request = mock.Mock()
        request.get_content_type.side_effect = (
            exceptions.UnsupportedContentType)
        request.body = "body"
        self.assertRaises(exceptions.UnsupportedContentType,
                          self.request_deserializer.deserialize_body, request,
                          "act")

        request.get_content_type.side_effect = None
        request.get_content_type.return_value = None
        result = self.request_deserializer.deserialize_body(request, "act")
        self.assertEqual({}, result)

        request.get_content_type.return_value = ""
        self.assertRaises(exceptions.UnsupportedContentType,
                          self.request_deserializer.deserialize_body, request,
                          "act")