From 99418b11601a6f652825a6550fead475b5f1707e Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sun, 26 Oct 2025 09:52:58 +0000 Subject: [PATCH] fix: Correct test mocks for MCP progress and headers tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix event bus API: use register_handler instead of register - Fix mock import paths: patch mcp.client.streamable_http.streamablehttp_client and mcp.ClientSession at their actual import locations Co-Authored-By: João --- .../tests/tools/test_mcp_tool_wrapper.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/crewai/tests/tools/test_mcp_tool_wrapper.py b/lib/crewai/tests/tools/test_mcp_tool_wrapper.py index 90da4e6d2..739957d2d 100644 --- a/lib/crewai/tests/tools/test_mcp_tool_wrapper.py +++ b/lib/crewai/tests/tools/test_mcp_tool_wrapper.py @@ -119,8 +119,8 @@ class TestMCPToolWrapperProgress: mock_result = Mock() mock_result.content = [Mock(text="Test result")] - with patch("crewai.tools.mcp_tool_wrapper.streamablehttp_client") as mock_client, \ - patch("crewai.tools.mcp_tool_wrapper.ClientSession") as mock_session_class: + with patch("mcp.client.streamable_http.streamablehttp_client") as mock_client, \ + patch("mcp.ClientSession") as mock_session_class: mock_session = AsyncMock() mock_session.initialize = AsyncMock() @@ -148,7 +148,7 @@ class TestMCPToolWrapperProgress: if isinstance(event, MCPToolProgressEvent): events_received.append(event) - crewai_event_bus.register(MCPToolProgressEvent, event_handler) + crewai_event_bus.register_handler(MCPToolProgressEvent, event_handler) try: wrapper = MCPToolWrapper( @@ -243,8 +243,8 @@ class TestMCPToolWrapperHeaders: mock_result = Mock() mock_result.content = [Mock(text="Test result")] - with patch("crewai.tools.mcp_tool_wrapper.streamablehttp_client") as mock_client, \ - patch("crewai.tools.mcp_tool_wrapper.ClientSession") as mock_session_class: + with patch("mcp.client.streamable_http.streamablehttp_client") as mock_client, \ + patch("mcp.ClientSession") as mock_session_class: mock_session = AsyncMock() mock_session.initialize = AsyncMock() @@ -277,8 +277,8 @@ class TestMCPToolWrapperHeaders: mock_result = Mock() mock_result.content = [Mock(text="Test result")] - with patch("crewai.tools.mcp_tool_wrapper.streamablehttp_client") as mock_client, \ - patch("crewai.tools.mcp_tool_wrapper.ClientSession") as mock_session_class: + with patch("mcp.client.streamable_http.streamablehttp_client") as mock_client, \ + patch("mcp.ClientSession") as mock_session_class: mock_session = AsyncMock() mock_session.initialize = AsyncMock() @@ -326,8 +326,8 @@ class TestMCPToolWrapperIntegration: mock_result = Mock() mock_result.content = [Mock(text="Test result")] - with patch("crewai.tools.mcp_tool_wrapper.streamablehttp_client") as mock_client, \ - patch("crewai.tools.mcp_tool_wrapper.ClientSession") as mock_session_class: + with patch("mcp.client.streamable_http.streamablehttp_client") as mock_client, \ + patch("mcp.ClientSession") as mock_session_class: mock_session = AsyncMock() mock_session.initialize = AsyncMock()