Skip to content
Open
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: 1 addition & 1 deletion src/helm/common/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def ensure_file_downloaded(
shell([downloader_executable, source_url, "-O", tmp_path])
else:
try:
print("Downloading source_url")
hlog(f"Downloading {source_url}")
urllib.request.urlretrieve(source_url, tmp_path)
except Exception as e:
if os.path.isfile(tmp_path):
Expand Down
19 changes: 19 additions & 0 deletions src/helm/common/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@ def test_ensure_file_downloaded():
shutil.rmtree("test-zip")


def test_ensure_file_downloaded_logs_url(monkeypatch, tmp_path):
source_url = "https://example.invalid/path/file.txt"
target_path = str(tmp_path / "file.txt")
messages = []

def fake_urlretrieve(url, filename):
with open(filename, "w") as f:
f.write("contents")

monkeypatch.setattr("helm.common.general.hlog", messages.append)
monkeypatch.setattr("urllib.request.urlretrieve", fake_urlretrieve)

ensure_file_downloaded(source_url, target_path)

assert os.path.exists(target_path)
assert messages[0] == f"Downloading {source_url}"
assert len(messages) == 2


def test_format_tags():
tags = ["tag_1", "tag_2", "tag_3"]
assert format_tags(tags) == "[tag_1,tag_2,tag_3]"
Expand Down