Skip to content

Commit

Permalink
Use enablerepo instead of no_rhsm to check custom repos
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
r0x0d committed Jul 3, 2024
1 parent 5c42c1f commit 3c983c8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions convert2rhel/actions/system_checks/custom_repos_are_valid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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()

Expand All @@ -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
)

0 comments on commit 3c983c8

Please sign in to comment.