From 11040f1b76981c22d62d17d1d22a3741e50a27fd Mon Sep 17 00:00:00 2001 From: Rodolfo Carvalho Date: Fri, 9 Jun 2017 17:04:19 +0200 Subject: Capture exceptions when resolving available checks Calling the action plugin (e.g. when running a playbook) with an incorrect check name was raising an unhandled exception, leading to poor output in Ansible (requiring a higher verbosity level to see what is going wrong). --- roles/openshift_health_checker/test/action_plugin_test.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'roles/openshift_health_checker/test/action_plugin_test.py') diff --git a/roles/openshift_health_checker/test/action_plugin_test.py b/roles/openshift_health_checker/test/action_plugin_test.py index 6ebf0ebb2..9383b233c 100644 --- a/roles/openshift_health_checker/test/action_plugin_test.py +++ b/roles/openshift_health_checker/test/action_plugin_test.py @@ -59,7 +59,7 @@ def failed(result, msg_has=None): if msg_has is not None: assert 'msg' in result for term in msg_has: - assert term in result['msg'] + assert term.lower() in result['msg'].lower() return result.get('failed', False) @@ -178,6 +178,16 @@ def test_action_plugin_run_check_exception(plugin, task_vars, monkeypatch): assert not skipped(result) +def test_action_plugin_resolve_checks_exception(plugin, task_vars, monkeypatch): + monkeypatch.setattr(plugin, 'load_known_checks', lambda: {}) + + result = plugin.run(tmp=None, task_vars=task_vars) + + assert failed(result, msg_has=['unknown', 'name']) + assert not changed(result) + assert not skipped(result) + + @pytest.mark.parametrize('names,all_checks,expected', [ ([], [], set()), ( -- cgit v1.2.3