Files
rune/tests/test_message_widgets.py
T

30 lines
1010 B
Python

"""Behavior contracts for chat and first-class tool objects."""
from rune.chat_bubble import ChatBubble
from rune.message_widgets import ToolCallWidget
def test_tool_object_keeps_protocol_data_out_of_chat_markup():
widget = ToolCallWidget(
{
"kind": "completed",
"request": {
"call_id": "call-1",
"name": "read_file",
"arguments": {"path": "[bold]/tmp/example[/bold]"},
},
"result": {"success": True, "result": "[red]literal[/red]"},
},
channel="chat",
)
assert widget.call_id == "call-1"
assert "✓ read_file" in widget._summary().plain
assert "[bold]/tmp/example[/bold]" in widget._details().plain
assert "[red]literal[/red]" in widget._details().plain
def test_chat_content_is_rendered_literally_between_tool_objects():
rendered = ChatBubble("assistant", "[bold]not markup[/bold]").render()
assert rendered.plain == "Rune\n[bold]not markup[/bold]"