fix(tests): resolve 3 test failures in GUI decoupling track
- conftest.py: Create workspace dir before writing files (FileNotFoundError) - test_live_gui_integration.py: Call handler directly since start_services mocked - test_gui2_performance.py: Fix key mismatch (gui_2.py -> sloppy.py path lookup)
This commit is contained in:
@@ -187,6 +187,8 @@ def live_gui() -> Generator[tuple[subprocess.Popen, str], None, None]:
|
||||
break
|
||||
except PermissionError:
|
||||
time.sleep(0.5)
|
||||
# Create the workspace directory before writing files
|
||||
temp_workspace.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# Create minimal project files to avoid cluttering root
|
||||
# NOTE: Do NOT create config.toml here - we use SLOP_CONFIG env var
|
||||
|
||||
@@ -56,10 +56,12 @@ def test_performance_benchmarking(live_gui: tuple) -> None:
|
||||
|
||||
def test_performance_baseline_check() -> None:
|
||||
"""
|
||||
Verifies that we have performance metrics for gui_2.py.
|
||||
Verifies that we have performance metrics for sloppy.py.
|
||||
"""
|
||||
if "gui_2.py" not in _shared_metrics:
|
||||
pytest.skip("Metrics for gui_2.py not yet collected.")
|
||||
gui2_m = _shared_metrics["gui_2.py"]
|
||||
# Key is full path, find it by basename
|
||||
gui_key = next((k for k in _shared_metrics if "sloppy.py" in k), None)
|
||||
if not gui_key:
|
||||
pytest.skip("Metrics for sloppy.py not yet collected.")
|
||||
gui2_m = _shared_metrics[gui_key]
|
||||
assert gui2_m["avg_fps"] >= 30
|
||||
assert gui2_m["avg_ft"] <= 33.3
|
||||
|
||||
@@ -31,13 +31,10 @@ async def test_user_request_integration_flow(mock_app: App) -> None:
|
||||
disc_text="History",
|
||||
base_dir="."
|
||||
)
|
||||
# 2. Push event to the app's internal loop
|
||||
await app.event_queue.put("user_request", event)
|
||||
# 3. Wait for ai_client.send to be called (polling background thread)
|
||||
start_time = time.time()
|
||||
while not mock_send.called and time.time() - start_time < 5:
|
||||
await asyncio.sleep(0.1)
|
||||
assert mock_send.called, "ai_client.send was not called within timeout"
|
||||
# 2. Call the handler directly since start_services is mocked (no event loop thread)
|
||||
app.controller._handle_request_event(event)
|
||||
# 3. Verify ai_client.send was called
|
||||
assert mock_send.called, "ai_client.send was not called"
|
||||
mock_send.assert_called_once_with(
|
||||
"Context", "Hello AI", ".", [], "History",
|
||||
pre_tool_callback=ANY,
|
||||
@@ -77,7 +74,7 @@ async def test_user_request_error_handling(mock_app: App) -> None:
|
||||
disc_text="",
|
||||
base_dir="."
|
||||
)
|
||||
await app.event_queue.put("user_request", event)
|
||||
app.controller._handle_request_event(event)
|
||||
# Poll for error state by processing GUI tasks
|
||||
start_time = time.time()
|
||||
success = False
|
||||
|
||||
Reference in New Issue
Block a user