conductor(checkpoint): Checkpoint end of Phase 1
This commit is contained in:
@@ -36,35 +36,36 @@ def test_mcp_tool_call_is_dispatched(app_instance):
|
||||
# 2. Construct the mock AI response (Gemini format)
|
||||
mock_response_with_tool = MagicMock()
|
||||
mock_part = MagicMock()
|
||||
mock_part.text = ""
|
||||
mock_part.function_call = mock_fc
|
||||
mock_candidate = MagicMock()
|
||||
mock_candidate.content.parts = [mock_part]
|
||||
mock_candidate.finish_reason.name = "TOOL_CALLING"
|
||||
mock_response_with_tool.candidates = [mock_candidate]
|
||||
|
||||
mock_usage_metadata = MagicMock()
|
||||
mock_usage_metadata.prompt_token_count = 100
|
||||
mock_usage_metadata.candidates_token_count = 10
|
||||
mock_usage_metadata.cached_content_token_count = 0
|
||||
mock_response_with_tool.usage_metadata = mock_usage_metadata
|
||||
|
||||
class DummyUsage:
|
||||
prompt_token_count = 100
|
||||
candidates_token_count = 10
|
||||
cached_content_token_count = 0
|
||||
|
||||
mock_response_with_tool.usage_metadata = DummyUsage()
|
||||
|
||||
# 3. Create a mock for the final AI response after the tool call
|
||||
mock_response_final = MagicMock()
|
||||
mock_response_final.text = "Final answer"
|
||||
mock_response_final.candidates = []
|
||||
mock_response_final.usage_metadata = mock_usage_metadata
|
||||
mock_response_final.usage_metadata = DummyUsage()
|
||||
|
||||
# 4. Patch the necessary components
|
||||
with patch("ai_client._ensure_gemini_client"), \
|
||||
patch("ai_client._gemini_client"), \
|
||||
patch("ai_client._gemini_chat") as mock_chat, \
|
||||
patch("ai_client._gemini_client") as mock_client, \
|
||||
patch('mcp_client.dispatch', 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._gemini_chat = mock_chat
|
||||
|
||||
|
||||
ai_client.set_provider("gemini", "mock-model")
|
||||
|
||||
|
||||
# 5. Call the send function
|
||||
ai_client.send(
|
||||
md_content="some context",
|
||||
|
||||
Reference in New Issue
Block a user