Mercurial
comparison dictation/webrtc_test.py @ 280:49e9e591c9bb
Add persistent dictation, prewarmed WebRTC speech input, Copilot SDK routing, animated conversation lifecycle controls, parking, and architecture coverage.
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Tue, 18 Aug 2026 19:14:53 -0700 |
| parents | 78699f810817 |
| children |
comparison
equal
deleted
inserted
replaced
| 279:b3b547563ec7 | 280:49e9e591c9bb |
|---|---|
| 58 ) | 58 ) |
| 59 | 59 |
| 60 | 60 |
| 61 class WebRtcTest(unittest.IsolatedAsyncioTestCase): | 61 class WebRtcTest(unittest.IsolatedAsyncioTestCase): |
| 62 async def test_audio_track_returns_transcript_events(self): | 62 async def test_audio_track_returns_transcript_events(self): |
| 63 loop_errors = [] | |
| 64 loop = asyncio.get_running_loop() | |
| 65 previous_exception_handler = loop.get_exception_handler() | |
| 66 loop.set_exception_handler( | |
| 67 lambda _loop, context: loop_errors.append(context) | |
| 68 ) | |
| 69 self.addCleanup( | |
| 70 loop.set_exception_handler, | |
| 71 previous_exception_handler, | |
| 72 ) | |
| 63 service = DictationService(test_config(), FakeTranscriber()) | 73 service = DictationService(test_config(), FakeTranscriber()) |
| 64 await service.start() | 74 await service.start() |
| 65 client = RTCPeerConnection() | 75 client = RTCPeerConnection() |
| 66 channel = client.createDataChannel("transcripts") | 76 channel = client.createDataChannel("transcripts") |
| 67 messages = [] | 77 messages = [] |
| 129 event_types = [message["type"] for message in messages] | 139 event_types = [message["type"] for message in messages] |
| 130 self.assertIn("ready", event_types) | 140 self.assertIn("ready", event_types) |
| 131 self.assertIn("speech.started", event_types) | 141 self.assertIn("speech.started", event_types) |
| 132 self.assertIn("transcript.partial", event_types) | 142 self.assertIn("transcript.partial", event_types) |
| 133 self.assertIn("transcript.final", event_types) | 143 self.assertIn("transcript.final", event_types) |
| 144 channel.send("commit") | |
| 145 await asyncio.sleep(0.2) | |
| 146 self.assertNotEqual(client.connectionState, "closed") | |
| 147 self.assertIn(answer["sessionId"], service.sessions) | |
| 134 finally: | 148 finally: |
| 135 await client.close() | 149 await client.close() |
| 136 await service.close() | 150 await service.close() |
| 151 await asyncio.sleep(0.6) | |
| 137 Path(audio_file.name).unlink(missing_ok=True) | 152 Path(audio_file.name).unlink(missing_ok=True) |
| 138 self.assertEqual(service.sessions, {}) | 153 self.assertEqual(service.sessions, {}) |
| 154 self.assertEqual(loop_errors, []) | |
| 139 | 155 |
| 140 | 156 |
| 141 if __name__ == "__main__": | 157 if __name__ == "__main__": |
| 142 unittest.main() | 158 unittest.main() |