Skip to content

Commit

Permalink
test: Ensure executor accepts links
Browse files Browse the repository at this point in the history
  • Loading branch information
serverwentdown committed Oct 9, 2021
1 parent 58375e2 commit 4e1a154
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions tests/installation/test_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 4e1a154

Please sign in to comment.