diff --git a/tests/installation/test_executor.py b/tests/installation/test_executor.py index c892b92ee3e..d5c9786851b 100644 --- a/tests/installation/test_executor.py +++ b/tests/installation/test_executor.py @@ -327,3 +327,60 @@ def test_executor_should_check_every_possible_hash_types_before_failing( Install(package), Link("https://example.com/demo-0.1.0-py2.py3-none-any.whl"), ) + + +def test_executor_should_hash_links( + config, io, pool, mocker, fixture_dir, tmp_dir +): + # Produce a file:/// URI that is a valid link + link = Link(fixture_dir("distributions").joinpath( + "demo-0.1.0-py2.py3-none-any.whl" + ).as_uri()) + mocker.patch.object( + 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") + package.files = [ + { + "file": "demo-0.1.0-py2.py3-none-any.whl", + "hash": "md5:15507846fd4299596661d0197bfb4f90", + } + ] + + archive = executor._download_link( + Install(package), 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.object( + 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") + package.files = [ + { + "file": "demo-0.1.0-py2.py3-none-any.whl", + "hash": "md5:15507846fd4299596661d0197bfb4f90", + } + ] + + archive = executor._download_link( + Install(package), Link("https://example.com/demo-0.1.0-py2.py3-none-any.whl") + ) + + assert archive == link