From 210fc2d3849a1baf9c1d8535044d92df23424274 Mon Sep 17 00:00:00 2001 From: Luke Meyer Date: Fri, 16 Jun 2017 17:24:01 -0400 Subject: openshift_checks: refactor to internalize task_vars Move task_vars into instance variable so we don't have to pass it around everywhere. Also store tmp. Make sure both are filled in on execute_module. In the process, is_active became an instance method, and task_vars is basically never used directly outside of test code. --- roles/openshift_health_checker/test/etcd_traffic_test.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'roles/openshift_health_checker/test/etcd_traffic_test.py') diff --git a/roles/openshift_health_checker/test/etcd_traffic_test.py b/roles/openshift_health_checker/test/etcd_traffic_test.py index 287175e29..f4316c423 100644 --- a/roles/openshift_health_checker/test/etcd_traffic_test.py +++ b/roles/openshift_health_checker/test/etcd_traffic_test.py @@ -21,7 +21,7 @@ def test_is_active(group_names, version, is_active): common=dict(short_version=version), ), ) - assert EtcdTraffic.is_active(task_vars=task_vars) == is_active + assert EtcdTraffic(task_vars=task_vars).is_active() == is_active @pytest.mark.parametrize('group_names,matched,failed,extra_words', [ @@ -30,7 +30,7 @@ def test_is_active(group_names, version, is_active): (["etcd"], False, False, []), ]) def test_log_matches_high_traffic_msg(group_names, matched, failed, extra_words): - def execute_module(module_name, args, task_vars): + def execute_module(module_name, *_): return { "matched": matched, "failed": failed, @@ -43,8 +43,7 @@ def test_log_matches_high_traffic_msg(group_names, matched, failed, extra_words) ) ) - check = EtcdTraffic(execute_module=execute_module) - result = check.run(tmp=None, task_vars=task_vars) + result = EtcdTraffic(execute_module, task_vars).run() for word in extra_words: assert word in result.get("msg", "") @@ -63,7 +62,7 @@ def test_systemd_unit_matches_deployment_type(is_containerized, expected_unit_va ) ) - def execute_module(module_name, args, task_vars): + def execute_module(module_name, args, *_): assert module_name == "search_journalctl" matchers = args["log_matchers"] @@ -72,9 +71,4 @@ def test_systemd_unit_matches_deployment_type(is_containerized, expected_unit_va return {"failed": False} - check = EtcdTraffic(execute_module=execute_module) - check.run(tmp=None, task_vars=task_vars) - - -def fake_execute_module(*args): - raise AssertionError('this function should not be called') + EtcdTraffic(execute_module, task_vars).run() -- cgit v1.2.1