midnight-static / tests /test_pipeline.py
cajpany's picture
Upload folder using huggingface_hub
2340b2a verified
Raw
History Blame Contribute Delete
1.26 kB
import json
from pathlib import Path
from midnight_static.pipeline import run_fixture_pipeline
def test_fixture_pipeline_writes_script_and_audio(tmp_path: Path):
result = run_fixture_pipeline("a lighthouse that broadcasts dreams", tmp_path)
script_path = Path(result["script"])
audio_path = Path(result["audio"])
assert result["mode"] == "placeholder"
assert result["writer"] == "fixture"
assert script_path.exists()
assert audio_path.exists()
assert audio_path.stat().st_size > 10_000
assert '"title"' in script_path.read_text(encoding="utf-8")
def test_fixture_pipeline_accepts_genre(tmp_path: Path):
result = run_fixture_pipeline(
"a honeymoon hotel room that keeps checking in new guests",
tmp_path,
genre="romance",
)
payload = json.loads(Path(result["script"]).read_text(encoding="utf-8"))
assert payload["genre"] == "romance"
assert payload["music"]["genre"] == "romance"
def test_fixture_pipeline_rejects_unknown_mode(tmp_path: Path):
try:
run_fixture_pipeline("static", tmp_path, mode="missing")
except ValueError as exc:
assert "unknown pipeline mode" in str(exc)
else:
raise AssertionError("expected unknown mode to fail")