diff --git a/testfm/decorators.py b/testfm/decorators.py index e935309..11129fa 100644 --- a/testfm/decorators.py +++ b/testfm/decorators.py @@ -1,3 +1,5 @@ +from distutils.version import StrictVersion as Version + import pytest import unittest2 @@ -19,11 +21,11 @@ def run_only_on(*server_version): from TestFM.decorators import run_only_on - @run_only_on('6.4') + @run_only_on("6.4") def test_health_check(): # test code continues here - :param str server_version: Enter '6.8', 6.7', '6.6', '6.5', '6.4' and '6.3' + :param str server_version: Enter "6.8", "6.7", "6.6", "6.5", "6.4" and "6.3" for specific version """ prd_version = product() @@ -43,15 +45,15 @@ def starts_in(version): from TestFM.decorators import starts_in - @starts_in(6.6) + @starts_in("6.6") def test_health_check(): # test code continues here - :param float version: Enter 6.8, 6.7, 6.6, 6.5, 6.4 and 6.3 + :param str version: Enter "6.10", "6.9", "6.8.4", and likewise for specific version """ return pytest.mark.skipif( - float(product()) < version, + Version(product()) < Version(version), reason="Server version is '{}' and this test will run only " "on {} '{}' onward".format(product(), server(), version), ) @@ -66,15 +68,15 @@ def ends_in(version): from TestFM.decorators import ends_in - @ends_in(6.6) + @ends_in("6.6") def test_health_check(): # test code continues here - :param float version: Enter 6.7, 6.6, 6.5 , 6.4 , 6.3 , 6.2 and 6.1 + :param str version: Enter "6.10", "6.9", "6.8.4", and likewise for specific version """ return pytest.mark.skipif( - float(product()) > version, + Version(product()) > Version(version), reason="Server version is '{}' and this test will run only " "on {} <= '{}'".format(product(), server(), version), ) diff --git a/testfm/helpers.py b/testfm/helpers.py index 52219bb..ca5b931 100644 --- a/testfm/helpers.py +++ b/testfm/helpers.py @@ -9,7 +9,7 @@ def product(): '-a "rpm -q satellite > /dev/null && rpm -q satellite --queryformat=%{VERSION}' ' || rpm -q satellite-capsule --queryformat=%{VERSION}" -o' ).read() - return server_version.splitlines()[0].split(" ")[-1][:3] + return server_version.splitlines()[0].split(" ")[-1] def run(command): diff --git a/tests/test_backup.py b/tests/test_backup.py index ebe6eff..fcfd23d 100644 --- a/tests/test_backup.py +++ b/tests/test_backup.py @@ -716,7 +716,7 @@ def test_negative_backup_online_incremental_nodir(ansible_module): assert NOPREV_MSG in result["stderr"] -@ends_in(6.7) +@ends_in("6.7") def test_positive_backup_stopped_dynflowd(setup_backup_tests, ansible_module): """Take online backup of server when dynflowd is not running @@ -763,7 +763,7 @@ def test_positive_backup_stopped_dynflowd(setup_backup_tests, ansible_module): assert result["rc"] == 0 -@ends_in(6.7) +@ends_in("6.7") def test_positive_backup_stopped_foreman_tasks(setup_backup_tests, ansible_module): """Take online backup of server when foreman-tasks is not running diff --git a/tests/test_packages.py b/tests/test_packages.py index 50e345d..c8f9c88 100644 --- a/tests/test_packages.py +++ b/tests/test_packages.py @@ -73,7 +73,7 @@ def test_positive_fm_packages_lock(ansible_module): @pytest.mark.capsule -@starts_in(6.6) +@starts_in("6.6") def test_positive_lock_package_versions(ansible_module): """Verify whether satellite related packages get locked