From 3ed345dae7bee789f17a11514103518d047960c2 Mon Sep 17 00:00:00 2001 From: Rodolfo Olivieri Date: Wed, 3 Jul 2024 11:34:39 -0300 Subject: [PATCH] Use enablerepo instead of no_rhsm to check custom repos We were using the no_rhsm option to skip the check for custom repositories, and since the system can be unregistered or pre-registered, there is no need anymore to use no_rhsm in this action, instead, we can use enablerepo directly to validate if the repositories are valid or not. --- .../actions/system_checks/custom_repos_are_valid.py | 4 ++-- .../actions/system_checks/custom_repos_are_valid_test.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/convert2rhel/actions/system_checks/custom_repos_are_valid.py b/convert2rhel/actions/system_checks/custom_repos_are_valid.py index 3f4ae4657..c55108a0e 100644 --- a/convert2rhel/actions/system_checks/custom_repos_are_valid.py +++ b/convert2rhel/actions/system_checks/custom_repos_are_valid.py @@ -37,8 +37,8 @@ def run(self): super(CustomReposAreValid, self).run() logger.task("Prepare: Check if --enablerepo repositories are accessible") - if not tool_opts.no_rhsm: - logger.info("Did not perform the check of repositories due to the use of RHSM for the conversion.") + if not tool_opts.enablerepo: + logger.info("Skipping the check as there was no --enablerepo option detected in the command-line.") return output, ret_code = call_yum_cmd( diff --git a/convert2rhel/unit_tests/actions/system_checks/custom_repos_are_valid_test.py b/convert2rhel/unit_tests/actions/system_checks/custom_repos_are_valid_test.py index a752f4d2b..ed28311fe 100644 --- a/convert2rhel/unit_tests/actions/system_checks/custom_repos_are_valid_test.py +++ b/convert2rhel/unit_tests/actions/system_checks/custom_repos_are_valid_test.py @@ -34,7 +34,7 @@ def test_custom_repos_are_valid(custom_repos_are_valid_action, monkeypatch, capl "call_yum_cmd", unit_tests.CallYumCmdMocked(return_code=0, return_string="Abcdef"), ) - monkeypatch.setattr(custom_repos_are_valid.tool_opts, "no_rhsm", True) + monkeypatch.setattr(custom_repos_are_valid.tool_opts, "enablerepo", ["rhel-7-server-optional-rpms"]) custom_repos_are_valid_action.run() @@ -47,7 +47,7 @@ def test_custom_repos_are_invalid(custom_repos_are_valid_action, monkeypatch): "call_yum_cmd", unit_tests.CallYumCmdMocked(return_code=1, return_string="YUM/DNF failed"), ) - monkeypatch.setattr(custom_repos_are_valid.tool_opts, "no_rhsm", True) + monkeypatch.setattr(custom_repos_are_valid.tool_opts, "enablerepo", ["rhel-7-server-optional-rpms"]) custom_repos_are_valid_action.run() @@ -63,11 +63,11 @@ def test_custom_repos_are_invalid(custom_repos_are_valid_action, monkeypatch): def test_custom_repos_are_valid_skip(custom_repos_are_valid_action, monkeypatch, caplog): - monkeypatch.setattr(custom_repos_are_valid.tool_opts, "no_rhsm", False) + monkeypatch.setattr(custom_repos_are_valid.tool_opts, "enablerepo", []) custom_repos_are_valid_action.run() assert ( - "Did not perform the check of repositories due to the use of RHSM for the conversion." + "Skipping the check as there was no --enablerepo option detected in the command-line." in caplog.records[-1].message )