Add tests and handle json

This commit is contained in:
Kunal Karmakar
2026-04-02 13:43:34 +08:00
committed by Xubin Ren
parent ac2ee58791
commit e206cffd7a
2 changed files with 44 additions and 23 deletions
@@ -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