| import json |
| from pathlib import Path |
|
|
| from midnight_static.gradio_app import ( |
| generate_broadcast, |
| load_showcase_for_ui, |
| on_air_start, |
| radio_shell_for_genre, |
| ) |
|
|
|
|
| def test_generate_broadcast_returns_audio_and_script(tmp_path: Path): |
| audio_path, script_json = generate_broadcast( |
| "a motel room where the wallpaper whispers", |
| mode="placeholder", |
| writer="fixture", |
| output_dir=str(tmp_path), |
| ) |
|
|
| payload = json.loads(script_json) |
|
|
| assert Path(audio_path).exists() |
| assert payload["title"].startswith("The Case of") |
| assert payload["genre"] == "weird" |
|
|
|
|
| def test_generate_broadcast_uses_selected_genre(tmp_path: Path): |
| audio_path, script_json = generate_broadcast( |
| "a saloon piano that predicts tomorrow", |
| mode="placeholder", |
| writer="fixture", |
| genre="western", |
| output_dir=str(tmp_path), |
| ) |
|
|
| payload = json.loads(script_json) |
|
|
| assert Path(audio_path).exists() |
| assert payload["genre"] == "western" |
| assert payload["music"]["genre"] == "western" |
|
|
|
|
| def test_radio_shell_tracks_genre_and_showcase(): |
| shell = radio_shell_for_genre("comedy") |
| _, _, showcase_genre, showcase_shell, showcase_status = load_showcase_for_ui( |
| "The Case of A Wedding Where Every Guest Recognizes" |
| ) |
|
|
| assert '--ms-needle-left: 75%' in shell |
| assert "<strong>LAFF</strong>" in shell |
| assert showcase_genre == "comedy" |
| assert "<strong>LAFF</strong>" in showcase_shell |
| assert "RERUN READY" in showcase_status |
|
|
|
|
| def test_on_air_start_returns_scanning_state(): |
| shell, status = on_air_start("noir") |
|
|
| assert "ms-radio is-scanning" in shell |
| assert "87.9 WRITING" in shell |
| assert "WRITING ... CASTING ... FOLEY ... SCORING ..." in status |
| assert "is-live" in status |
|
|