fix(server): announce track title not album in messages; cover error paths

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-08 20:07:09 -07:00
parent f4ffd23ed8
commit 257ed5e0a5
2 changed files with 19 additions and 4 deletions

View File

@@ -1,7 +1,6 @@
"""Glue between a chosen Hit and a side-effecting download. Mirrors musicfetch's """Glue between a chosen Hit and a side-effecting download. Mirrors musicfetch's
main() dispatch but returns a structured result dict and speakable messages.""" main() dispatch but returns a structured result dict and speakable messages."""
import os import os
from typing import Optional
from . import mf from . import mf
@@ -11,7 +10,7 @@ def _source_label(hit) -> str:
def _title(hit) -> str: def _title(hit) -> str:
return hit.album or hit.title or hit.artist return hit.album if hit.kind == "album" else (hit.title or hit.album or hit.artist)
def started_message(hit) -> str: def started_message(hit) -> str:

View File

@@ -1,3 +1,5 @@
import pytest
from server import actions, mf from server import actions, mf
@@ -15,14 +17,14 @@ def make_lidarr_album_hit():
def test_started_message_mentions_source_and_title(): def test_started_message_mentions_source_and_title():
msg = actions.started_message(make_yt_hit()) msg = actions.started_message(make_yt_hit())
assert "Under My Skin" in msg assert "Together" in msg
assert "Avril Lavigne" in msg assert "Avril Lavigne" in msg
assert "YouTube" in msg assert "YouTube" in msg
def test_done_message_mentions_title(): def test_done_message_mentions_title():
msg = actions.done_message(make_yt_hit()) msg = actions.done_message(make_yt_hit())
assert "Under My Skin" in msg assert "Together" in msg
assert "Avril Lavigne" in msg assert "Avril Lavigne" in msg
@@ -58,3 +60,17 @@ def test_perform_lidarr_album_fallsthrough_to_youtube(monkeypatch):
quality="best", root="/media/music") quality="best", root="/media/music")
assert yt_calls["hit"] is yt_hit assert yt_calls["hit"] is yt_hit
assert result["path"] == "/media/music/Avril Lavigne/youtube" assert result["path"] == "/media/music/Avril Lavigne/youtube"
def test_perform_lidarr_album_no_release_no_fallback_raises(monkeypatch):
monkeypatch.setattr(mf, "act_lidarr_album",
lambda hit, root, search_all, dry_run: False)
hit = make_lidarr_album_hit()
with pytest.raises(RuntimeError):
actions.perform_fetch(hit, [hit], quality="best", root="/media/music")
def test_failed_message_mentions_title_and_artist():
msg = actions.failed_message(make_yt_hit())
assert "Together" in msg
assert "Avril Lavigne" in msg