Exemplo n.º 1
0
 def request(self, method, data=None, **kwargs):
     if getattr(settings, 'RUBBER_MOCK_HTTP_RESPONSE', False):
         return self.wrapper(ResponseMock(settings.RUBBER_MOCK_HTTP_RESPONSE))
     path = self.base_url + self.path
     try:
         response = requests.request(method, path, data=data_to_json(data), **kwargs)
     except Exception, e:
         if self.raise_on_error:
             raise
         import logging
         logging.exception('Could not perform %s %s' % (method.upper(), path))
         return None
Exemplo n.º 2
0
 def request(self, method, data=None, **kwargs):
     if getattr(settings, 'RUBBER_MOCK_HTTP_RESPONSE', False):
         return self.wrapper(
             ResponseMock(settings.RUBBER_MOCK_HTTP_RESPONSE))
     path = self.base_url + self.path
     try:
         response = requests.request(method,
                                     path,
                                     data=data_to_json(data),
                                     **kwargs)
     except Exception, e:
         if self.raise_on_error:
             raise
         import logging
         logging.exception('Could not perform %s %s' %
                           (method.upper(), path))
         return None
Exemplo n.º 3
0
 def delete(self, data=None, **kwargs):
     mock = getattr(settings, 'RUBBER_MOCK_HTTP_RESPONSE', None)
     if mock: return self.wrapper(ResponseMock(mock))
     return self.wrapper(requests.delete(self.base_url + self.path, data=data_to_json(data), **kwargs))