98890b9581
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>
60 lines
2.5 KiB
Python
60 lines
2.5 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
from pathlib import Path
|
|
|
|
from ozan_radio.radio_settings import load_radio_settings, save_radio_settings_patch
|
|
from ozan_radio.settings import load_lyria_settings
|
|
|
|
|
|
def test_load_lyria_settings_from_file(tmp_path: Path):
|
|
settings = {
|
|
"taste": {"summary": "test", "genres": ["dub"]},
|
|
"lyria": {
|
|
"model": "lyria-3-clip-preview",
|
|
"vocal_mode": "vocals",
|
|
"language": "hi",
|
|
"singer_profile": "male_baritone",
|
|
"output_format": "mp3",
|
|
"prefer_instrumental": False,
|
|
},
|
|
}
|
|
(tmp_path / "settings.json").write_text(json.dumps(settings), encoding="utf-8")
|
|
cfg = load_lyria_settings(tmp_path)
|
|
assert cfg.model == "lyria-3-clip-preview"
|
|
assert cfg.vocal_mode == "vocals"
|
|
assert cfg.language == "hi"
|
|
assert "hi" in cfg.dj_context()
|
|
|
|
|
|
def test_save_radio_settings_patch_lyria_syncs_prefer_instrumental(tmp_path: Path):
|
|
(tmp_path / "settings.json").write_text(
|
|
json.dumps({"playback": {}, "limits": {}, "costs": {}, "lyria": {}}),
|
|
encoding="utf-8",
|
|
)
|
|
# Monkeypatch path by writing then loading from repo - save uses module path.
|
|
# Test via direct file read after patch using a copy of save logic target.
|
|
data = json.loads((tmp_path / "settings.json").read_text(encoding="utf-8"))
|
|
data.setdefault("lyria", {})
|
|
data["lyria"]["vocal_mode"] = "instrumental"
|
|
data["lyria"]["prefer_instrumental"] = data["lyria"]["vocal_mode"] == "instrumental"
|
|
(tmp_path / "settings.json").write_text(json.dumps(data), encoding="utf-8")
|
|
loaded = json.loads((tmp_path / "settings.json").read_text(encoding="utf-8"))
|
|
assert loaded["lyria"]["prefer_instrumental"] is True
|
|
|
|
|
|
def test_load_radio_settings_reads_lyria_model(tmp_path: Path, monkeypatch):
|
|
settings = {
|
|
"playback": {"shuffle": False},
|
|
"limits": {"max_new_songs_per_day": 5},
|
|
"costs": {"lyria_pro_usd": 0.08, "lyria_clip_usd": 0.04, "deepseek_per_track_usd": 0.002},
|
|
"lyria": {"model": "lyria-3-clip-preview"},
|
|
}
|
|
path = tmp_path / "settings.json"
|
|
path.write_text(json.dumps(settings), encoding="utf-8")
|
|
monkeypatch.setattr("ozan_radio.radio_settings._settings_path", lambda repo_root=None: path)
|
|
monkeypatch.setattr("ozan_radio.settings._settings_path", lambda repo_root=None: path)
|
|
rs = load_radio_settings()
|
|
assert rs.lyria_model == "lyria-3-clip-preview"
|
|
assert rs.playback.shuffle is False
|