summaryrefslogtreecommitdiffstats
path: root/roles/lib_utils/test/openshift_master_facts_bad_input_tests.py
diff options
context:
space:
mode:
authorScott Dodson <sdodson@redhat.com>2018-01-11 18:43:36 -0500
committerGitHub <noreply@github.com>2018-01-11 18:43:36 -0500
commitfa649787c6a19bbfffb16d9cce3f8e3f7de5a8a1 (patch)
tree6c891a58fb0642d9e0f7399f139940fe46c919e9 /roles/lib_utils/test/openshift_master_facts_bad_input_tests.py
parentfdc5829d6ca252e1574278cd1dc50e932378d98d (diff)
parentd3fefc32a727fe3c13159c4e9fe4399f35b487a8 (diff)
downloadopenshift-fa649787c6a19bbfffb16d9cce3f8e3f7de5a8a1.tar.gz
openshift-fa649787c6a19bbfffb16d9cce3f8e3f7de5a8a1.tar.bz2
openshift-fa649787c6a19bbfffb16d9cce3f8e3f7de5a8a1.tar.xz
openshift-fa649787c6a19bbfffb16d9cce3f8e3f7de5a8a1.zip
Merge pull request #6614 from mgugino-upstream-stage/plugins-to-lib-utils
Move more plugins to lib_utils
Diffstat (limited to 'roles/lib_utils/test/openshift_master_facts_bad_input_tests.py')
-rw-r--r--roles/lib_utils/test/openshift_master_facts_bad_input_tests.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/roles/lib_utils/test/openshift_master_facts_bad_input_tests.py b/roles/lib_utils/test/openshift_master_facts_bad_input_tests.py
new file mode 100644
index 000000000..e8da1e04a
--- /dev/null
+++ b/roles/lib_utils/test/openshift_master_facts_bad_input_tests.py
@@ -0,0 +1,57 @@
+import copy
+import os
+import sys
+
+from ansible.errors import AnsibleError
+import pytest
+
+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):
+ lookup = LookupModule()
+ default_facts = {
+ 'openshift': {
+ 'common': {}
+ }
+ }
+
+ def test_missing_openshift_facts(self):
+ with pytest.raises(AnsibleError):
+ facts = {}
+ self.lookup.run(None, variables=facts)
+
+ def test_missing_deployment_type(self):
+ with pytest.raises(AnsibleError):
+ facts = copy.deepcopy(self.default_facts)
+ facts['openshift']['common']['short_version'] = '10.10'
+ self.lookup.run(None, variables=facts)
+
+ def test_missing_short_version_and_missing_openshift_release(self):
+ with pytest.raises(AnsibleError):
+ facts = copy.deepcopy(self.default_facts)
+ facts['openshift']['common']['deployment_type'] = 'origin'
+ self.lookup.run(None, variables=facts)
+
+ def test_unknown_deployment_types(self):
+ with pytest.raises(AnsibleError):
+ 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)
+
+ def test_unknown_origin_version(self):
+ with pytest.raises(AnsibleError):
+ 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)
+
+ def test_unknown_ocp_version(self):
+ with pytest.raises(AnsibleError):
+ 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)