From 4393e831b04450679d56b81601c2cd06705088cf Mon Sep 17 00:00:00 2001 From: Ed_ Date: Wed, 17 Jun 2026 00:32:33 -0400 Subject: [PATCH] test(ai_client): rename send_result to send in test_ai_loop_regressions_20260614 13 references renamed (planned 12; one extra found in a comment). Test function test_fr2_send_result_callable_in_app_controller_namespace renamed to test_fr2_send_callable_in_app_controller_namespace. 7 tests pass. --- tests/test_ai_loop_regressions_20260614.py | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/test_ai_loop_regressions_20260614.py b/tests/test_ai_loop_regressions_20260614.py index d35c2d2d..08fe550e 100644 --- a/tests/test_ai_loop_regressions_20260614.py +++ b/tests/test_ai_loop_regressions_20260614.py @@ -43,10 +43,10 @@ def _make_event(prompt: str = "Hello AI") -> UserRequestEvent: def test_fr1_error_becomes_discussion_entry(mock_app: App, monkeypatch: pytest.MonkeyPatch) -> None: """ - When send_result returns errors, _handle_request_event must enqueue a + When send returns errors, _handle_request_event must enqueue a 'response' event with status='error' and the error message in the text. - Currently broken: the code calls deprecated ai_client.send_result() which + Currently broken: the code calls deprecated ai_client.send() which silently returns '' on error. The empty string is then routed to the event_queue as a 'done' response and _on_comms_entry filters it out via `if text_content.strip():` (src/app_controller.py:3801). @@ -54,7 +54,7 @@ def test_fr1_error_becomes_discussion_entry(mock_app: App, monkeypatch: pytest.M app = mock_app err = ErrorInfo(kind=ErrorKind.NETWORK, message="connection refused", source="ai_client.test") err_result = Result(data="", errors=[err]) - monkeypatch.setattr(ai_client, "send_result", lambda *a, **kw: err_result) + monkeypatch.setattr(ai_client, "send", lambda *a, **kw: err_result) monkeypatch.setattr(ai_client, "set_custom_system_prompt", lambda *a, **kw: None) monkeypatch.setattr(ai_client, "set_base_system_prompt", lambda *a, **kw: None) monkeypatch.setattr(ai_client, "set_use_default_base_prompt", lambda *a, **kw: None) @@ -83,7 +83,7 @@ def test_fr1_success_still_works(mock_app: App, monkeypatch: pytest.MonkeyPatch) """ app = mock_app ok_result = Result(data="Hello back from AI") - monkeypatch.setattr(ai_client, "send_result", lambda *a, **kw: ok_result) + monkeypatch.setattr(ai_client, "send", lambda *a, **kw: ok_result) monkeypatch.setattr(ai_client, "set_custom_system_prompt", lambda *a, **kw: None) monkeypatch.setattr(ai_client, "set_base_system_prompt", lambda *a, **kw: None) monkeypatch.setattr(ai_client, "set_use_default_base_prompt", lambda *a, **kw: None) @@ -111,7 +111,7 @@ def test_fr1_ai_status_updated(mock_app: App, monkeypatch: pytest.MonkeyPatch) - app = mock_app err = ErrorInfo(kind=ErrorKind.RATE_LIMIT, message="slow down", source="ai_client.test") err_result = Result(data="", errors=[err]) - monkeypatch.setattr(ai_client, "send_result", lambda *a, **kw: err_result) + monkeypatch.setattr(ai_client, "send", lambda *a, **kw: err_result) monkeypatch.setattr(ai_client, "set_custom_system_prompt", lambda *a, **kw: None) monkeypatch.setattr(ai_client, "set_base_system_prompt", lambda *a, **kw: None) monkeypatch.setattr(ai_client, "set_use_default_base_prompt", lambda *a, **kw: None) @@ -154,18 +154,18 @@ def test_fr2_no_provider_error_in_source() -> None: assert not violations, f"Found {len(violations)} ProviderError reference(s) in {src_path}: {violations}" -def test_fr2_send_result_callable_in_app_controller_namespace() -> None: +def test_fr2_send_callable_in_app_controller_namespace() -> None: """ - Sanity check: ai_client.send_result exists and returns a Result. This - guards the FR2 fix path -- the replacement code calls send_result() and + Sanity check: ai_client.send exists and returns a Result. This + guards the FR2 fix path -- the replacement code calls send() and branches on result.ok. """ from src import result_types - assert hasattr(ai_client, "send_result"), "ai_client.send_result is the migration target; it must exist" - assert callable(ai_client.send_result) - ok = ai_client.send_result("system", "user") if False else None + assert hasattr(ai_client, "send"), "ai_client.send is the migration target; it must exist" + assert callable(ai_client.send) + ok = ai_client.send("system", "user") if False else None # Smoke test: just verify the import path and signature; the actual call - # path is exercised in test_ai_client_result.py::test_send_result_public_api_returns_result + # path is exercised in test_ai_client_result.py::test_send_public_api_returns_result # endregion: FR2 tests