Files
manual_slop/tests/test_sim_execution.py

51 lines
1.5 KiB
Python

import pytest
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__), "..")))
from simulation.sim_execution import ExecutionSimulation
def test_execution_simulation_run():
mock_client = MagicMock()
mock_client.wait_for_server.return_value = True
# Mock show_confirm_modal state
vals = {"show_confirm_modal": False}
def side_effect(key):
return vals.get(key)
def set_side_effect(key, val):
vals[key] = val
mock_client.get_value.side_effect = side_effect
mock_client.set_value.side_effect = set_side_effect
# Mock session entries with tool output
mock_session = {
'session': {
'entries': [
{'role': 'Tool', 'content': 'Simulation Test', 'tool_call_id': 'call_1'}
]
}
}
mock_client.get_session.return_value = mock_session
# Mock script confirmation event
mock_client.wait_for_event.side_effect = [
{"type": "script_confirmation_required", "script": "dir"},
None # Second call returns None to end the loop
]
with patch('simulation.sim_base.WorkflowSimulator') as mock_sim_class:
mock_sim = MagicMock()
mock_sim_class.return_value = mock_sim
sim = ExecutionSimulation(mock_client)
sim.run()
# Verify calls
mock_sim.run_discussion_turn_async.assert_called()
mock_client.click.assert_called_with("btn_approve_script")