Skip to content

Instantly share code, notes, and snippets.

@abadger
Created September 19, 2023 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abadger/15ebd7845a3f21c9a3e7a7d7de7c36b7 to your computer and use it in GitHub Desktop.
Save abadger/15ebd7845a3f21c9a3e7a7d7de7c36b7 to your computer and use it in GitHub Desktop.
@pytest.mark.parametrize(
("bad_output_from_extract",),
(
[
[
"convert2rhel-0:0.18.0-1.el7.noarch",
"Not a NEVRA that we was not filtered due to a bug",
"convert2rhel-0:0.20.0-1.el7.noarch",
],
],
)
)
@pytest.mark.parametrize(
("convert2rhel_latest_version_test",),
(
[
{
"local_version": "0.19.0",
"package_version_repoquery": "C2R convert2rhel-0:0.18.0-1.el7.noarch\nNot a NEVRA that we was not filtered due to a bug\nC2R convert2rhel-0:0.20.0-1.el7.noarch",
"package_version_qf": "C2R convert2rhel-0:0.19.0-1.el7.noarch",
"package_version_V": 0,
"pmajor": "8",
"running_version": "0:0.19.0-1.el7",
"latest_version": "0:0.20-1.el7",
},
],
),
indirect=True,
)
def test_bad_NEVRA_to_parse_pkg_string(self, bad_output_from_extract, convert2rhel_latest_action, convert2rhel_latest_version_test, monkeypatch):
monkeypatch.setattr(convert2rhel_latest, "_extract_convert2rhel_versions",
mock.Mock(spec=convert2rhel_latest._extract_convert2rhel_versions,
side_effect=fake_extract_convert2rhel_versions))
convert2rhel_latest_action.run()
running_version, latest_version = convert2rhel_latest_version_test
unit_tests.assert_actions_result(
convert2rhel_latest_action,
level="ERROR",
id="OUT_OF_DATE",
title="Outdated convert2rhel version detected",
description="An outdated convert2rhel version has been detected",
diagnosis=(
"You are currently running %s and the latest version of convert2rhel is %s.\n"
"Only the latest version is supported for conversion." % (running_version, latest_version)
),
remediation="If you want to ignore this check, then set the environment variable 'CONVERT2RHEL_ALLOW_OLDER_VERSION=1' to continue.",
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment