Add tests and handle json

This commit is contained in:
Kunal Karmakar authored and Xubin Ren committed 2026-04-02 13:43:34 +08:00
1 parent ac2ee58791
commit e206cffd7a
2 files changed
+44 -23

No files matched your search

@@ -492,22 +492,22 @@ class TestConsumeSdkStream:
@pytest.mark.asyncio
async def test_error_event_raises(self):
ev = MagicMock(type="error")
ev = MagicMock(type="error", error="rate_limit_exceeded")
async def stream():
yield ev
with pytest.raises(RuntimeError, match="Response failed"):
with pytest.raises(RuntimeError, match="Response failed.*rate_limit_exceeded"):
await consume_sdk_stream(stream())
@pytest.mark.asyncio
async def test_failed_event_raises(self):
ev = MagicMock(type="response.failed")
ev = MagicMock(type="response.failed", error="server_error")
async def stream():
yield ev
with pytest.raises(RuntimeError, match="Response failed"):
with pytest.raises(RuntimeError, match="Response failed.*server_error"):
await consume_sdk_stream(stream())
@pytest.mark.asyncio