diff --git a/convert2rhel/pkghandler.py b/convert2rhel/pkghandler.py index c598cb6add..16a0196c9a 100644 --- a/convert2rhel/pkghandler.py +++ b/convert2rhel/pkghandler.py @@ -1024,18 +1024,9 @@ def get_total_packages_to_update(): def _get_packages_to_update_yum(): - """Query all the packages with yum that has an update pending on the - system.""" - # Check first if this path is not in the `sys.path` - if "/usr/share/yum-cli" not in sys.path: - # Yum's installation path for the CLI code - # https://github.com/rpm-software-management/yum/blob/4ed25525ee4781907bd204018c27f44948ed83fe/bin/yum#L26 - sys.path.insert(0, "/usr/share/yum-cli") - - from cli import YumBaseCli # pylint: disable=E0401 - - base = YumBaseCli() - packages = base.returnPkgLists(["updates"], None) + """Query all the packages with yum that has an update pending on the system.""" + base = pkgmanager.YumBase() + packages = base.doPackageLists(pkgnarrow="updates") all_packages = [] for package in packages.updates: all_packages.append(package.name) @@ -1044,12 +1035,9 @@ def _get_packages_to_update_yum(): def _get_packages_to_update_dnf(): - """Query all the packages with dnf that has an update pending on the - system.""" - from dnf import Base # pylint: disable=E0401 - + """Query all the packages with dnf that has an update pending on the system.""" packages = [] - base = Base() + base = pkgmanager.Base() # Fix the case when we are trying to query packages in Oracle Linux 8 # when the DNF API gets called, those variables are not populated by default. if system_info.id == "oracle": diff --git a/convert2rhel/unit_tests/pkghandler_test.py b/convert2rhel/unit_tests/pkghandler_test.py index 2defc6b464..5e9785f1c4 100644 --- a/convert2rhel/unit_tests/pkghandler_test.py +++ b/convert2rhel/unit_tests/pkghandler_test.py @@ -1502,8 +1502,7 @@ def test_get_total_packages_to_update(package_manager_type, packages, monkeypatc ) @pytest.mark.parametrize(("packages"), ((["package-1", "package-2", "package-3"],))) def test_get_packages_to_update_yum(packages, monkeypatch): - sys.path.insert(0, "/usr/share/yum-cli") - from cli import YumBaseCli # pylint: disable=E0401 + from yum import YumBase # pylint: disable=E0401 PkgName = namedtuple("PkgNames", ["name"]) PkgUpdates = namedtuple("PkgUpdates", ["updates"]) @@ -1513,11 +1512,8 @@ def test_get_packages_to_update_yum(packages, monkeypatch): pkg_lists_mock = mock.Mock(return_value=PkgUpdates(transaction_pkgs)) - monkeypatch.setattr(YumBaseCli, "returnPkgLists", value=pkg_lists_mock) + monkeypatch.setattr(YumBase, "doPackageLists", value=pkg_lists_mock) - # Remvoe the /usr/share/yum-cli from the system path so the code - # can load it - sys.path.remove("/usr/share/yum-cli") assert _get_packages_to_update_yum() == packages