refactor(ai_client): remove unused history management and bleed stats helpers
This commit is contained in:
@@ -11,16 +11,3 @@ def test_send_invokes_adapter_send() -> None:
|
||||
ai_client.set_provider("gemini_cli", "gemini-2.0-flash")
|
||||
res = ai_client.send("context", "msg")
|
||||
assert res == "Hello from mock adapter"
|
||||
|
||||
def test_get_history_bleed_stats() -> 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": "txt"}', '')
|
||||
mock_process.returncode = 0
|
||||
mock_popen.return_value = mock_process
|
||||
ai_client.set_provider("gemini_cli", "gemini-2.0-flash")
|
||||
ai_client.send("context", "msg")
|
||||
stats = ai_client.get_history_bleed_stats()
|
||||
assert stats["provider"] == "gemini_cli"
|
||||
|
||||
@@ -112,22 +112,4 @@ def test_history_persistence_across_turns(tmp_path: Path) -> None:
|
||||
reloaded = project_manager.load_project(str(project_path))
|
||||
active_disc = reloaded["discussion"]["active"]
|
||||
h2 = reloaded["discussion"]["discussions"][active_disc]["history"]
|
||||
assert len(h2) >= 2
|
||||
|
||||
def test_get_history_bleed_stats_basic() -> None:
|
||||
"""Tests basic retrieval of history bleed statistics from the AI client."""
|
||||
ai_client.set_provider("gemini", "gemini-2.5-flash-lite")
|
||||
# Before any message, it might be 0 or based on an empty context
|
||||
stats = ai_client.get_history_bleed_stats()
|
||||
assert "provider" in stats
|
||||
assert stats["provider"] == "gemini"
|
||||
assert "current" in stats
|
||||
assert "limit" in stats, "Stats dictionary should contain 'limit'"
|
||||
|
||||
# Test with a different limit
|
||||
ai_client.set_model_params(0.0, 8192, 500)
|
||||
stats = ai_client.get_history_bleed_stats()
|
||||
assert "current" in stats, "Stats dictionary should contain 'current' token usage"
|
||||
assert 'limit' in stats, "Stats dictionary should contain 'limit'"
|
||||
assert stats['limit'] == 500
|
||||
assert isinstance(stats['current'], int) and stats['current'] >= 0
|
||||
assert len(h2) >= 2
|
||||
@@ -18,13 +18,6 @@ def test_minimax_list_models() -> None:
|
||||
assert "MiniMax-M2.1" in models
|
||||
assert "MiniMax-M2" in models
|
||||
|
||||
def test_minimax_history_bleed_stats() -> None:
|
||||
ai_client.set_provider("minimax", "MiniMax-M2.5")
|
||||
ai_client.reset_session()
|
||||
stats = ai_client.get_history_bleed_stats(md_content="Test context")
|
||||
assert stats["provider"] == "minimax"
|
||||
assert stats["limit"] == 204800
|
||||
|
||||
def test_minimax_in_providers_list() -> None:
|
||||
from src.models import PROVIDERS
|
||||
assert "minimax" in PROVIDERS
|
||||
|
||||
@@ -47,13 +47,6 @@ def test_add_bleed_derived_headroom_clamped_to_zero() -> None:
|
||||
result = ai_client._add_bleed_derived(d)
|
||||
assert result["headroom"] == 0
|
||||
|
||||
def test_get_history_bleed_stats_returns_all_keys_unknown_provider() -> None:
|
||||
"""get_history_bleed_stats must return a valid dict even if provider is unknown."""
|
||||
ai_client.set_provider("unknown", "unknown")
|
||||
stats = ai_client.get_history_bleed_stats()
|
||||
for key in ["provider", "limit", "current", "percentage", "estimated_prompt_tokens", "headroom", "would_trim", "sys_tokens", "tool_tokens", "history_tokens"]:
|
||||
assert key in stats
|
||||
|
||||
def test_app_token_stats_initialized_empty(app_instance: Any) -> None:
|
||||
"""App._token_stats should start empty."""
|
||||
assert app_instance.controller._token_stats == {}
|
||||
|
||||
Reference in New Issue
Block a user