summaryrefslogtreecommitdiff
path: root/tests/test_transcription.py
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2026-07-24 12:11:54 +0200
committerYuval Adam <_@yuv.al>2026-07-24 12:11:54 +0200
commitdf594d42ad1206fcb246bedb1945949527d7e039 (patch)
treea8fe0e95404d1712331c90cb5095f1df4844c513 /tests/test_transcription.py
Implement initial terminal-independent transcription core
Diffstat (limited to 'tests/test_transcription.py')
-rw-r--r--tests/test_transcription.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/test_transcription.py b/tests/test_transcription.py
new file mode 100644
index 0000000..916aac2
--- /dev/null
+++ b/tests/test_transcription.py
@@ -0,0 +1,29 @@
+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()