feat(worker): Last.fm artist.getSimilar as a second discovery SimilaritySource
Adds LastfmSource, resolving Last.fm's often-empty artist mbid via the injected MB browser (name->mbid cached) so every emitted SimilarArtist.mbid is a real MusicBrainz artist MBID. Registered in build_similarity_sources, gated on lastfm.api_key so the ListenBrainz-only path is unchanged when unset.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from lyra_worker.registry import build_similarity_sources
|
||||
from lyra_worker.similarity._lastfm import LastfmSource
|
||||
from lyra_worker.similarity._listenbrainz import ListenBrainzSource
|
||||
|
||||
|
||||
@@ -12,3 +13,17 @@ def test_build_returns_listenbrainz_by_default():
|
||||
def test_base_url_override_from_config():
|
||||
src = build_similarity_sources({"discover.listenBrainzUrl": "http://lb.local"})[0]
|
||||
assert src._base == "http://lb.local"
|
||||
|
||||
|
||||
def test_lastfm_added_when_api_key_configured():
|
||||
sources = build_similarity_sources({"lastfm.api_key": "secret-key"})
|
||||
names = [s.name for s in sources]
|
||||
assert names == ["listenbrainz", "lastfm"]
|
||||
lastfm = next(s for s in sources if s.name == "lastfm")
|
||||
assert isinstance(lastfm, LastfmSource)
|
||||
assert lastfm._key == "secret-key"
|
||||
|
||||
|
||||
def test_lastfm_omitted_without_api_key():
|
||||
sources = build_similarity_sources({})
|
||||
assert all(s.name != "lastfm" for s in sources)
|
||||
|
||||
Reference in New Issue
Block a user