feat: Tagger seam and pipeline tag-stage integration
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
from lyra_worker.adapters.qobuz import QobuzAdapter
|
||||
from lyra_worker.claim import claim_next
|
||||
from lyra_worker.pipeline import run_pipeline
|
||||
from tests.conftest import insert_request
|
||||
from tests.test_qobuz_adapter import FakeQobuzClient
|
||||
|
||||
|
||||
class RecordingTagger:
|
||||
def __init__(self, fail=False):
|
||||
self.calls = []
|
||||
self._fail = fail
|
||||
|
||||
def tag_album(self, album_dir, target):
|
||||
self.calls.append((album_dir, target))
|
||||
if self._fail:
|
||||
raise RuntimeError("tagging blew up")
|
||||
|
||||
|
||||
def test_tagger_called_with_album_dir_and_target(conn):
|
||||
tagger = RecordingTagger()
|
||||
job_id = insert_request(conn, artist="John Mayer", album="Continuum")
|
||||
claim_next(conn)
|
||||
run_pipeline(conn, job_id, [QobuzAdapter(FakeQobuzClient())], tagger=tagger, dest_root="/tmp/lib")
|
||||
|
||||
with conn.cursor() as cur:
|
||||
cur.execute('SELECT state FROM "Job" WHERE id = %s', (job_id,))
|
||||
assert cur.fetchone()[0] == "imported"
|
||||
assert len(tagger.calls) == 1
|
||||
album_dir, target = tagger.calls[0]
|
||||
assert album_dir == "/tmp/lib/John Mayer/Continuum"
|
||||
assert target.album == "Continuum"
|
||||
|
||||
|
||||
def test_tagger_failure_does_not_fail_the_job(conn):
|
||||
tagger = RecordingTagger(fail=True)
|
||||
job_id = insert_request(conn, artist="John Mayer", album="Continuum")
|
||||
claim_next(conn)
|
||||
run_pipeline(conn, job_id, [QobuzAdapter(FakeQobuzClient())], tagger=tagger, dest_root="/tmp/lib")
|
||||
|
||||
with conn.cursor() as cur:
|
||||
cur.execute('SELECT state FROM "Job" WHERE id = %s', (job_id,))
|
||||
assert cur.fetchone()[0] == "imported" # tagging error is logged, not fatal
|
||||
|
||||
|
||||
def test_no_tagger_still_imports(conn):
|
||||
job_id = insert_request(conn, artist="John Mayer", album="Continuum")
|
||||
claim_next(conn)
|
||||
run_pipeline(conn, job_id, [QobuzAdapter(FakeQobuzClient())], dest_root="/tmp/lib") # no tagger
|
||||
|
||||
with conn.cursor() as cur:
|
||||
cur.execute('SELECT state FROM "Job" WHERE id = %s', (job_id,))
|
||||
assert cur.fetchone()[0] == "imported"
|
||||
Reference in New Issue
Block a user