from unittest.mock import MagicMock, patch from ea_chatbot.graph.nodes.synthesizer import synthesizer_node from ea_chatbot.graph.state import AgentState from langchain_core.messages import AIMessage def test_synthesizer_node_success(): """Verify that the synthesizer node produces a final response.""" state = AgentState( messages=[AIMessage(content="Worker 1 found data."), AIMessage(content="Worker 2 searched web.")], question="What are the results?", checklist=[], current_step=0, iterations=0, vfs={}, plots=[], dfs={}, next_action="", analysis={} ) # Mocking the LLM with patch("ea_chatbot.graph.nodes.synthesizer.get_llm_model") as mock_get_llm: mock_llm = MagicMock() mock_llm.invoke.return_value = AIMessage(content="Final synthesized answer.") mock_get_llm.return_value = mock_llm result = synthesizer_node(state) assert len(result["messages"]) == 1 assert result["messages"][0].content == "Final synthesized answer." assert result["next_action"] == "end"