Spaces:
Runtime error
Runtime error
File size: 1,585 Bytes
ad51766 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | """Unit tests for display helpers."""
import json
from display import (
build_display_content,
format_tool_call_prompt,
format_tool_calls_for_display,
)
def test_build_display_content_empty():
assert build_display_content("", "") == ""
def test_build_display_content_only_content():
assert build_display_content("", "hello") == "hello"
def test_build_display_content_streaming_reasoning_open():
"""While content is empty the thinking block should be open."""
out = build_display_content("step 1...", "")
assert "<details" in out
assert " open>" in out
assert "Thinking..." in out
assert "step 1..." in out
def test_build_display_content_completed_reasoning_collapsed():
out = build_display_content("step 1...", "final answer")
assert "Thinking complete" in out
assert " open>" not in out
assert "final answer" in out
def test_format_single_tool_call_dict():
tc = {
"id": "call_1",
"type": "function",
"function": {"name": "ping", "arguments": json.dumps({"x": 1})},
}
out = format_tool_calls_for_display([tc])
assert "ping" in out
assert '"x": 1' in out
def test_format_single_tool_call_invalid_args_kept_raw():
tc = {"function": {"name": "ping", "arguments": "{not json"}}
out = format_tool_calls_for_display([tc])
assert "{not json" in out
def test_format_tool_call_prompt_header():
tc = {"function": {"name": "ping", "arguments": "{}"}}
out = format_tool_call_prompt(tc, 2, 5)
assert "Function call (2/5)" in out
assert "ping" in out
|