Files
jundot--omlx/tests/test_parser_tool_calls.py
wehub-resource-sync e9a2f726c9
CI / test (3.11) (push) Has been cancelled
CI / test (3.12) (push) Has been cancelled
CI / test (3.13) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:29:51 +08:00

45 lines
1.4 KiB
Python

# SPDX-License-Identifier: Apache-2.0
"""Tests for parser-emitted tool call conversion."""
import logging
from omlx.api.parser_tool_calls import convert_parser_tool_calls
class TestParserToolCallConversion:
def test_drops_malformed_parser_tool_call_arguments(self, caplog):
with caplog.at_level(logging.WARNING, logger="omlx.api.parser_tool_calls"):
converted = convert_parser_tool_calls(
[
{
"id": "call_bad",
"name": "read",
"arguments": '{"path": "/tmp/file"',
}
]
)
assert converted == []
assert "Dropping malformed parser tool call 'read'" in caplog.text
def test_keeps_valid_parser_tool_calls_when_one_is_malformed(self):
converted = convert_parser_tool_calls(
[
{
"id": "call_valid",
"name": "read",
"arguments": '{"path": "/tmp/file"}',
},
{
"id": "call_bad",
"name": "write",
"arguments": '{"path":',
},
]
)
assert len(converted) == 1
assert converted[0].id == "call_valid"
assert converted[0].function.name == "read"
assert converted[0].function.arguments == '{"path": "/tmp/file"}'