test: cover Jupyter MIME output paths

This commit is contained in:
lda
2026-08-30 19:35:27 +07:00 Verified
parent 6315235e16
commit 56e1b96077
3 changed files with 37 additions and 2 deletions
+14
View File
@@ -3,16 +3,30 @@ import unittest
import httpx
from ipython_shell.jupyter.transport import KernelMessage
from ipython_webapp.jupyter.app import (
InputReply,
app,
reply_to_input,
run_code,
serialize_event,
shell_app,
)
class JupyterWebAppTests(unittest.IsolatedAsyncioTestCase):
def test_serialize_event_encodes_binary_buffers(self):
event = KernelMessage(
msg_type="display_data",
parent_id="call-1",
content={"data": {"application/octet-stream": "present"}},
buffers=[b"\x00\xff"],
)
serialized = serialize_event(event)
self.assertEqual(serialized["buffers"], ["AP8="])
async def test_run_endpoint_streams_json_events_with_mime_data(self):
transport = httpx.ASGITransport(app=app)
async with httpx.AsyncClient(