def post(self, api_url, data=None, headers=None, expected_status_code=None, **kwargs): """ POST :param api_url: API URL :param data: POST request payload :param headers: Custom header :param expected_status_code: Asserts the result's status code :param kwargs: Other arguments used in the requests. http://docs.python-requests.org/en/master/api/ :return: Request response """ url = self.api_gw + api_url request_headers = self._combine_headers(headers) if 'files' in kwargs: request_headers.pop('Content-type') request_data = self._data_content(request_headers, data) r = requests.post(url, headers=request_headers, data=request_data, **kwargs) self._write_log_response('POST', api_url, r) if expected_status_code is not None: assert_status(r, inspect.stack()[1][3], expected_status_code) return r
def delete(self, api_url, headers=None, expected_status_code=None, **kwargs): """ DELETE :param api_url: API URL :param headers: Custom header :param expected_status_code: Asserts the result's status code :param kwargs: Other arguments used in the requests. http://docs.python-requests.org/en/master/api/ :return: Request response """ url = self.api_gw + api_url if headers is not None: request_headers = self._combine_headers(headers) else: request_headers = self.headers r = requests.delete(url, headers=request_headers, **kwargs) self._write_log_response('DELETE', api_url, r) if expected_status_code is not None: assert_status(r, inspect.stack()[1][3], expected_status_code) return r