def test_verify_url_internal_failure(exec_result, expect): check = Kibana( execute_module=lambda *_: dict(failed=True, msg=exec_result)) check._get_kibana_url = lambda: ('url', None) error = check._check_kibana_route() assert_error(error, expect)
def test_verify_url_external_failure(lib_result, expect, monkeypatch): class _http_return: def __init__(self, code): self.code = code def getcode(self): return self.code def urlopen(url, context): if type(lib_result) is int: return _http_return(lib_result) raise lib_result monkeypatch.setattr(urllib2, 'urlopen', urlopen) check = Kibana() check._get_kibana_url = lambda: ('url', None) check._verify_url_internal = lambda url: None error = check._check_kibana_route() assert_error(error, expect)
def test_verify_url_internal_failure(exec_result, expect): check = Kibana(execute_module=lambda module_name, args, task_vars: dict(failed=True, msg=exec_result)) check._get_kibana_url = lambda task_vars: ('url', None) error = check._check_kibana_route({}) assert_error(error, expect)