From 209810c9905c0ebf89b1e03ccb8593f78a6e5396 Mon Sep 17 00:00:00 2001 From: Rodolfo Carvalho Date: Wed, 22 Mar 2017 21:05:18 +0100 Subject: Add unit tests for mixins.py --- roles/openshift_health_checker/test/mixins_test.py | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 roles/openshift_health_checker/test/mixins_test.py (limited to 'roles/openshift_health_checker') diff --git a/roles/openshift_health_checker/test/mixins_test.py b/roles/openshift_health_checker/test/mixins_test.py new file mode 100644 index 000000000..2d83e207d --- /dev/null +++ b/roles/openshift_health_checker/test/mixins_test.py @@ -0,0 +1,23 @@ +import pytest + +from openshift_checks import OpenShiftCheck, OpenShiftCheckException +from openshift_checks.mixins import NotContainerizedMixin + + +class NotContainerizedCheck(NotContainerizedMixin, OpenShiftCheck): + name = "not_containerized" + run = NotImplemented + + +@pytest.mark.parametrize('task_vars,expected', [ + (dict(openshift=dict(common=dict(is_containerized=False))), True), + (dict(openshift=dict(common=dict(is_containerized=True))), False), +]) +def test_is_active(task_vars, expected): + assert NotContainerizedCheck.is_active(task_vars) == expected + + +def test_is_active_missing_task_vars(): + with pytest.raises(OpenShiftCheckException) as excinfo: + NotContainerizedCheck.is_active(task_vars={}) + assert 'is_containerized' in str(excinfo.value) -- cgit v1.2.3