Private
Public Access
0
0
Files
manual_slop/tests/test_gemini_cli_edge_cases.py
T
ed ada9617308 test(ai_client): rename send_result to send in 22 remaining test files
Batch rename of 22 test files. 62 references renamed total.

The full test suite is now GREEN again, matching the pre-rename baseline
from Task 1.1. Pure mechanical rename. No behavior change.

Files affected: test_ai_cache_tracking, test_ai_client_cli,
test_ai_client_result, test_api_events, test_context_pruner,
test_deepseek_provider, test_gemini_cli_* (3 files), test_gui2_mcp,
test_headless_* (2 files), test_live_gui_integration_v2,
test_orchestration_logic, test_phase6_engine, test_rag_integration,
test_run_worker_lifecycle_abort, test_spawn_interception_v2,
test_symbol_parsing, test_tier4_interceptor, test_tiered_aggregation,
test_token_usage.

Note: spec estimated 24 files; actual is 22 (test_deprecation_warnings
no longer exists, and 1 fewer file than spec's list).

Refs: conductor/tracks/send_result_to_send_20260616/
2026-06-17 00:38:29 -04:00

42 lines
1.8 KiB
Python

from unittest.mock import patch, MagicMock
from src.gemini_cli_adapter import GeminiCliAdapter
from src import mcp_client
from src.result_types import Result
def test_gemini_cli_context_bleed_prevention() -> 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:
adapter = GeminiCliAdapter()
mock_process = MagicMock()
stdout_output = (
'{"type": "message", "role": "user", "content": "Echoed user prompt"}' + "\n" +
'{"type": "message", "role": "model", "content": "Model response"}'
)
mock_process.communicate.return_value = (stdout_output, '')
mock_process.returncode = 0
mock_popen.return_value = mock_process
result = adapter.send("msg")
assert result["text"] == "Model response"
def test_gemini_cli_parameter_resilience() -> None:
with patch('src.mcp_client.read_file', return_value="content") as mock_read:
mcp_client.dispatch("read_file", {"file_path": "aliased.txt"})
mock_read.assert_called_once_with("aliased.txt")
with patch('src.mcp_client.list_directory', return_value="files") as mock_list:
mcp_client.dispatch("list_directory", {"dir_path": "aliased_dir"})
mock_list.assert_called_once_with("aliased_dir")
def test_gemini_cli_loop_termination() -> 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": "Final answer", "tool_calls": []}', "")
mock_process.returncode = 0
mock_popen.return_value = mock_process
ai_client.set_provider("gemini_cli", "gemini-2.0-flash")
result = ai_client.send("context", "prompt")
assert result.ok
assert result.data == "Final answer"