CallOptions

This commit is contained in:
lda
2026-08-30 03:39:26 +07:00 Verified
parent 2587b07b4a
commit 282dc5b4e8
8 changed files with 59 additions and 65 deletions
+11 -8
View File
@@ -9,7 +9,7 @@ import unittest
from unittest.mock import Mock, patch
from ipython_demo.app import App
from ipython_demo.models import CallResponse
from ipython_demo.models import CallOptions, CallResponse
class AppTests(unittest.TestCase):
@@ -41,7 +41,7 @@ class AppTests(unittest.TestCase):
payload = json.loads(completed.stdout)
self.assertEqual(len(payload), 2)
self.assertEqual(payload[0]["events"][0]["kind"], "stdout")
self.assertTrue(payload[1]["collapsed"])
self.assertTrue(payload[1]["options"]["collapsed"])
def test_run_code_returns_frontend_facing_call_response(self):
app = App()
@@ -50,17 +50,20 @@ class AppTests(unittest.TestCase):
call = app.run_code(
"print('hello'); 2 + 2",
shell_name="new",
collapsed=True,
options=CallOptions(collapsed=True),
)
self.assertIsInstance(call, CallResponse)
self.assertEqual(call.code, "print('hello'); 2 + 2")
self.assertTrue(call.collapsed)
self.assertTrue(call.options.collapsed)
self.assertEqual(call.result.result, 4)
self.assertEqual([event.kind for event in call.events], [
"stdout",
"execute_result",
])
self.assertEqual(
[event.kind for event in call.events],
[
"stdout",
"execute_result",
],
)
def test_last_reuses_shell_but_each_call_has_new_id(self):
app = App()