コード例 #1
0
ファイル: views.py プロジェクト: duisetsuna/django-slumber
def _perform(client, method, url, data, content_type=None):
    def method_wrapper(*a, **kw):
        logging.info("Using wrapped GET handler")
        return client.get(*a, REQUEST_METHOD=method.upper(), **kw)
    logging.info("%s with data %s", method, data)
    headers = _calculate_signature('service', method.upper(), url, data, None, True)
    response = getattr(client, method, method_wrapper)(
        url, data, content_type=content_type, **headers)
    if response.status_code == 200:
        return response, loads(response.content)
    else:
        return response, {}
コード例 #2
0
ファイル: views.py プロジェクト: tcarlander/django-slumber
def _perform(client, method, url, data, content_type=None, username=None):
    def method_wrapper(*a, **kw):
        logging.info("Using wrapped GET handler")
        return client.get(*a, REQUEST_METHOD=method.upper(), **kw)
    logging.info("%s with data %s", method, data)
    headers = _calculate_signature('service',
        method.upper(), url, data, username)
    response = getattr(client, method, method_wrapper)(
        url, data, content_type=content_type, **_fake_http_headers(headers))
    if response.status_code == 200:
        return response, loads(response.content)
    else:
        return response, {}
コード例 #3
0
 def signed_post(self, username, url, data):
     headers = _calculate_signature('service', 'POST', url, data, username)
     return self.client.post(url, data, **_fake_http_headers(headers))
コード例 #4
0
 def signed_get(self, username, url='/'):
     headers = _calculate_signature('service', 'GET', url, '', username)
     return self.client.get(url, **_fake_http_headers(headers))
コード例 #5
0
 def signed_post(self, username, url, data):
     headers = _calculate_signature("service", "POST", url, data, username)
     return self.client.post(url, data, **_fake_http_headers(headers))
コード例 #6
0
 def signed_get(self, username, url="/"):
     headers = _calculate_signature("service", "GET", url, "", username)
     return self.client.get(url, **_fake_http_headers(headers))
コード例 #7
0
 def signed_post(self, username, url, data):
     headers = _calculate_signature('service', 'POST', url, data, username, True)
     return self.client.post(url, data, **headers)
コード例 #8
0
 def signed_get(self,  username, url='/'):
     headers = _calculate_signature('service', 'GET', url, '', username, True)
     return self.client.get(url, **headers)