summaryrefslogtreecommitdiffstats
path: root/test/openshift_version_tests.py
diff options
context:
space:
mode:
authorAndrew Butcher <abutcher@redhat.com>2017-03-27 16:09:40 -0400
committerAndrew Butcher <abutcher@redhat.com>2017-03-27 17:00:46 -0400
commitfedcc4c28b897ae6a18e4a03eab1f0c2a72c2889 (patch)
tree327eb2f541e2a610d37d10d77f9f7a8225d4b17c /test/openshift_version_tests.py
parentf48106c83b81735fe9e338037064ec4d168ea429 (diff)
downloadopenshift-fedcc4c28b897ae6a18e4a03eab1f0c2a72c2889.tar.gz
openshift-fedcc4c28b897ae6a18e4a03eab1f0c2a72c2889.tar.bz2
openshift-fedcc4c28b897ae6a18e4a03eab1f0c2a72c2889.tar.xz
openshift-fedcc4c28b897ae6a18e4a03eab1f0c2a72c2889.zip
Use oo_version_gte_3_6+ for future versions and treat 1.x origin as legacy. Add tests.
Diffstat (limited to 'test/openshift_version_tests.py')
-rw-r--r--test/openshift_version_tests.py72
1 files changed, 72 insertions, 0 deletions
diff --git a/test/openshift_version_tests.py b/test/openshift_version_tests.py
new file mode 100644
index 000000000..52e9a9888
--- /dev/null
+++ b/test/openshift_version_tests.py
@@ -0,0 +1,72 @@
+""" Tests for the openshift_version Ansible filter module. """
+# pylint: disable=missing-docstring,invalid-name
+
+import os
+import sys
+import unittest
+
+sys.path = [os.path.abspath(os.path.dirname(__file__) + "/../filter_plugins/")] + sys.path
+
+# pylint: disable=import-error
+import openshift_version # noqa: E402
+
+
+class OpenShiftVersionTests(unittest.TestCase):
+
+ openshift_version_filters = openshift_version.FilterModule()
+
+ # Static tests for legacy filters.
+ legacy_gte_tests = [{'name': 'oo_version_gte_3_1_or_1_1',
+ 'positive_enterprise_version': '3.2.0',
+ 'negative_enterprise_version': '3.0.0',
+ 'positive_origin_version': '1.2.0',
+ 'negative_origin_version': '1.0.0'},
+ {'name': 'oo_version_gte_3_1_1_or_1_1_1',
+ 'positive_enterprise_version': '3.2.0',
+ 'negative_enterprise_version': '3.1.0',
+ 'positive_origin_version': '1.2.0',
+ 'negative_origin_version': '1.1.0'},
+ {'name': 'oo_version_gte_3_2_or_1_2',
+ 'positive_enterprise_version': '3.3.0',
+ 'negative_enterprise_version': '3.1.0',
+ 'positive_origin_version': '1.3.0',
+ 'negative_origin_version': '1.1.0'},
+ {'name': 'oo_version_gte_3_3_or_1_3',
+ 'positive_enterprise_version': '3.4.0',
+ 'negative_enterprise_version': '3.2.0',
+ 'positive_origin_version': '1.4.0',
+ 'negative_origin_version': '1.2.0'},
+ {'name': 'oo_version_gte_3_4_or_1_4',
+ 'positive_enterprise_version': '3.5.0',
+ 'negative_enterprise_version': '3.3.0',
+ 'positive_origin_version': '1.5.0',
+ 'negative_origin_version': '1.3.0'},
+ {'name': 'oo_version_gte_3_5_or_1_5',
+ 'positive_enterprise_version': '3.6.0',
+ 'negative_enterprise_version': '3.4.0',
+ 'positive_origin_version': '1.6.0',
+ 'negative_origin_version': '1.4.0'}]
+
+ def test_legacy_gte_filters(self):
+ for test in self.legacy_gte_tests:
+ for deployment_type in ['enterprise', 'origin']:
+ # Test negative case per deployment_type
+ self.assertFalse(
+ self.openshift_version_filters._filters[test['name']](
+ test["negative_{}_version".format(deployment_type)], deployment_type))
+ # Test positive case per deployment_type
+ self.assertTrue(
+ self.openshift_version_filters._filters[test['name']](
+ test["positive_{}_version".format(deployment_type)], deployment_type))
+
+ def test_gte_filters(self):
+ for major, minor_start, minor_end in self.openshift_version_filters.versions:
+ for minor in range(minor_start, minor_end):
+ # Test positive case
+ self.assertTrue(
+ self.openshift_version_filters._filters["oo_version_gte_{}_{}".format(major, minor)](
+ "{}.{}".format(major, minor + 1)))
+ # Test negative case
+ self.assertFalse(
+ self.openshift_version_filters._filters["oo_version_gte_{}_{}".format(major, minor)](
+ "{}.{}".format(major, minor)))