@@ -52,27 +52,38 @@ def test_fetchrunner_downloads(patches):
52
52
assert "downloads" in runner .__dict__
53
53
54
54
55
- def test_fetchrunner_downloads_path (patches ):
55
+ @pytest .mark .parametrize ("output_dir" , [True , False ])
56
+ def test_fetchrunner_downloads_path (patches , output_dir ):
56
57
runner = utils .FetchRunner ()
57
58
patched = patches (
58
59
"pathlib" ,
60
+ ("FetchRunner.args" ,
61
+ dict (new_callable = PropertyMock )),
59
62
("FetchRunner.tempdir" ,
60
63
dict (new_callable = PropertyMock )),
61
64
prefix = "envoy.base.utils.fetch_runner" )
62
65
63
- with patched as (m_plib , m_temp ):
66
+ with patched as (m_plib , m_args , m_temp ):
67
+ if output_dir :
68
+ m_args .return_value .output = "dir"
64
69
assert (
65
70
runner .downloads_path
66
- == m_plib .Path .return_value .joinpath .return_value )
71
+ == (m_plib .Path .return_value .joinpath .return_value
72
+ if not output_dir
73
+ else m_plib .Path .return_value ))
67
74
75
+ assert "downloads_path" in runner .__dict__
68
76
assert (
69
77
m_plib .Path .call_args
70
- == [(m_temp .return_value .name , ), {}])
71
- assert (
72
- m_plib .Path .return_value .joinpath .call_args
73
- == [("downloads" , ), {}])
74
-
75
- assert "downloads_path" in runner .__dict__
78
+ == [((m_temp .return_value .name
79
+ if not output_dir
80
+ else m_args .return_value .output_path ), ), {}])
81
+ if not output_dir :
82
+ assert (
83
+ m_plib .Path .return_value .joinpath .call_args
84
+ == [("downloads" , ), {}])
85
+ else :
86
+ assert not m_plib .Path .return_value .joinpath .called
76
87
77
88
78
89
@pytest .mark .parametrize ("excludes" , ["" , "EXCLUDE_PATH" ])
@@ -593,7 +604,7 @@ def test_fetchrunner_hashed(patches):
593
604
== [(), {}])
594
605
595
606
596
- @pytest .mark .parametrize ("output" , ["json" , "NOTJSON " ])
607
+ @pytest .mark .parametrize ("output" , ["json" , "dir" , "OTHER " ])
597
608
@pytest .mark .parametrize ("path" , ["" , "PATH" ])
598
609
@pytest .mark .parametrize ("exists" , [True , False ])
599
610
@pytest .mark .parametrize ("empty" , [True , False ])
@@ -660,17 +671,20 @@ async def _concurrent():
660
671
m_log .return_value .debug .call_args_list [:5 ]
661
672
== [[(f"{ m_elapsed .return_value } Received:\n { x } \n " , ), {}]
662
673
for x in items ])
663
-
664
- if output == "json" :
674
+ if output in ("json" , "dir" ):
665
675
assert result == 0
666
- assert (
667
- m_print .call_args
668
- == [(m_json .dumps .return_value , ), {}])
669
676
assert len (m_log .return_value .debug .call_args_list ) == 5
670
- assert (
671
- m_json .dumps .call_args
672
- == [({k : v .decode () for k , v in items .items ()},), {}])
673
677
assert not m_asyncio .to_thread .called
678
+ if output == "json" :
679
+ assert (
680
+ m_print .call_args
681
+ == [(m_json .dumps .return_value , ), {}])
682
+ assert (
683
+ m_json .dumps .call_args
684
+ == [({k : v .decode () for k , v in items .items ()},), {}])
685
+ else :
686
+ assert not m_print .called
687
+ assert not m_json .dumps .called
674
688
return
675
689
if not path :
676
690
assert result == 0
0 commit comments