fe52024311
The test_send_invokes_adapter_send test calls ai_client.send() and asserts the return value. Migrating to send_result() with assert res.ok and res.data == "Hello from mock adapter". Changes: - Rename ai_client.send(...) to ai_client.send_result(...) - Add assert res.ok before accessing res.data - Add "from src.result_types import Result" import 1 test passes.
16 lines
647 B
Python
16 lines
647 B
Python
from unittest.mock import patch, MagicMock
|
|
from src.result_types import Result
|
|
|
|
def test_send_invokes_adapter_send() -> None:
|
|
import src.ai_client as ai_client
|
|
ai_client._gemini_cli_adapter = None
|
|
with patch('src.gemini_cli_adapter.subprocess.Popen') as mock_popen:
|
|
mock_process = MagicMock()
|
|
mock_process.communicate.return_value = ('{"type": "message", "content": "Hello from mock adapter"}', '')
|
|
mock_process.returncode = 0
|
|
mock_popen.return_value = mock_process
|
|
ai_client.set_provider("gemini_cli", "gemini-2.0-flash")
|
|
res = ai_client.send_result("context", "msg")
|
|
assert res.ok
|
|
assert res.data == "Hello from mock adapter"
|