feat: MbBrowser seam and FakeMbBrowser test double
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -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, []))
|
||||
|
||||
Reference in New Issue
Block a user