Use partial() for download_web_files_in_config call sites; collapse dedup loop into a dict comp

- Both audio_file and speaker.media_player now use functools.partial to
  bind path_for=_compute_local_file_path instead of an inline lambda.
- download_content_many's dedup loop becomes a dict comprehension.
  Last-URL wins now (dict-comp semantics) instead of first-URL; in
  practice duplicate paths only arise when the URL itself is duplicated,
  so the choice is meaningless. Test updated accordingly.
This commit is contained in:
J. Nick Koston
2026-04-26 10:02:44 -05:00
parent 2e037308de
commit 2def20c646
4 changed files with 14 additions and 11 deletions
+3 -3
View File
@@ -368,7 +368,9 @@ def test_download_content_many_dedupes_by_path(
mock_download_content: MagicMock, setup_core: Path
) -> None:
"""Two items pointing at the same cache path must collapse to one
download -- otherwise concurrent writes race on the same file.
download -- otherwise concurrent writes race on the same file. Which
URL wins doesn't matter (in practice duplicate paths only arise when
the URL is duplicated), so we only assert the call count and path.
"""
path = setup_core / "shared"
items = [
@@ -378,9 +380,7 @@ def test_download_content_many_dedupes_by_path(
]
external_files.download_content_many(items)
assert mock_download_content.call_count == 1
# First-seen URL wins, matching dict-insertion order.
args, _ = mock_download_content.call_args
assert args[0] == "https://example.com/a"
assert args[1] == path