summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--roles/openshift_master_facts/test/openshift_master_facts_bad_input_tests.py58
-rw-r--r--roles/openshift_master_facts/test/openshift_master_facts_default_predicates_tests.py41
-rw-r--r--roles/openshift_master_facts/test/openshift_master_facts_default_priorities_tests.py41
3 files changed, 60 insertions, 80 deletions
diff --git a/roles/openshift_master_facts/test/openshift_master_facts_bad_input_tests.py b/roles/openshift_master_facts/test/openshift_master_facts_bad_input_tests.py
new file mode 100644
index 000000000..ec6c7ae4a
--- /dev/null
+++ b/roles/openshift_master_facts/test/openshift_master_facts_bad_input_tests.py
@@ -0,0 +1,58 @@
+import copy
+import os
+import sys
+
+from ansible.errors import AnsibleError
+from nose.tools import raises
+
+sys.path.insert(1, os.path.join(os.path.dirname(__file__), os.pardir, "lookup_plugins"))
+
+from openshift_master_facts_default_predicates import LookupModule # noqa: E402
+
+
+class TestOpenShiftMasterFactsBadInput(object):
+ def setUp(self):
+ self.lookup = LookupModule()
+ self.default_facts = {
+ 'openshift': {
+ 'common': {}
+ }
+ }
+
+ @raises(AnsibleError)
+ def test_missing_openshift_facts(self):
+ facts = {}
+ self.lookup.run(None, variables=facts)
+
+ @raises(AnsibleError)
+ def test_missing_deployment_type(self):
+ facts = copy.deepcopy(self.default_facts)
+ facts['openshift']['common']['short_version'] = '10.10'
+ self.lookup.run(None, variables=facts)
+
+ @raises(AnsibleError)
+ def test_missing_short_version_and_missing_openshift_release(self):
+ facts = copy.deepcopy(self.default_facts)
+ facts['openshift']['common']['deployment_type'] = 'origin'
+ self.lookup.run(None, variables=facts)
+
+ @raises(AnsibleError)
+ def test_unknown_deployment_types(self):
+ facts = copy.deepcopy(self.default_facts)
+ facts['openshift']['common']['short_version'] = '1.1'
+ facts['openshift']['common']['deployment_type'] = 'bogus'
+ self.lookup.run(None, variables=facts)
+
+ @raises(AnsibleError)
+ def test_unknown_origin_version(self):
+ facts = copy.deepcopy(self.default_facts)
+ facts['openshift']['common']['short_version'] = '0.1'
+ facts['openshift']['common']['deployment_type'] = 'origin'
+ self.lookup.run(None, variables=facts)
+
+ @raises(AnsibleError)
+ def test_unknown_ocp_version(self):
+ facts = copy.deepcopy(self.default_facts)
+ facts['openshift']['common']['short_version'] = '0.1'
+ facts['openshift']['common']['deployment_type'] = 'openshift-enterprise'
+ self.lookup.run(None, variables=facts)
diff --git a/roles/openshift_master_facts/test/openshift_master_facts_default_predicates_tests.py b/roles/openshift_master_facts/test/openshift_master_facts_default_predicates_tests.py
index c7cf73523..ec1120bd5 100644
--- a/roles/openshift_master_facts/test/openshift_master_facts_default_predicates_tests.py
+++ b/roles/openshift_master_facts/test/openshift_master_facts_default_predicates_tests.py
@@ -2,8 +2,7 @@ import copy
import os
import sys
-from ansible.errors import AnsibleError
-from nose.tools import raises, assert_equal
+from nose.tools import assert_equal
sys.path.insert(1, os.path.join(os.path.dirname(__file__), os.pardir, "lookup_plugins"))
@@ -97,44 +96,6 @@ class TestOpenShiftMasterFactsDefaultPredicates(object):
}
}
- @raises(AnsibleError)
- def test_missing_openshift_facts(self):
- facts = {}
- self.lookup.run(None, variables=facts)
-
- @raises(AnsibleError)
- def test_missing_deployment_type(self):
- facts = copy.deepcopy(self.default_facts)
- facts['openshift']['common']['short_version'] = '10.10'
- self.lookup.run(None, variables=facts)
-
- @raises(AnsibleError)
- def test_missing_short_version_and_missing_openshift_release(self):
- facts = copy.deepcopy(self.default_facts)
- facts['openshift']['common']['deployment_type'] = 'origin'
- self.lookup.run(None, variables=facts)
-
- @raises(AnsibleError)
- def test_unknown_deployment_types(self):
- facts = copy.deepcopy(self.default_facts)
- facts['openshift']['common']['short_version'] = '1.1'
- facts['openshift']['common']['deployment_type'] = 'bogus'
- self.lookup.run(None, variables=facts)
-
- @raises(AnsibleError)
- def test_unknown_origin_version(self):
- facts = copy.deepcopy(self.default_facts)
- facts['openshift']['common']['short_version'] = '0.1'
- facts['openshift']['common']['deployment_type'] = 'origin'
- self.lookup.run(None, variables=facts)
-
- @raises(AnsibleError)
- def test_unknown_ocp_version(self):
- facts = copy.deepcopy(self.default_facts)
- facts['openshift']['common']['short_version'] = '0.1'
- facts['openshift']['common']['deployment_type'] = 'openshift-enterprise'
- self.lookup.run(None, variables=facts)
-
def check_defaults_short_version(self, short_version, deployment_type, default_predicates,
regions_enabled):
facts = copy.deepcopy(self.default_facts)
diff --git a/roles/openshift_master_facts/test/openshift_master_facts_default_priorities_tests.py b/roles/openshift_master_facts/test/openshift_master_facts_default_priorities_tests.py
index 36d159f4a..974cc1d0c 100644
--- a/roles/openshift_master_facts/test/openshift_master_facts_default_priorities_tests.py
+++ b/roles/openshift_master_facts/test/openshift_master_facts_default_priorities_tests.py
@@ -2,8 +2,7 @@ import copy
import os
import sys
-from ansible.errors import AnsibleError
-from nose.tools import raises, assert_equal
+from nose.tools import assert_equal
sys.path.insert(1, os.path.join(os.path.dirname(__file__), os.pardir, "lookup_plugins"))
@@ -85,44 +84,6 @@ class TestOpenShiftMasterFactsDefaultPredicates(object):
}
}
- @raises(AnsibleError)
- def test_missing_openshift_facts(self):
- facts = {}
- self.lookup.run(None, variables=facts)
-
- @raises(AnsibleError)
- def test_missing_deployment_type(self):
- facts = copy.deepcopy(self.default_facts)
- facts['openshift']['common']['short_version'] = '10.10'
- self.lookup.run(None, variables=facts)
-
- @raises(AnsibleError)
- def test_missing_short_version_and_missing_openshift_release(self):
- facts = copy.deepcopy(self.default_facts)
- facts['openshift']['common']['deployment_type'] = 'origin'
- self.lookup.run(None, variables=facts)
-
- @raises(AnsibleError)
- def test_unknown_deployment_types(self):
- facts = copy.deepcopy(self.default_facts)
- facts['openshift']['common']['short_version'] = '1.1'
- facts['openshift']['common']['deployment_type'] = 'bogus'
- self.lookup.run(None, variables=facts)
-
- @raises(AnsibleError)
- def test_unknown_origin_version(self):
- facts = copy.deepcopy(self.default_facts)
- facts['openshift']['common']['short_version'] = '0.1'
- facts['openshift']['common']['deployment_type'] = 'origin'
- self.lookup.run(None, variables=facts)
-
- @raises(AnsibleError)
- def test_unknown_ocp_version(self):
- facts = copy.deepcopy(self.default_facts)
- facts['openshift']['common']['short_version'] = '0.1'
- facts['openshift']['common']['deployment_type'] = 'openshift-enterprise'
- self.lookup.run(None, variables=facts)
-
def check_defaults_short_version(self, release, deployment_type,
default_priorities, zones_enabled):
facts = copy.deepcopy(self.default_facts)