def mock_request(method, url, **kwargs): if 'standby' in url: mock_request.standby_count += 1 return _standby_response() elif 'localhost' in url: mock_request.active_count += 1 return original_request(method, url, **kwargs) else: self.fail("Unexpected url {}".format(url)) # pragma: no cover
def mock_request(method: str, url: str, **kwargs: object) -> requests.Response: if "standby" in url: standby_count[0] += 1 return _standby_response() elif "localhost" in url: active_count[0] += 1 return original_request(method, url, **kwargs) else: self.fail("Unexpected url {}".format(url)) # pragma: no cover
def wrapped_request(*args, **kwargs): wrapped_request.called = True return original_request(*args, **kwargs)
def _hacked_request(method, url, **kwargs): """Hack to "redirect" hostnames that the VM knows to localhost""" url = url.replace('quickstart.cloudera', 'localhost') return original_request(method, url, **kwargs)
def wrapped_request(*args: Any, **kwargs: Any) -> requests.Response: called[0] = True return original_request(*args, **kwargs)