""" ANTI-SIMPLIFICATION: These tests verify the Tool Usage simulation. They MUST NOT be simplified. They ensure that tool execution flows are properly simulated and verified within the GUI state. """ from unittest.mock import MagicMock, patch import os import sys # Ensure project root is in path sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "src"))) from simulation.sim_tools import ToolsSimulation def test_tools_simulation_run() -> None: """ Verifies that ToolsSimulation requests specific tool executions and verifies they appear in the resulting session history. """ mock_client = MagicMock() mock_client.wait_for_server.return_value = True # Mock session entries with tool output mock_session = { 'session': { 'entries': [ {'role': 'User', 'content': 'List files'}, {'role': 'Tool', 'content': 'aggregate.py, ai_client.py', 'tool_call_id': 'call_1'}, {'role': 'AI', 'content': 'The files are: aggregate.py, ai_client.py'} ] } } mock_client.get_session.return_value = mock_session with patch('simulation.sim_base.WorkflowSimulator') as mock_sim_class: mock_sim = MagicMock() mock_sim_class.return_value = mock_sim sim = ToolsSimulation(mock_client) sim.run() # Verify calls # ANTI-SIMPLIFICATION: Must assert the specific commands were tested mock_sim.run_discussion_turn.assert_any_call("List the files in the current directory.") mock_sim.run_discussion_turn.assert_any_call("Read the first 10 lines of aggregate.py.")