import unittest from parley.errors import TranscriptionError from parley.transcription import parse_jsonl class ParseJsonlTests(unittest.TestCase): def test_skips_header_and_malformed_lines(self) -> None: output = "\n".join( [ "runtime diagnostic", '{"type":"batch_header","count":1}', '{"file":"recording.wav","text":"hello world"}', ] ) self.assertEqual(parse_jsonl(output), "hello world") def test_reports_error_row(self) -> None: with self.assertRaisesRegex(TranscriptionError, "decoder failed"): parse_jsonl('{"file":"x.wav","error":"decoder failed","text":""}') def test_rejects_output_without_result(self) -> None: with self.assertRaisesRegex(TranscriptionError, "no transcript"): parse_jsonl('{"type":"batch_header"}\nnot json') def test_accepts_empty_transcript(self) -> None: self.assertEqual(parse_jsonl('{"text":""}'), "") if __name__ == "__main__": unittest.main()