Files
ozan 98890b9581 Add pytest suite, unlimited daily cap, and vocal batch generator.
Tests cover curation, Lyria, queue, and API routes. Setting max_new_songs_per_day to 0 disables the limit; generate-batch runs 20 curated multilingual vocal directions.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-07 15:33:58 +01:00

59 lines
1.6 KiB
Python

from __future__ import annotations
from pathlib import Path
from ozan_radio.dj import TrackPlan
from ozan_radio.lyria import GeneratedTrack
from ozan_radio.queue import RadioQueue
def _track(tmp_path: Path, track_id: str, title: str) -> GeneratedTrack:
safe = title.replace(" ", "_")
path = tmp_path / f"{track_id}_{safe}.mp3"
path.write_bytes(b"ID3")
plan = TrackPlan(
id=track_id,
title=title,
mood="test",
dj_line="on air",
lyria_prompt="test prompt",
)
return GeneratedTrack(plan=plan, audio_path=path, lyrics="")
def test_queue_add_and_advance(tmp_path: Path):
q = RadioQueue(tmp_path)
q.add(_track(tmp_path, "aaaa1111", "One"))
q.add(_track(tmp_path, "bbbb2222", "Two"))
assert q.length == 2
assert q.current().plan.title == "One"
q.advance()
assert q.current().plan.title == "Two"
def test_queue_prunes_stale_manifest_entries(tmp_path: Path):
q = RadioQueue(tmp_path)
q.add(_track(tmp_path, "aaaa1111", "Only"))
manifest = tmp_path / "manifest.json"
import json
data = json.loads(manifest.read_text(encoding="utf-8"))
data["tracks"].append(
{
"id": "ghost",
"title": "Ghost",
"mood": "",
"dj_line": "",
"lyria_prompt": "",
"lyrics": "",
"file": "ghost_Ghost.mp3",
}
)
manifest.write_text(json.dumps(data), encoding="utf-8")
q2 = RadioQueue(tmp_path)
assert q2.length == 1
cleaned = json.loads(manifest.read_text(encoding="utf-8"))
assert cleaned["count"] == 1
assert all(t["id"] != "ghost" for t in cleaned["tracks"])