test: Update tests to mock async_dispatch for asynchronous tool execution engine.

This commit is contained in:
2026-03-06 13:26:32 -05:00
parent eddc24503d
commit 3bc900b760
2 changed files with 4 additions and 2 deletions

View File

@@ -1,3 +1,4 @@
import unittest.mock
from unittest.mock import patch, MagicMock
from src.gui_2 import App
from src import ai_client
@@ -35,7 +36,7 @@ def test_mcp_tool_call_is_dispatched(app_instance: App) -> None:
# 4. Patch the necessary components
with patch("src.ai_client._ensure_gemini_client"), \
patch("src.ai_client._gemini_client") as mock_client, \
patch("src.mcp_client.dispatch", return_value="file content") as mock_dispatch:
patch("src.mcp_client.async_dispatch", new_callable=unittest.mock.AsyncMock, return_value="file content") as mock_dispatch:
mock_chat = mock_client.chats.create.return_value
mock_chat.send_message.side_effect = [mock_response_with_tool, mock_response_final]
ai_client.set_provider("gemini", "mock-model")