fus: Support HTTP repos

Recent version of fus gained ability to download repodata if repo is
provided as HTTP url.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2019-06-05 12:27:43 +02:00
parent ce066707c1
commit 0207260b9f
2 changed files with 28 additions and 13 deletions

View File

@ -62,13 +62,9 @@ def write_config(conf_file, modules, packages):
def _prep_path(path): def _prep_path(path):
"""Strip file:// from the path if present or raise exception for other """Strip file:// from the path if present."""
protocols. if path.startswith("file://"):
""" return path[len("file://"):]
if "://" in path:
proto, path = path.split("://", 2)
if proto != "file":
raise ValueError("Only repositories on local filesystem are supported.")
return path return path

View File

@ -63,9 +63,19 @@ class TestGetCmd(unittest.TestCase):
], ],
) )
def test_fail_on_http_repo(self): def test_preserves_http_protocol(self):
with self.assertRaises(ValueError): cmd = fus.get_cmd("conf", "x86_64", [], ["http://r"])
fus.get_cmd("conf", "x86_64", ["http:///tmp"], []) self.assertEqual(
cmd,
[
"fus",
"--verbose",
"--arch",
"x86_64",
"--repo=lookaside-0,lookaside,http://r",
"@conf",
],
)
def test_strip_file_protocol_lookaside(self): def test_strip_file_protocol_lookaside(self):
cmd = fus.get_cmd("conf", "x86_64", [], ["file:///r"]) cmd = fus.get_cmd("conf", "x86_64", [], ["file:///r"])
@ -81,9 +91,18 @@ class TestGetCmd(unittest.TestCase):
], ],
) )
def test_fail_on_http_repo_lookaside(self): def test_preserves_http_protocol_lookaside(self):
with self.assertRaises(ValueError): self.assertEqual(
fus.get_cmd("conf", "x86_64", [], ["http:///tmp"]) fus.get_cmd("conf", "x86_64", [], ["http:///tmp"]),
[
"fus",
"--verbose",
"--arch",
"x86_64",
"--repo=lookaside-0,lookaside,http:///tmp",
"@conf",
]
)
class TestWriteConfig(PungiTestCase): class TestWriteConfig(PungiTestCase):