diff --git a/tests/test_live_gui_integration_v2.py b/tests/test_live_gui_integration_v2.py index a306385a..dbdc7de7 100644 --- a/tests/test_live_gui_integration_v2.py +++ b/tests/test_live_gui_integration_v2.py @@ -9,6 +9,7 @@ import time from src.gui_2 import App from src.events import UserRequestEvent from src.api_hook_client import ApiHookClient +from src.result_types import Result, ErrorInfo, ErrorKind @pytest.mark.timeout(10) def test_user_request_integration_flow(mock_app: App) -> None: @@ -25,7 +26,7 @@ def test_user_request_integration_flow(mock_app: App) -> None: # Mock all ai_client methods called during _handle_request_event mock_response = "This is a test AI response" with ( - patch('src.ai_client.send', return_value=mock_response) as mock_send, + patch('src.ai_client.send_result', return_value=Result(data=mock_response)) as mock_send, patch('src.ai_client.set_custom_system_prompt'), patch('src.ai_client.set_model_params'), patch('src.ai_client.set_agent_tools'), @@ -51,8 +52,8 @@ def test_user_request_integration_flow(mock_app: App) -> None: # Let's call the handler app.controller._handle_request_event(event) - # 3. Verify ai_client.send was called - assert mock_send.called, "ai_client.send was not called" + # 3. Verify ai_client.send_result was called + assert mock_send.called, "ai_client.send_result was not called" # 4. First event should be 'comms' (request logging) event_name, payload = app.controller.event_queue.get() @@ -82,8 +83,9 @@ def test_user_request_error_handling(mock_app: App) -> None: Verifies that if ai_client.send raises an exception, the UI is updated with the error state. """ app = mock_app + err = ErrorInfo(kind=ErrorKind.NETWORK, message="API Failure", source="ai_client.test") with ( - patch('src.ai_client.send', side_effect=Exception("API Failure")), + patch('src.ai_client.send_result', return_value=Result(data="", errors=[err])), patch('src.ai_client.set_custom_system_prompt'), patch('src.ai_client.set_model_params'), patch('src.ai_client.set_agent_tools'), @@ -118,7 +120,7 @@ def test_user_request_error_handling(mock_app: App) -> None: app.controller._process_pending_gui_tasks() assert app.controller.ai_status == "error" - assert "ERROR: API Failure" in app.controller.ai_response + assert "API Failure" in app.controller.ai_response def test_api_gui_state_live(live_gui) -> None: client = ApiHookClient()