VibecoderMcSwaggins commited on
Commit
46b9533
·
1 Parent(s): f160233

fix: Update test for judge node initialization with improved mocking

Browse files

- Replaced the mock for the pydantic_ai Agent with a mock for get_model to avoid real API key requirements.
- Enhanced the test by mocking the Agent class entirely to ensure proper behavior during initialization.
- Adjusted the test setup to maintain functionality while improving isolation from external dependencies.

Files changed (1) hide show
  1. tests/unit/graph/test_nodes.py +7 -3
tests/unit/graph/test_nodes.py CHANGED
@@ -9,8 +9,8 @@ from src.agents.graph.state import ResearchState
9
  @pytest.mark.asyncio
10
  async def test_judge_node_initialization(mocker):
11
  """Test judge creates initial hypothesis if none exist."""
12
- # Mock pydantic_ai Agent
13
- mock_run = mocker.patch("pydantic_ai.Agent.run")
14
 
15
  # Create a mock assessment with attributes
16
  mock_hypothesis = mocker.Mock()
@@ -25,7 +25,11 @@ async def test_judge_node_initialization(mocker):
25
 
26
  mock_result = mocker.Mock()
27
  mock_result.output = mock_assessment
28
- mock_run.return_value = mock_result
 
 
 
 
29
 
30
  state: ResearchState = {
31
  "query": "Does coffee cause cancer?",
 
9
  @pytest.mark.asyncio
10
  async def test_judge_node_initialization(mocker):
11
  """Test judge creates initial hypothesis if none exist."""
12
+ # Mock get_model to avoid needing real API keys
13
+ mocker.patch("src.agents.graph.nodes.get_model", return_value=mocker.Mock())
14
 
15
  # Create a mock assessment with attributes
16
  mock_hypothesis = mocker.Mock()
 
25
 
26
  mock_result = mocker.Mock()
27
  mock_result.output = mock_assessment
28
+
29
+ # Mock the Agent class entirely
30
+ mock_agent_instance = mocker.Mock()
31
+ mock_agent_instance.run = mocker.AsyncMock(return_value=mock_result)
32
+ mocker.patch("src.agents.graph.nodes.Agent", return_value=mock_agent_instance)
33
 
34
  state: ResearchState = {
35
  "query": "Does coffee cause cancer?",