diff options
author | Luke Meyer <lmeyer@redhat.com> | 2017-07-28 07:19:24 -0400 |
---|---|---|
committer | Luke Meyer <lmeyer@redhat.com> | 2017-08-01 12:18:37 -0400 |
commit | 4e6bf287d97aaa254aeb8cf1d83b2229fee7a19f (patch) | |
tree | 4d2292c3b533c47693e03072f89720002a998223 /roles/openshift_health_checker/test | |
parent | bf0bf407479458206f48885e43d3e1d3a2eab6e1 (diff) | |
download | openshift-4e6bf287d97aaa254aeb8cf1d83b2229fee7a19f.tar.gz openshift-4e6bf287d97aaa254aeb8cf1d83b2229fee7a19f.tar.bz2 openshift-4e6bf287d97aaa254aeb8cf1d83b2229fee7a19f.tar.xz openshift-4e6bf287d97aaa254aeb8cf1d83b2229fee7a19f.zip |
openshift_checks: enable variable conversion
Diffstat (limited to 'roles/openshift_health_checker/test')
-rw-r--r-- | roles/openshift_health_checker/test/openshift_check_test.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/roles/openshift_health_checker/test/openshift_check_test.py b/roles/openshift_health_checker/test/openshift_check_test.py index 43aa875f4..789784c77 100644 --- a/roles/openshift_health_checker/test/openshift_check_test.py +++ b/roles/openshift_health_checker/test/openshift_check_test.py @@ -81,6 +81,7 @@ def dummy_check(task_vars): @pytest.mark.parametrize("keys,expected", [ (("foo",), 42), (("bar", "baz"), "openshift"), + (("bar.baz",), "openshift"), ]) def test_get_var_ok(task_vars, keys, expected): assert dummy_check(task_vars).get_var(*keys) == expected @@ -94,3 +95,24 @@ def test_get_var_error(task_vars, missing_keys): def test_get_var_default(task_vars, missing_keys): default = object() assert dummy_check(task_vars).get_var(*missing_keys, default=default) == default + + +@pytest.mark.parametrize("keys, convert, expected", [ + (("foo",), str, "42"), + (("foo",), float, 42.0), + (("bar", "baz"), bool, False), +]) +def test_get_var_convert(task_vars, keys, convert, expected): + assert dummy_check(task_vars).get_var(*keys, convert=convert) == expected + + +@pytest.mark.parametrize("keys, convert", [ + (("bar", "baz"), int), + (("bar.baz"), float), + (("foo"), "bogus"), + (("foo"), lambda a, b: 1), + (("foo"), lambda a: 1 / 0), +]) +def test_get_var_convert_error(task_vars, keys, convert): + with pytest.raises(OpenShiftCheckException): + dummy_check(task_vars).get_var(*keys, convert=convert) |