diff --git a/convert2rhel/actions/conversion/list_non_red_hat_pkgs_left.py b/convert2rhel/actions/conversion/list_non_red_hat_pkgs_left.py
new file mode 100644
index 0000000000..34fe2a924e
--- /dev/null
+++ b/convert2rhel/actions/conversion/list_non_red_hat_pkgs_left.py
@@ -0,0 +1,43 @@
+# Copyright(C) 2024 Red Hat, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+__metaclass__ = type
+
+import logging
+
+from convert2rhel import actions
+from convert2rhel.pkghandler import get_installed_pkgs_w_different_fingerprint, print_pkg_info
+from convert2rhel.systeminfo import system_info
+
+
+loggerinst = logging.getLogger(__name__)
+
+
+class ListNonRedHatPkgsLeft(actions.Action):
+ id = "LIST_NON_RED_HAT_PKGS_LEFT"
+
+ def run(self):
+ """List all the packages that have not been replaced by the
+ Red Hat-signed ones during the conversion.
+ """
+ super(ListNonRedHatPkgsLeft, self).run()
+ loggerinst.info("Listing packages not signed by Red Hat")
+ non_red_hat_pkgs = get_installed_pkgs_w_different_fingerprint(system_info.fingerprints_rhel)
+ if not non_red_hat_pkgs:
+ loggerinst.info("All packages are now signed by Red Hat.")
+ return
+
+ loggerinst.info("The following packages were left unchanged.\n")
+ print_pkg_info(non_red_hat_pkgs)
diff --git a/convert2rhel/main.py b/convert2rhel/main.py
index b3e394affe..82f1909078 100644
--- a/convert2rhel/main.py
+++ b/convert2rhel/main.py
@@ -391,8 +391,6 @@ def post_ponr_changes():
def post_ponr_conversion():
"""Perform main steps for system conversion."""
- loggerinst.task("Convert: List remaining non-Red Hat packages")
- pkghandler.list_non_red_hat_pkgs_left()
loggerinst.task("Convert: Configure the bootloader")
grub.post_ponr_set_efi_configuration()
loggerinst.task("Convert: Patch yum configuration file")
diff --git a/convert2rhel/pkghandler.py b/convert2rhel/pkghandler.py
index bf561e3723..59fc72a33f 100644
--- a/convert2rhel/pkghandler.py
+++ b/convert2rhel/pkghandler.py
@@ -536,19 +536,6 @@ def get_vendor(pkg_obj):
return pkg_obj.vendor if pkg_obj.vendor else "N/A"
-def list_non_red_hat_pkgs_left():
- """List all the packages that have not been replaced by the
- Red Hat-signed ones during the conversion.
- """
- loggerinst.info("Listing packages not signed by Red Hat")
- non_red_hat_pkgs = get_installed_pkgs_w_different_fingerprint(system_info.fingerprints_rhel)
- if non_red_hat_pkgs:
- loggerinst.info("The following packages were left unchanged.\n")
- print_pkg_info(non_red_hat_pkgs)
- else:
- loggerinst.info("All packages are now signed by Red Hat.")
-
-
def get_pkg_nevras(pkg_objects):
"""Get a list of package NEVRA strings from a list of PackageInformation objects."""
return [get_pkg_nevra(pkg_obj) for pkg_obj in pkg_objects]
diff --git a/convert2rhel/unit_tests/actions/conversion/list_non_red_hat_pkgs_left_test.py b/convert2rhel/unit_tests/actions/conversion/list_non_red_hat_pkgs_left_test.py
new file mode 100644
index 0000000000..bdb2dfd175
--- /dev/null
+++ b/convert2rhel/unit_tests/actions/conversion/list_non_red_hat_pkgs_left_test.py
@@ -0,0 +1,54 @@
+# Copyright(C) 2024 Red Hat, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+__metaclass__ = type
+
+
+import pytest
+import six
+
+from convert2rhel.actions.conversion import list_non_red_hat_pkgs_left
+
+
+six.add_move(six.MovedModule("mock", "mock", "unittest.mock"))
+
+from convert2rhel import pkghandler
+from convert2rhel.unit_tests import FormatPkgInfoMocked, GetInstalledPkgInformationMocked
+
+
+@pytest.fixture
+def list_non_red_hat_pkgs_left_instance():
+ return list_non_red_hat_pkgs_left.ListNonRedHatPkgsLeft()
+
+
+def test_list_non_red_hat_pkgs_left(list_non_red_hat_pkgs_left_instance, monkeypatch):
+ monkeypatch.setattr(pkghandler, "format_pkg_info", FormatPkgInfoMocked())
+ monkeypatch.setattr(
+ pkghandler, "get_installed_pkg_information", GetInstalledPkgInformationMocked(pkg_selection="fingerprints")
+ )
+ list_non_red_hat_pkgs_left_instance.run()
+
+ assert len(pkghandler.format_pkg_info.call_args[0][0]) == 1
+ assert pkghandler.format_pkg_info.call_args[0][0][0].nevra.name == "pkg2"
+
+
+def test_no_non_red_hat_pkgs_left(list_non_red_hat_pkgs_left_instance, monkeypatch, caplog):
+ monkeypatch.setattr(pkghandler, "format_pkg_info", FormatPkgInfoMocked())
+ monkeypatch.setattr(
+ pkghandler, "get_installed_pkg_information", GetInstalledPkgInformationMocked(pkg_selection="empty")
+ )
+ list_non_red_hat_pkgs_left_instance.run()
+
+ assert "All packages are now signed by Red Hat." in caplog.records[-1].message
diff --git a/convert2rhel/unit_tests/main_test.py b/convert2rhel/unit_tests/main_test.py
index 2b542daf98..501d4810d5 100644
--- a/convert2rhel/unit_tests/main_test.py
+++ b/convert2rhel/unit_tests/main_test.py
@@ -207,19 +207,16 @@ def test_show_eula_nonexisting_file(self, caplog, monkeypatch, tmpdir):
def test_post_ponr_conversion(monkeypatch):
- list_non_red_hat_pkgs_left_mock = mock.Mock()
post_ponr_set_efi_configuration_mock = mock.Mock()
yum_conf_patch_mock = mock.Mock()
lock_releasever_in_rhel_repositories_mock = mock.Mock()
- monkeypatch.setattr(pkghandler, "list_non_red_hat_pkgs_left", list_non_red_hat_pkgs_left_mock)
monkeypatch.setattr(grub, "post_ponr_set_efi_configuration", post_ponr_set_efi_configuration_mock)
monkeypatch.setattr(redhatrelease.YumConf, "patch", yum_conf_patch_mock)
monkeypatch.setattr(subscription, "lock_releasever_in_rhel_repositories", lock_releasever_in_rhel_repositories_mock)
main.post_ponr_conversion()
- assert list_non_red_hat_pkgs_left_mock.call_count == 1
assert post_ponr_set_efi_configuration_mock.call_count == 1
assert yum_conf_patch_mock.call_count == 1
assert lock_releasever_in_rhel_repositories_mock.call_count == 1
diff --git a/convert2rhel/unit_tests/pkghandler_test.py b/convert2rhel/unit_tests/pkghandler_test.py
index a3ef0e3719..666215a2e0 100644
--- a/convert2rhel/unit_tests/pkghandler_test.py
+++ b/convert2rhel/unit_tests/pkghandler_test.py
@@ -1483,17 +1483,6 @@ def test_get_third_party_pkgs(fingerprint_orig_os, expected_count, expected_pkgs
assert len(pkgs) == expected_pkgs
-def test_list_non_red_hat_pkgs_left(monkeypatch):
- monkeypatch.setattr(pkghandler, "format_pkg_info", FormatPkgInfoMocked())
- monkeypatch.setattr(
- pkghandler, "get_installed_pkg_information", GetInstalledPkgInformationMocked(pkg_selection="fingerprints")
- )
- pkghandler.list_non_red_hat_pkgs_left()
-
- assert len(pkghandler.format_pkg_info.call_args[0][0]) == 1
- assert pkghandler.format_pkg_info.call_args[0][0][0].nevra.name == "pkg2"
-
-
@pytest.mark.parametrize(
("package_name", "subprocess_output", "expected", "expected_command"),
(