def handler(request, data): parsed_url = urlparse(request.url) path_with_params = path_from_url(request.url) method = request.method headers = request.headers request_handler = Mock() request_handler.proxy = Mock() request_handler.proxy.port = port response = modify_and_forward(method=method, path=path_with_params, data_bytes=data, headers=headers, forward_base_url=forward_url, listeners=[listener], request_handler=None, client_address=request.remote_addr, server_address=parsed_url.netloc) return response
def _from_env(*args, **kwargs): result = Mock() result.api = Mock() result.api.get_adapter = (lambda *args, **kwargs: None) return result