VibecoderMcSwaggins commited on
Commit
7323f55
·
1 Parent(s): 2ff16a3

fix: mock all agent creation in _build_workflow test

Browse files

The 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.

Files changed (1) hide show
  1. tests/unit/test_magentic_fix.py +16 -1
tests/unit/test_magentic_fix.py CHANGED
@@ -68,7 +68,22 @@ class TestMagenticFixes:
68
  assert orchestrator._max_rounds == 25
69
 
70
  # Also verify it's used in _build_workflow
71
- with patch("src.orchestrator_magentic.MagenticBuilder") as mock_builder:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  # Mock the builder chain
73
  mock_chain = mock_builder.return_value.participants.return_value
74
  mock_chain.with_standard_manager.return_value.build.return_value = MagicMock()
 
68
  assert orchestrator._max_rounds == 25
69
 
70
  # Also verify it's used in _build_workflow
71
+ # Mock all the agent creation and OpenAI client calls
72
+ with (
73
+ patch("src.orchestrator_magentic.create_search_agent") as mock_search,
74
+ patch("src.orchestrator_magentic.create_judge_agent") as mock_judge,
75
+ patch("src.orchestrator_magentic.create_hypothesis_agent") as mock_hypo,
76
+ patch("src.orchestrator_magentic.create_report_agent") as mock_report,
77
+ patch("src.orchestrator_magentic.OpenAIChatClient") as mock_client,
78
+ patch("src.orchestrator_magentic.MagenticBuilder") as mock_builder,
79
+ ):
80
+ # Setup mocks
81
+ mock_search.return_value = MagicMock()
82
+ mock_judge.return_value = MagicMock()
83
+ mock_hypo.return_value = MagicMock()
84
+ mock_report.return_value = MagicMock()
85
+ mock_client.return_value = MagicMock()
86
+
87
  # Mock the builder chain
88
  mock_chain = mock_builder.return_value.participants.return_value
89
  mock_chain.with_standard_manager.return_value.build.return_value = MagicMock()