test(ai_client_cli): migrate to send_result() (Phase 2.1)
Replaces the deprecated ai_client.send() call with ai_client.send_result() in the test. The mock for GeminiCliAdapter is unchanged (it is patched to return a dict that send_result unwraps internally). Changes: - Rename response = ai_client.send(...) to result = ai_client.send_result(...) - Add assert result.ok before accessing result.data - Add "from src.result_types import Result" import 1 test passes.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from unittest.mock import patch, MagicMock
|
||||
from src import ai_client
|
||||
from src.result_types import Result
|
||||
|
||||
|
||||
def test_ai_client_send_gemini_cli() -> None:
|
||||
@@ -19,7 +20,7 @@ def test_ai_client_send_gemini_cli() -> None:
|
||||
MockAdapterClass.return_value = mock_adapter_instance
|
||||
ai_client._gemini_cli_adapter = mock_adapter_instance
|
||||
with patch.object(ai_client.events, "emit") as mock_emit:
|
||||
response = ai_client.send(
|
||||
result = ai_client.send_result(
|
||||
md_content="<context></context>",
|
||||
user_message=test_message,
|
||||
base_dir=".",
|
||||
@@ -28,4 +29,5 @@ def test_ai_client_send_gemini_cli() -> None:
|
||||
emitted_event_names = [call.args[0] for call in mock_emit.call_args_list]
|
||||
assert "request_start" in emitted_event_names
|
||||
assert "response_received" in emitted_event_names
|
||||
assert response == test_response
|
||||
assert result.ok
|
||||
assert result.data == test_response
|
||||
|
||||
Reference in New Issue
Block a user