feat: MbBrowser seam and FakeMbBrowser test double

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonathan
2026-07-11 12:12:17 +02:00
parent ec85016d88
commit 2ca0f7a385
3 changed files with 57 additions and 0 deletions
+15
View File
@@ -1,5 +1,6 @@
from typing import Callable
from lyra_worker.browser import ArtistHit, ReleaseGroupInfo
from lyra_worker.types import Candidate, DownloadResult, MBTarget, Quality
_QUALITIES = {
@@ -66,3 +67,17 @@ class FailingAdapter(_BaseFake):
self, candidate: Candidate, dest: str, on_progress: Callable[[float], None]
) -> DownloadResult:
return DownloadResult(ok=False, error="simulated download failure")
class FakeMbBrowser:
"""In-memory MbBrowser for tests. `releases` maps artist mbid -> [ReleaseGroupInfo]."""
def __init__(self, artists=None, releases=None):
self._artists = list(artists or [])
self._releases = dict(releases or {})
def search_artist(self, name: str) -> list[ArtistHit]:
return list(self._artists)
def browse_release_groups(self, artist_mbid: str) -> list[ReleaseGroupInfo]:
return list(self._releases.get(artist_mbid, []))