ok
This commit is contained in:
@@ -5,39 +5,23 @@ from unittest.mock import patch
|
||||
|
||||
|
||||
def test_track_proposal_editing(app_instance):
|
||||
# Setup some proposed tracks
|
||||
app_instance.proposed_tracks = [
|
||||
{"title": "Old Title", "goal": "Old Goal"},
|
||||
{"title": "Another Track", "goal": "Another Goal"}
|
||||
]
|
||||
|
||||
# Simulate editing via logic (since we can't easily drive imgui in unit tests)
|
||||
# The tool instructions say to verify "track proposal editing"
|
||||
app_instance.proposed_tracks[0]['title'] = "New Title"
|
||||
app_instance.proposed_tracks[0]['goal'] = "New Goal"
|
||||
|
||||
assert app_instance.proposed_tracks[0]['title'] == "New Title"
|
||||
assert app_instance.proposed_tracks[0]['goal'] == "New Goal"
|
||||
|
||||
# Test removal logic
|
||||
app_instance.proposed_tracks.pop(1)
|
||||
assert len(app_instance.proposed_tracks) == 1
|
||||
assert app_instance.proposed_tracks[0]['title'] == "New Title"
|
||||
|
||||
def test_conductor_setup_scan(app_instance, tmp_path):
|
||||
# Create a mock conductor directory
|
||||
cond_dir = tmp_path / "conductor"
|
||||
cond_dir.mkdir()
|
||||
(cond_dir / "index.md").write_text("Index content\nLine 2")
|
||||
(cond_dir / "tracks").mkdir()
|
||||
(cond_dir / "tracks" / "track1").mkdir()
|
||||
|
||||
with patch('gui_2.Path', side_effect=lambda *args: Path(tmp_path, *args) if args and args[0] == "conductor" else Path(*args)):
|
||||
# We need to be careful with Path mocking.
|
||||
# Instead of mocking Path globally, let's just use a real dir if possible or mock the method's behavior.
|
||||
pass
|
||||
|
||||
# Alternative: Change CWD for the test
|
||||
def test_conductor_setup_scan(app_instance, tmp_path):
|
||||
old_cwd = os.getcwd()
|
||||
os.chdir(tmp_path)
|
||||
try:
|
||||
@@ -55,16 +39,16 @@ def test_conductor_setup_scan(app_instance, tmp_path):
|
||||
finally:
|
||||
os.chdir(old_cwd)
|
||||
|
||||
|
||||
def test_create_track(app_instance, tmp_path):
|
||||
old_cwd = os.getcwd()
|
||||
os.chdir(tmp_path)
|
||||
try:
|
||||
(Path("conductor") / "tracks").mkdir(parents=True, exist_ok=True)
|
||||
|
||||
with patch('gui_2.project_manager.get_all_tracks', return_value=[]):
|
||||
with patch('src.gui_2.project_manager.get_all_tracks', return_value=[]):
|
||||
app_instance._cb_create_track("Test Track", "Test Description", "feature")
|
||||
|
||||
# Search for a directory starting with 'test_track' in 'conductor/tracks/'
|
||||
tracks_root = Path("conductor/tracks")
|
||||
matching_dirs = [d for d in tracks_root.iterdir() if d.is_dir() and d.name.startswith("test_track")]
|
||||
assert len(matching_dirs) == 1
|
||||
|
||||
@@ -108,7 +108,7 @@ async def test_headless_verification_error_and_qa_interceptor(vlogger) -> None:
|
||||
mock_chat.send_message_stream.side_effect = [make_stream_mock(mock_resp1), make_stream_mock(mock_resp2)]
|
||||
# Mock run_powershell behavior: it should call the qa_callback on error
|
||||
|
||||
def run_side_effect(script: Any, base_dir: Any, qa_callback: Any) -> Any:
|
||||
def run_side_effect(script: Any, base_dir: Any, qa_callback: Any, patch_callback: Any = None) -> Any:
|
||||
if qa_callback:
|
||||
analysis = qa_callback("Error: file not found")
|
||||
return f"STDERR: Error: file not found\n\nQA ANALYSIS:\n{analysis}"
|
||||
@@ -119,7 +119,7 @@ async def test_headless_verification_error_and_qa_interceptor(vlogger) -> None:
|
||||
|
||||
# Patch engine used in test
|
||||
with patch("src.multi_agent_conductor.run_worker_lifecycle", wraps=multi_agent_conductor.run_worker_lifecycle):
|
||||
engine.run()
|
||||
engine.run(max_ticks=1)
|
||||
|
||||
vlogger.log_state("T1 Final Status", "todo", t1.status)
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ def _make_app(**kwargs):
|
||||
app._pending_mma_spawn = kwargs.get("_pending_mma_spawn", None)
|
||||
app._pending_mma_approval = kwargs.get("_pending_mma_approval", None)
|
||||
app._pending_ask_dialog = kwargs.get("_pending_ask_dialog", False)
|
||||
app.perf_profiling_enabled = False
|
||||
app.ui_new_track_name = ""
|
||||
app.ui_new_track_desc = ""
|
||||
app.ui_new_track_type = "feature"
|
||||
@@ -34,6 +35,12 @@ def _make_app(**kwargs):
|
||||
app.ui_new_ticket_deps = ""
|
||||
app.ui_new_ticket_deps = ""
|
||||
app.ui_selected_ticket_id = ""
|
||||
mock_engine = MagicMock()
|
||||
mock_engine._pause_event = MagicMock()
|
||||
mock_engine._pause_event.is_set.return_value = False
|
||||
mock_controller = MagicMock()
|
||||
mock_controller.engine = mock_engine
|
||||
app.controller = mock_controller
|
||||
return app
|
||||
|
||||
def _make_imgui_mock():
|
||||
|
||||
@@ -22,6 +22,7 @@ def _make_app(**kwargs):
|
||||
app._pending_mma_spawn = kwargs.get("_pending_mma_spawn", None)
|
||||
app._pending_mma_approval = kwargs.get("_pending_mma_approval", None)
|
||||
app._pending_ask_dialog = kwargs.get("_pending_ask_dialog", False)
|
||||
app.perf_profiling_enabled = False
|
||||
app.ui_new_track_name = ""
|
||||
app.ui_new_track_desc = ""
|
||||
app.ui_new_track_type = "feature"
|
||||
@@ -33,6 +34,12 @@ def _make_app(**kwargs):
|
||||
app.ui_new_ticket_target = ""
|
||||
app.ui_new_ticket_deps = ""
|
||||
app._tier_stream_last_len = {}
|
||||
mock_engine = MagicMock()
|
||||
mock_engine._pause_event = MagicMock()
|
||||
mock_engine._pause_event.is_set.return_value = False
|
||||
mock_controller = MagicMock()
|
||||
mock_controller.engine = mock_engine
|
||||
app.controller = mock_controller
|
||||
return app
|
||||
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ def test_perf_monitor_basic_timing() -> None:
|
||||
|
||||
def test_perf_monitor_component_timing() -> None:
|
||||
pm = PerformanceMonitor()
|
||||
pm.enabled = True
|
||||
pm.start_component("test_comp")
|
||||
time.sleep(0.01)
|
||||
pm.end_component("test_comp")
|
||||
|
||||
@@ -36,7 +36,7 @@ def test_handle_generate_send_appends_definitions(controller):
|
||||
# Mock symbol helpers
|
||||
with (
|
||||
patch('src.app_controller.parse_symbols', return_value=["Track"]) as mock_parse,
|
||||
patch('src.app_controller.get_symbol_definition', return_value=("src/models.py", "class Track: pass")) as mock_get_def,
|
||||
patch('src.app_controller.get_symbol_definition', return_value=("src/models.py", "class Track: pass", 42)) as mock_get_def,
|
||||
patch('threading.Thread') as mock_thread
|
||||
):
|
||||
# Execute
|
||||
@@ -56,7 +56,7 @@ def test_handle_generate_send_appends_definitions(controller):
|
||||
assert isinstance(event_payload, UserRequestEvent)
|
||||
|
||||
# Check if definition was appended
|
||||
expected_suffix = "\n\n[Definition: Track from src/models.py]\n```python\nclass Track: pass\n```"
|
||||
expected_suffix = "\n\n[Definition: Track from src/models.py (line 42)]\n```python\nclass Track: pass\n```"
|
||||
assert event_payload.prompt == "Explain @Track object" + expected_suffix
|
||||
|
||||
def test_handle_generate_send_no_symbols(controller):
|
||||
|
||||
Reference in New Issue
Block a user