test: consolidate repetitive cases across the suite
This commit is contained in:
1 parent
c406024b59
commit
6eccc2859a
31 files changed
+745
-1315
No files matched your search
@@ -121,12 +121,40 @@ async def test_tool_hint_multiple_tools_in_one_message(mock_feishu_channel):
|
||||
|
||||
|
||||
@mark.asyncio
|
||||
async def test_tool_hint_new_format_basic(mock_feishu_channel):
|
||||
"""New format hints (read path, grep "pattern") should parse correctly."""
|
||||
@pytest.mark.parametrize(
|
||||
"content, first_hint, second_hint",
|
||||
[
|
||||
pytest.param(
|
||||
"read src/main.py, grep \"TODO\"",
|
||||
"read src/main.py",
|
||||
"grep \"TODO\"",
|
||||
id="new_format_basic",
|
||||
),
|
||||
pytest.param(
|
||||
"grep \"hello, world\", $ echo test",
|
||||
"grep \"hello, world\"",
|
||||
"$ echo test",
|
||||
id="new_format_with_comma_in_quotes",
|
||||
),
|
||||
pytest.param(
|
||||
"read path × 3, grep \"pattern\"",
|
||||
"× 3",
|
||||
"grep \"pattern\"",
|
||||
id="new_format_with_folding",
|
||||
),
|
||||
pytest.param(
|
||||
"web_search(\"foo, bar\"), read_file(\"/path/to/file\")",
|
||||
"web_search(\"foo, bar\")",
|
||||
"read_file(\"/path/to/file\")",
|
||||
id="keeps_commas_inside_arguments",
|
||||
),
|
||||
],
|
||||
)
|
||||
async def test_tool_hint_preserves_arguments(mock_feishu_channel, content, first_hint, second_hint):
|
||||
msg = OutboundMessage(
|
||||
channel="feishu",
|
||||
chat_id="oc_123456",
|
||||
content='read src/main.py, grep "TODO"',
|
||||
content=content,
|
||||
event=ProgressEvent(tool_hint=True),
|
||||
)
|
||||
|
||||
@@ -135,46 +163,8 @@ async def test_tool_hint_new_format_basic(mock_feishu_channel):
|
||||
|
||||
card = _get_tool_hint_card(mock_send)
|
||||
md = card["elements"][0]["content"]
|
||||
assert "read src/main.py" in md
|
||||
assert 'grep "TODO"' in md
|
||||
|
||||
|
||||
@mark.asyncio
|
||||
async def test_tool_hint_new_format_with_comma_in_quotes(mock_feishu_channel):
|
||||
"""Commas inside quoted arguments must not cause incorrect line splits."""
|
||||
msg = OutboundMessage(
|
||||
channel="feishu",
|
||||
chat_id="oc_123456",
|
||||
content='grep "hello, world", $ echo test',
|
||||
event=ProgressEvent(tool_hint=True),
|
||||
)
|
||||
|
||||
with patch.object(mock_feishu_channel, '_send_message_sync') as mock_send:
|
||||
await mock_feishu_channel.send(msg)
|
||||
|
||||
card = _get_tool_hint_card(mock_send)
|
||||
md = card["elements"][0]["content"]
|
||||
assert 'grep "hello, world"' in md
|
||||
assert "$ echo test" in md
|
||||
|
||||
|
||||
@mark.asyncio
|
||||
async def test_tool_hint_new_format_with_folding(mock_feishu_channel):
|
||||
"""Folded calls (× N) should display correctly."""
|
||||
msg = OutboundMessage(
|
||||
channel="feishu",
|
||||
chat_id="oc_123456",
|
||||
content='read path × 3, grep "pattern"',
|
||||
event=ProgressEvent(tool_hint=True),
|
||||
)
|
||||
|
||||
with patch.object(mock_feishu_channel, '_send_message_sync') as mock_send:
|
||||
await mock_feishu_channel.send(msg)
|
||||
|
||||
card = _get_tool_hint_card(mock_send)
|
||||
md = card["elements"][0]["content"]
|
||||
assert "\u00d7 3" in md
|
||||
assert 'grep "pattern"' in md
|
||||
assert first_hint in md
|
||||
assert second_hint in md
|
||||
|
||||
|
||||
@mark.asyncio
|
||||
@@ -193,22 +183,3 @@ async def test_tool_hint_new_format_mcp(mock_feishu_channel):
|
||||
card = _get_tool_hint_card(mock_send)
|
||||
md = card["elements"][0]["content"]
|
||||
assert "4_5v::analyze_image" in md
|
||||
|
||||
|
||||
@mark.asyncio
|
||||
async def test_tool_hint_keeps_commas_inside_arguments(mock_feishu_channel):
|
||||
"""Commas inside a single tool argument must not be split onto a new line."""
|
||||
msg = OutboundMessage(
|
||||
channel="feishu",
|
||||
chat_id="oc_123456",
|
||||
content='web_search("foo, bar"), read_file("/path/to/file")',
|
||||
event=ProgressEvent(tool_hint=True),
|
||||
)
|
||||
|
||||
with patch.object(mock_feishu_channel, '_send_message_sync') as mock_send:
|
||||
await mock_feishu_channel.send(msg)
|
||||
|
||||
card = _get_tool_hint_card(mock_send)
|
||||
md = card["elements"][0]["content"]
|
||||
assert 'web_search("foo, bar")' in md
|
||||
assert 'read_file("/path/to/file")' in md
|
||||
Reference in new issue
Block a user