def log(level, log_entry): return RequestLog.objects.create( domain=log_entry.domain, log_level=level, payload_id=log_entry.payload_id, request_method=log_entry.method, request_url=log_entry.url, request_headers=log_entry.headers, request_params=log_entry.params, request_body=as_text(log_entry.data), request_error=log_entry.error, response_status=log_entry.response_status, response_body=as_text(log_entry.response_body), )
def assert_create_called_with_request_body_and_params( self, create_mock, request_body, request_params=None): create_mock.assert_called_with( domain=TEST_DOMAIN, log_level=logging.INFO, payload_id=None, request_body=as_text(request_body), request_error=self.error_message, request_headers=self.request_headers, request_method=self.request_method, request_params=request_params, request_url=f'{TEST_API_URL}person/', response_body=as_text(self.content_json), response_status=self.status_code, )