Browse Source

Test recursively finding subclasses

Rodolfo Carvalho 8 years ago
parent
commit
0af4d72753
1 changed files with 17 additions and 0 deletions
  1. 17 0
      roles/openshift_health_checker/test/openshift_check_test.py

+ 17 - 0
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()