Commit 6473994b by Fredrik Averpil Committed by GitHub

chef: make cached artifact uri platform independent

Cached artifact uri was previously constructed manually using a string
representation of the artifact path. This change ensures that the uri 
is generated by pathlib instead.

Resolves: #2744

Co-authored-by: Fredrik Averpil <fredrik.averpil@ericsson.com>
Co-authored-by: Arun Babu Neelicattu <arun.neelicattu@gmail.com>
parent 50360f2d
...@@ -81,7 +81,7 @@ class Chef: ...@@ -81,7 +81,7 @@ class Chef:
links = [] links = []
for archive_type in archive_types: for archive_type in archive_types:
for archive in cache_dir.glob("*.{}".format(archive_type)): for archive in cache_dir.glob("*.{}".format(archive_type)):
links.append(Link("file://{}".format(str(archive)))) links.append(Link(archive.as_uri()))
return links return links
......
...@@ -44,17 +44,19 @@ def test_get_cached_archives_for_link(config, mocker): ...@@ -44,17 +44,19 @@ def test_get_cached_archives_for_link(config, mocker):
), ),
) )
distributions = Path(__file__).parent.parent.joinpath("fixtures/distributions")
mocker.patch.object( mocker.patch.object(
chef, chef, "get_cache_directory_for_link", return_value=distributions,
"get_cache_directory_for_link",
return_value=Path(__file__).parent.parent.joinpath("fixtures/distributions"),
) )
archives = chef.get_cached_archives_for_link( archives = chef.get_cached_archives_for_link(
Link("https://files.python-poetry.org/demo-0.1.0.tar.gz") Link("https://files.python-poetry.org/demo-0.1.0.tar.gz")
) )
assert 2 == len(archives) assert archives
assert set(archives) == {
Link(path.as_uri()) for path in distributions.glob("demo-0.1.0*")
}
def test_get_cache_directory_for_link(config): def test_get_cache_directory_for_link(config):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment