conductor(checkpoint): Phase 3: AI Settings and Tools Simulation complete
This commit is contained in:
41
tests/test_sim_ai_settings.py
Normal file
41
tests/test_sim_ai_settings.py
Normal file
@@ -0,0 +1,41 @@
|
||||
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_ai_settings import AISettingsSimulation
|
||||
|
||||
def test_ai_settings_simulation_run():
|
||||
mock_client = MagicMock()
|
||||
mock_client.wait_for_server.return_value = True
|
||||
|
||||
mock_client.get_value.side_effect = lambda key: {
|
||||
"current_provider": "gemini",
|
||||
"current_model": "gemini-2.0-flash"
|
||||
}.get(key)
|
||||
|
||||
with patch('simulation.sim_base.WorkflowSimulator') as mock_sim_class:
|
||||
mock_sim = MagicMock()
|
||||
mock_sim_class.return_value = mock_sim
|
||||
|
||||
sim = AISettingsSimulation(mock_client)
|
||||
|
||||
# Override the side effect after initial setup if needed or just let it return the same for simplicity
|
||||
# Actually, let's use a side effect that updates
|
||||
vals = {"current_provider": "gemini", "current_model": "gemini-2.0-flash"}
|
||||
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
|
||||
|
||||
sim.run()
|
||||
|
||||
# Verify calls
|
||||
mock_client.set_value.assert_any_call("current_provider", "anthropic")
|
||||
mock_client.set_value.assert_any_call("current_provider", "gemini")
|
||||
36
tests/test_sim_tools.py
Normal file
36
tests/test_sim_tools.py
Normal file
@@ -0,0 +1,36 @@
|
||||
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_tools import ToolsSimulation
|
||||
|
||||
def test_tools_simulation_run():
|
||||
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
|
||||
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.")
|
||||
Reference in New Issue
Block a user