From 0af4d72753fa411ddbd17e180aca2c3f4a4df9a6 Mon Sep 17 00:00:00 2001 From: Rodolfo Carvalho Date: Wed, 22 Mar 2017 16:52:37 +0100 Subject: Test recursively finding subclasses --- .../test/openshift_check_test.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'roles/openshift_health_checker') diff --git a/roles/openshift_health_checker/test/openshift_check_test.py b/roles/openshift_health_checker/test/openshift_check_test.py index 03465a7c3..e3153979c 100644 --- a/roles/openshift_health_checker/test/openshift_check_test.py +++ b/roles/openshift_health_checker/test/openshift_check_test.py @@ -58,6 +58,23 @@ def test_OpenShiftCheck_init(): assert check.module_executor == execute_module +def test_subclasses(): + """OpenShiftCheck.subclasses should find all subclasses recursively.""" + class TestCheck1(OpenShiftCheck): + pass + + class TestCheck2(OpenShiftCheck): + pass + + class TestCheck1A(TestCheck1): + pass + + local_subclasses = set([TestCheck1, TestCheck1A, TestCheck2]) + known_subclasses = set(OpenShiftCheck.subclasses()) + + assert local_subclasses - known_subclasses == set(), "local_subclasses should be a subset of known_subclasses" + + def test_load_checks(): """Loading checks should load and return Python modules.""" modules = load_checks() -- cgit v1.2.3