diff options
author | Luke Meyer <lmeyer@redhat.com> | 2017-06-16 17:24:01 -0400 |
---|---|---|
committer | Luke Meyer <lmeyer@redhat.com> | 2017-07-25 13:23:58 -0400 |
commit | 210fc2d3849a1baf9c1d8535044d92df23424274 (patch) | |
tree | 20b6998ca0696257eb816e4ace464ee95b926816 /roles/openshift_health_checker/test/etcd_traffic_test.py | |
parent | 2a0936b291992ba1b7343680aec915df0c29892c (diff) | |
download | openshift-210fc2d3849a1baf9c1d8535044d92df23424274.tar.gz openshift-210fc2d3849a1baf9c1d8535044d92df23424274.tar.bz2 openshift-210fc2d3849a1baf9c1d8535044d92df23424274.tar.xz openshift-210fc2d3849a1baf9c1d8535044d92df23424274.zip |
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.
Diffstat (limited to 'roles/openshift_health_checker/test/etcd_traffic_test.py')
-rw-r--r-- | roles/openshift_health_checker/test/etcd_traffic_test.py | 16 |
1 files changed, 5 insertions, 11 deletions
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() |