Skip to content

Commit

Permalink
fix: Properly trigger cache codepath in _download_link
Browse files Browse the repository at this point in the history
  • Loading branch information
serverwentdown committed Oct 21, 2021
1 parent c2baf68 commit 0f322be
Showing 1 changed file with 9 additions and 24 deletions.
33 changes: 9 additions & 24 deletions tests/installation/test_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,40 +468,25 @@ def test_executor_should_write_pep610_url_references_for_git(
)


def test_executor_should_hash_links(config, io, pool, mocker, fixture_dir, tmp_dir):
def test_executor_should_use_cached_link_and_hash(tmp_venv, pool, config, io, mocker, fixture_dir):
# Produce a file:/// URI that is a valid link
link = Link(
link_cached = Link(
fixture_dir("distributions")
.joinpath("demo-0.1.0-py2.py3-none-any.whl")
.as_uri()
)
mocker.patch(
"poetry.installation.chef.Chef.get_cached_archive_for_link",
side_effect=lambda _: link,
side_effect=lambda _: link_cached,
)

env = MockEnv(path=Path(tmp_dir))
executor = Executor(env, pool, config, io)

archive = executor._download_link(
Install(Package("demo", "0.1.0")),
Link("https://example.com/demo-0.1.0-py2.py3-none-any.whl"),
)
assert archive == link


def test_executor_should_hash_paths(config, io, pool, mocker, fixture_dir, tmp_dir):
link = fixture_dir("distributions").joinpath("demo-0.1.0-py2.py3-none-any.whl")
mocker.patch(
"poetry.installation.chef.Chef.get_cached_archive_for_link",
side_effect=lambda _: link,
)

env = MockEnv(path=Path(tmp_dir))
executor = Executor(env, pool, config, io)
package = Package("demo", "0.1.0")
# Set package.files so the executor will attempt to hash the package
package.files = [{"filename": "file1"}]

executor = Executor(tmp_venv, pool, config, io)
archive = executor._download_link(
Install(Package("demo", "0.1.0")),
Install(package),
Link("https://example.com/demo-0.1.0-py2.py3-none-any.whl"),
)
assert archive == link
assert archive == link_cached

0 comments on commit 0f322be

Please sign in to comment.