fix(amazon): add set_engine/set_shutdown_check so _engine gets wired

AmazonDownloadClient was missing set_engine() and set_shutdown_check().
The download engine auto-wires plugins by calling set_engine(self) at
registration time if the method exists (engine.py:136). Without it,
_engine stayed None forever, causing every download() call to raise
RuntimeError("_engine is not set") — silently failing and marking all
tracks not found.

All other streaming clients (Deezer, Qobuz, Tidal, HiFi, SoundCloud)
expose set_engine(); Amazon now matches the pattern.

Tests added: set_engine wires _engine, set_shutdown_check wires callback,
set_engine unblocks download dispatch (the exact live failure mode).
pull/615/head
Broque Thomas 1 week ago
parent 791e3630ff
commit 9fb63ff86d

@ -95,6 +95,13 @@ class AmazonDownloadClient(DownloadSourcePlugin):
# DownloadSourcePlugin — lifecycle
# ------------------------------------------------------------------
def set_engine(self, engine) -> None:
"""Engine callback — wires the central thread worker + state store."""
self._engine = engine
def set_shutdown_check(self, check_callable) -> None:
self.shutdown_check = check_callable
def is_configured(self) -> bool:
# T2Tunes has a public default instance; no credentials required.
# Return True unconditionally so the source shows as available.

@ -679,6 +679,29 @@ class TestDownloadDispatch:
assert call[1]["target_id"] == "B09XYZ1234"
assert call[1]["display_name"] == "Artist - Title"
def test_set_engine_wires_engine(self, tmp_path):
client = _make_client(tmp_path)
assert client._engine is None
engine = MagicMock()
client.set_engine(engine)
assert client._engine is engine
def test_set_shutdown_check_wires_callback(self, tmp_path):
client = _make_client(tmp_path)
assert client.shutdown_check is None
check = lambda: False
client.set_shutdown_check(check)
assert client.shutdown_check is check
def test_set_engine_allows_download_dispatch(self, tmp_path):
"""set_engine() must unblock download() — the live failure mode."""
client = _make_client(tmp_path)
engine = MagicMock()
engine.worker.dispatch.return_value = "dl-wired"
client.set_engine(engine)
result = run(client.download("amazon", "B09XYZ1234||Artist - Title"))
assert result == "dl-wired"
# ---------------------------------------------------------------------------
# Status interface

Loading…
Cancel
Save