Spaces:
Build error
Build error
Commit ·
7323f55
1
Parent(s): 2ff16a3
fix: mock all agent creation in _build_workflow test
Browse filesThe test calls _build_workflow() which creates agents internally.
These agents need OpenAIChatClient which requires OPENAI_API_KEY.
Mock all agent creation functions to make test hermetic.
67 unmodified lines6869707172737467 unmodified linesassert orchestrator._max_rounds == 25# Also verify it's used in _build_workflowwith patch("src.orchestrator_magentic.MagenticBuilder") as mock_builder:# Mock the builder chainmock_chain = mock_builder.return_value.participants.return_valuemock_chain.with_standard_manager.return_value.build.return_value = MagicMock()67 unmodified lines6869707172737475767778798081828384858687888967 unmodified linesassert orchestrator._max_rounds == 25# Also verify it's used in _build_workflow# Mock all the agent creation and OpenAI client callswith (patch("src.orchestrator_magentic.create_search_agent") as mock_search,patch("src.orchestrator_magentic.create_judge_agent") as mock_judge,patch("src.orchestrator_magentic.create_hypothesis_agent") as mock_hypo,patch("src.orchestrator_magentic.create_report_agent") as mock_report,patch("src.orchestrator_magentic.OpenAIChatClient") as mock_client,patch("src.orchestrator_magentic.MagenticBuilder") as mock_builder,):# Setup mocksmock_search.return_value = MagicMock()mock_judge.return_value = MagicMock()mock_hypo.return_value = MagicMock()mock_report.return_value = MagicMock()mock_client.return_value = MagicMock()# Mock the builder chainmock_chain = mock_builder.return_value.participants.return_valuemock_chain.with_standard_manager.return_value.build.return_value = MagicMock()
tests/unit/test_magentic_fix.py+16-1