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, {}
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, {}
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))
def signed_get(self, username, url='/'): headers = _calculate_signature('service', 'GET', url, '', username) return self.client.get(url, **_fake_http_headers(headers))
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))
def signed_get(self, username, url="/"): headers = _calculate_signature("service", "GET", url, "", username) return self.client.get(url, **_fake_http_headers(headers))
def signed_post(self, username, url, data): headers = _calculate_signature('service', 'POST', url, data, username, True) return self.client.post(url, data, **headers)
def signed_get(self, username, url='/'): headers = _calculate_signature('service', 'GET', url, '', username, True) return self.client.get(url, **headers)