ansible/packaging/release/tests/version_helper_test.py
Matt Davis e4edb2842a 2.6 changelog gen/version/root dir cleanup (#40421)
* patched in changelog gen stuff from stable-2.5
* Makefile updates
* release.py as single-source-of-truth
* Remove obsolete ansible-core-sitemap.xml file.
* Move ROADMAP.rst into README.rst.
* dynamic rpm changelog, zap old deb/rpm changelogs
* fix changelog in MANIFEST.in
* Remove obsolete hacking/update.sh script.
* Remove ref to deleted authors script.
* Remove ref to removed module-formatter script.
* Update headings to match script names.
* MANIFEST.in cleanup
* removed RELEASES.txt and versions.yml
* removed obsolete release generation playbook/bits (not used since 2.5)
* misc Makefile cleanup
* speculative changes to DEB versioning
* allow override of DEB_VERSION/DEB_RELEASE
2018-05-21 16:14:53 -07:00

42 lines
1.8 KiB
Python

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.0dev1', None, None, 'raw', '2.5.0dev1'),
('2.5.0', None, None, 'raw', '2.5.0'),
('2.5.0dev1', None, None, 'major_version', '2.5'),
('2.5.0', None, None, 'major_version', '2.5'),
('2.5.0dev1', None, None, 'base_version', '2.5.0'),
('2.5.0', None, None, 'base_version', '2.5.0'),
('2.5.0dev1', None, None, 'deb_version', '2.5.0~dev1'),
('2.5.0b1', None, None, 'deb_version', '2.5.0~b1'),
('2.5.0', None, None, 'deb_version', '2.5.0'),
('2.5.0dev1', None, None, 'deb_release', '1'),
('2.5.0b1', 2, None, 'deb_release', '2'),
('2.5.0dev1', None, None, 'rpm_release', '0.1.dev1'),
('2.5.0a1', None, None, 'rpm_release', '0.101.a1'),
('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', 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