openshift_version_tests.py 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. """ Tests for the openshift_version Ansible filter module. """
  2. # pylint: disable=missing-docstring,invalid-name
  3. import os
  4. import sys
  5. import unittest
  6. sys.path = [os.path.abspath(os.path.dirname(__file__) + "/../filter_plugins/")] + sys.path
  7. # pylint: disable=import-error
  8. import openshift_version # noqa: E402
  9. class OpenShiftVersionTests(unittest.TestCase):
  10. openshift_version_filters = openshift_version.FilterModule()
  11. def test_gte_filters(self):
  12. for major, minor_start, minor_end in self.openshift_version_filters.versions:
  13. for minor in range(minor_start, minor_end):
  14. # Test positive case
  15. self.assertTrue(
  16. self.openshift_version_filters._filters["oo_version_gte_{}_{}".format(major, minor)](
  17. "{}.{}".format(major, minor + 1)))
  18. # Test negative case
  19. self.assertFalse(
  20. self.openshift_version_filters._filters["oo_version_gte_{}_{}".format(major, minor)](
  21. "{}.{}".format(major, minor)))
  22. def test_get_filters(self):
  23. self.assertTrue(
  24. self.openshift_version_filters.filters() == self.openshift_version_filters._filters)