Skip to content

Commit 4e1a154

Browse files
test: Ensure executor accepts links
1 parent 58375e2 commit 4e1a154

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

tests/installation/test_executor.py

+57
Original file line numberDiff line numberDiff line change
@@ -327,3 +327,60 @@ def test_executor_should_check_every_possible_hash_types_before_failing(
327327
Install(package),
328328
Link("https://example.com/demo-0.1.0-py2.py3-none-any.whl"),
329329
)
330+
331+
332+
def test_executor_should_hash_links(config, io, pool, mocker, fixture_dir, tmp_dir):
333+
# Produce a file:/// URI that is a valid link
334+
link = Link(
335+
fixture_dir("distributions")
336+
.joinpath("demo-0.1.0-py2.py3-none-any.whl")
337+
.as_uri()
338+
)
339+
mocker.patch.object(
340+
Chef,
341+
"get_cached_archive_for_link",
342+
side_effect=lambda _: link,
343+
)
344+
345+
env = MockEnv(path=Path(tmp_dir))
346+
executor = Executor(env, pool, config, io)
347+
348+
package = Package("demo", "0.1.0")
349+
package.files = [
350+
{
351+
"file": "demo-0.1.0-py2.py3-none-any.whl",
352+
"hash": "md5:15507846fd4299596661d0197bfb4f90",
353+
}
354+
]
355+
356+
archive = executor._download_link(
357+
Install(package), Link("https://example.com/demo-0.1.0-py2.py3-none-any.whl")
358+
)
359+
360+
assert archive == link
361+
362+
363+
def test_executor_should_hash_paths(config, io, pool, mocker, fixture_dir, tmp_dir):
364+
link = fixture_dir("distributions").joinpath("demo-0.1.0-py2.py3-none-any.whl")
365+
mocker.patch.object(
366+
Chef,
367+
"get_cached_archive_for_link",
368+
side_effect=lambda _: link,
369+
)
370+
371+
env = MockEnv(path=Path(tmp_dir))
372+
executor = Executor(env, pool, config, io)
373+
374+
package = Package("demo", "0.1.0")
375+
package.files = [
376+
{
377+
"file": "demo-0.1.0-py2.py3-none-any.whl",
378+
"hash": "md5:15507846fd4299596661d0197bfb4f90",
379+
}
380+
]
381+
382+
archive = executor._download_link(
383+
Install(package), Link("https://example.com/demo-0.1.0-py2.py3-none-any.whl")
384+
)
385+
386+
assert archive == link

0 commit comments

Comments
 (0)