mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-02 02:11:58 +00:00
cover missing mcp tools list
This commit is contained in:
parent
0a0e4fea0d
commit
d0388dcd84
1 changed files with 22 additions and 0 deletions
|
|
@ -193,6 +193,28 @@ class TestMCPClientUnitTests:
|
|||
mock_session_instance.initialize.assert_called_once()
|
||||
mock_session_instance.send_request.assert_awaited_once()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_tools_tolerates_missing_tools_field(self):
|
||||
"""Test listing tools when the upstream response omits empty tools."""
|
||||
client = MCPClient("http://example.com")
|
||||
mock_session = AsyncMock()
|
||||
|
||||
async def send_request(_request, result_type):
|
||||
assert result_type is mcp_client_module._LenientListToolsResult
|
||||
return result_type.model_validate({})
|
||||
|
||||
mock_session.send_request = AsyncMock(side_effect=send_request)
|
||||
|
||||
async def run_with_session(operation):
|
||||
return await operation(mock_session)
|
||||
|
||||
client.run_with_session = AsyncMock(side_effect=run_with_session)
|
||||
|
||||
result = await client.list_tools()
|
||||
|
||||
assert result == []
|
||||
mock_session.send_request.assert_awaited_once()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@patch.object(mcp_client_module, "streamable_http_client")
|
||||
@patch.object(mcp_client_module, "ClientSession")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue