diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 16:04:21 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 16:04:21 +0000 |
commit | 8a754e0858d922e955e71b253c139e071ecec432 (patch) | |
tree | 527d16e74bfd1840c85efd675fdecad056c54107 /packaging/release/tests | |
parent | Initial commit. (diff) | |
download | ansible-core-8a754e0858d922e955e71b253c139e071ecec432.tar.xz ansible-core-8a754e0858d922e955e71b253c139e071ecec432.zip |
Adding upstream version 2.14.3.upstream/2.14.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'packaging/release/tests')
-rw-r--r-- | packaging/release/tests/__init__.py | 0 | ||||
-rw-r--r-- | packaging/release/tests/version_helper_test.py | 47 |
2 files changed, 47 insertions, 0 deletions
diff --git a/packaging/release/tests/__init__.py b/packaging/release/tests/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/packaging/release/tests/__init__.py diff --git a/packaging/release/tests/version_helper_test.py b/packaging/release/tests/version_helper_test.py new file mode 100644 index 0000000..ff14bd4 --- /dev/null +++ b/packaging/release/tests/version_helper_test.py @@ -0,0 +1,47 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +import pytest + +from packaging.version import InvalidVersion +from versionhelper.version_helper import AnsibleVersionMunger + + +@pytest.mark.parametrize('version,revision,codename,output_propname,expected', [ + ('2.5.0.dev1', None, None, 'raw', '2.5.0.dev1'), + ('2.5.0a0.post0', None, None, 'raw', '2.5.0a0.post0'), + ('2.5.0', None, None, 'raw', '2.5.0'), + ('2.5.0.dev1', None, None, 'major_version', '2.5'), + ('2.5.0', None, None, 'major_version', '2.5'), + ('2.5.0.dev1', None, None, 'base_version', '2.5.0'), + ('2.5.0', None, None, 'base_version', '2.5.0'), + ('2.5.0.dev1', None, None, 'deb_version', '2.5.0~dev1'), + ('2.5.0b1', None, None, 'deb_version', '2.5.0~b1'), + ('2.5.0b1.dev1', None, None, 'deb_version', '2.5.0~b1~dev1'), + ('2.5.0b1.post0', None, None, 'deb_version', '2.5.0~b1~post0'), + ('2.5.0', None, None, 'deb_version', '2.5.0'), + ('2.5.0.dev1', None, None, 'deb_release', '1'), + ('2.5.0b1', 2, None, 'deb_release', '2'), + ('2.5.0.dev1', None, None, 'rpm_release', '0.1.dev1'), + ('2.5.0a1', None, None, 'rpm_release', '0.101.a1'), + ('2.5.0a1.post0', None, None, 'rpm_release', '0.101.a1.post0'), + ('2.5.0b1', None, None, 'rpm_release', '0.201.b1'), + ('2.5.0rc1', None, None, 'rpm_release', '0.1001.rc1'), + ('2.5.0rc1', '0.99', None, 'rpm_release', '0.99.rc1'), + ('2.5.0.rc.1', None, None, 'rpm_release', '0.1001.rc.1'), + ('2.5.0.rc1.dev1', None, None, 'rpm_release', '0.1001.rc1.dev1'), + ('2.5.0', None, None, 'rpm_release', '1'), + ('2.5.0', 2, None, 'rpm_release', '2'), + ('2.5.0', None, None, 'codename', 'UNKNOWN'), + ('2.5.0', None, 'LedZeppelinSongHere', 'codename', 'LedZeppelinSongHere'), + ('2.5.0x1', None, None, None, InvalidVersion) +]) +def test_output_values(version, revision, codename, output_propname, expected): + try: + v = AnsibleVersionMunger(version, revision, codename) + assert getattr(v, output_propname) == expected + except Exception as ex: + if isinstance(expected, type): + assert isinstance(ex, expected) + else: + raise |