Skip to content

Commit b34be10

Browse files
test(speak): kill mutation survivors (Segment frozen, multi --out path); fix dialogue test typing
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 31b448b commit b34be10

3 files changed

Lines changed: 22 additions & 3 deletions

File tree

tests/test_speak.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,18 @@ def test_dialogue_json_reports_speaker_voice_map(fake_dialogue):
195195
assert payload["audio_duration_seconds"] == 1.235
196196

197197

198+
def test_dialogue_json_out_path_is_reported(fake_dialogue, monkeypatch, tmp_path):
199+
# With --out, the multi JSON reports the file path (not null) — pins the
200+
# `str(out) if out is not None else None` branch in _emit_multi.
201+
monkeypatch.setattr("aai_cli.commands.speak.audio.write_wav", lambda *a, **k: None)
202+
out = tmp_path / "dialogue.wav"
203+
text = "Speaker A: One.\nSpeaker B: Two."
204+
result = runner.invoke(app, ["--sandbox", "speak", "--out", str(out), "--json"], input=text)
205+
assert result.exit_code == 0
206+
payload = json.loads(result.stdout.strip())
207+
assert payload["out"] == str(out)
208+
209+
198210
def test_empty_speaker_labels_raises_usage_error():
199211
# Speaker-labeled input with no spoken text: detected as labeled, parses to zero
200212
# segments, and raises the usage error before any synthesis.

tests/test_tts_dialogue.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ def test_plain_prose_is_not_labeled():
1919
assert dialogue.looks_like_speaker_labeled("") is False
2020

2121

22+
def test_segment_is_immutable():
23+
seg = dialogue.Segment("A", "hi")
24+
attr = "text" # a variable (not a constant) keeps ruff's B010 from rewriting setattr
25+
with pytest.raises(AttributeError): # frozen=True -> assignment is blocked
26+
setattr(seg, attr, "changed")
27+
28+
2229
def test_parse_single_line_turns():
2330
segs = dialogue.parse_segments("Speaker A: Hello.\nSpeaker B: Hi there.")
2431
assert [(s.speaker_id, s.text) for s in segs] == [("A", "Hello."), ("B", "Hi there.")]

tests/test_tts_session.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,9 @@ def test_synthesize_dialogue_uses_server_sample_rate():
311311

312312

313313
def test_synthesize_dialogue_empty_segments_returns_silent_default():
314-
# No segments -> no audio at the default rate, and no crash (the connect factory
315-
# is never invoked because the loop body never runs).
316-
result = session.synthesize_dialogue("k", [], connect=lambda *a, **k: None)
314+
# No segments -> no audio at the default rate, and no crash. connect is omitted
315+
# entirely: the loop body never runs, so no connection is ever attempted.
316+
result = session.synthesize_dialogue("k", [])
317317
assert result.pcm == b""
318318
assert result.sample_rate == 24000
319319
assert result.audio_duration_seconds == 0.0

0 commit comments

Comments
 (0)