Skip to content

Commit

Permalink
chef: make cached artifact uri platform independent
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
3 people authored Jul 30, 2020
1 parent 50360f2 commit 6473994
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion poetry/installation/chef.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def get_cached_archives_for_link(self, link): # type: (Link) -> List[Link]
links = []
for archive_type in archive_types:
for archive in cache_dir.glob("*.{}".format(archive_type)):
links.append(Link("file://{}".format(str(archive))))
links.append(Link(archive.as_uri()))

return links

Expand Down
10 changes: 6 additions & 4 deletions tests/installation/test_chef.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,19 @@ def test_get_cached_archives_for_link(config, mocker):
),
)

distributions = Path(__file__).parent.parent.joinpath("fixtures/distributions")
mocker.patch.object(
chef,
"get_cache_directory_for_link",
return_value=Path(__file__).parent.parent.joinpath("fixtures/distributions"),
chef, "get_cache_directory_for_link", return_value=distributions,
)

archives = chef.get_cached_archives_for_link(
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):
Expand Down

0 comments on commit 6473994

Please sign in to comment.