Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

envoy.base.utils: Minor fix for empty output dir (fetch) #2213

Merged
merged 1 commit into from
Aug 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions envoy.base.utils/envoy/base/utils/fetch_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ async def run(self) -> Optional[int]:

if not self.args.output_path:
return 0
if not any(self.downloads_path.iterdir()):
return 0
self.log.debug(
f"{self.time_elapsed} "
f"Packing:\n"
Expand Down
19 changes: 17 additions & 2 deletions envoy.base.utils/tests/test_fetch_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,11 @@ def test_fetchrunner_hashed(patches):

@pytest.mark.parametrize("output", ["json", "NOTJSON"])
@pytest.mark.parametrize("path", ["", "PATH"])
async def test_fetchrunner_run(patches, iters, output, path):
@pytest.mark.parametrize("empty", [True, False])
async def test_fetchrunner_run(patches, iters, output, path, empty):
runner = utils.FetchRunner()
patched = patches(
"any",
"asyncio",
"concurrent",
"json",
Expand All @@ -603,9 +605,10 @@ async def _concurrent():
yield item, items[item]

with patched as patchy:
(m_asyncio, m_concurrent, m_json, m_print,
(m_any, m_asyncio, m_concurrent, m_json, m_print,
m_utils, m_excluded, m_fetch, m_args,
m_downloads, m_path, m_log, m_elapsed) = patchy
m_any.return_value = not empty
m_args.return_value.output = output
m_args.return_value.output_path = path
_to_thread = AsyncMock()
Expand Down Expand Up @@ -650,6 +653,18 @@ async def _concurrent():
assert result == 0
assert len(m_log.return_value.debug.call_args_list) == 5
assert not m_asyncio.to_thread.called
assert not m_any.called
return
if empty:
assert result == 0
assert len(m_log.return_value.debug.call_args_list) == 5
assert not m_asyncio.to_thread.called
assert (
m_any.call_args
== [(m_path.return_value.iterdir.return_value, ), {}])
assert (
m_path.return_value.iterdir.call_args
== [(), {}])
return
assert (
m_log.return_value.debug.call_args_list[5]
Expand Down