diff --git a/core/amazon_download_client.py b/core/amazon_download_client.py index 0273f81f..fb5dcdb6 100644 --- a/core/amazon_download_client.py +++ b/core/amazon_download_client.py @@ -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. diff --git a/tests/tools/test_amazon_download_client.py b/tests/tools/test_amazon_download_client.py index c591f7fb..0ab0f85b 100644 --- a/tests/tools/test_amazon_download_client.py +++ b/tests/tools/test_amazon_download_client.py @@ -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