Skip to content

Commit

Permalink
Added a function to check if the repository endpoint is none
Browse files Browse the repository at this point in the history
Leapp is not able to handle these types of repositories, so we should refrain from adding them.
  • Loading branch information
Mikhail Sandakov committed May 9, 2024
1 parent d58b275 commit 5bdfc7a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pleskdistup/common/src/rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,17 @@ def upgrade_packages(pkgs: typing.Optional[typing.List[str]] = None) -> None:

def autoremove_outdated_packages() -> None:
util.logged_check_call(["/usr/bin/yum", "autoremove", "-y"])


def repository_has_none_link(
id: typing.Optional[str],
name: typing.Optional[str],
url: typing.Optional[str],
metalink: typing.Optional[str],
mirrorlist: typing.Optional[str]
) -> bool:
for link in (url, metalink, mirrorlist):
if link is not None and link.lower() == "none":
return True

return False
20 changes: 20 additions & 0 deletions pleskdistup/common/tests/rpmtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,3 +377,23 @@ def test_handle_whole_directory(self):
self.assertEqual(open(full_filepath).read(), content)

shutil.rmtree(self.test_dir)


class repositoryHasNoneLinkTest(unittest.TestCase):
def test_no_link(self):
self.assertFalse(rpm.repository_has_none_link(None, None, None, None, None))

def test_url(self):
self.assertTrue(rpm.repository_has_none_link("id", "name", "none", None, None))

def test_metalink(self):
self.assertTrue(rpm.repository_has_none_link("id", "name", None, "none", None))

def test_mirrorlist(self):
self.assertTrue(rpm.repository_has_none_link("id", "name", None, None, "none"))

def test_all(self):
self.assertTrue(rpm.repository_has_none_link("id", "name", "none", "none", "none"))

def test_links_are_fine(self):
self.assertFalse(rpm.repository_has_none_link("id", "name", "url", "metalink", "mirrorlist"))

0 comments on commit 5bdfc7a

Please sign in to comment.