Files
ea-chatbot-lg/backend/tests/test_orchestrator_reflector.py

31 lines
1.1 KiB
Python

from unittest.mock import MagicMock, patch
from ea_chatbot.graph.nodes.reflector import reflector_node
from ea_chatbot.graph.state import AgentState
def test_reflector_node_satisfied():
"""Verify that the reflector node increments current_step when satisfied."""
state = AgentState(
checklist=[{"task": "Analyze votes", "worker": "data_analyst"}],
current_step=0,
messages=[],
question="test",
analysis={},
next_action="",
iterations=0,
vfs={},
plots=[],
dfs={},
summary="Worker successfully analyzed votes and found 5 million."
)
# Mocking the LLM to return 'satisfied=True'
with patch("ea_chatbot.graph.nodes.reflector.get_llm_model") as mock_get_llm:
mock_llm = MagicMock()
mock_llm.with_structured_output.return_value.invoke.return_value = MagicMock(satisfied=True, reasoning="Good.")
mock_get_llm.return_value = mock_llm
result = reflector_node(state)
assert result["current_step"] == 1
assert result["next_action"] == "delegate" # Route back to delegate for next task