@@ -327,3 +327,60 @@ def test_executor_should_check_every_possible_hash_types_before_failing(
327
327
Install (package ),
328
328
Link ("https://example.com/demo-0.1.0-py2.py3-none-any.whl" ),
329
329
)
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