示例#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
示例#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
示例#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))