summaryrefslogtreecommitdiffstats
path: root/roles/openshift_health_checker/test/mixins_test.py
blob: b1a41ca3cfe66e5fe3a0a98d6d1e2f09929fcc6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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(None, task_vars).is_active() == expected


def test_is_active_missing_task_vars():
    with pytest.raises(OpenShiftCheckException) as excinfo:
        NotContainerizedCheck().is_active()
    assert 'is_containerized' in str(excinfo.value)