feat: add preferred premium auto configuration logic and corresponding tests

This commit is contained in:
DESKTOP-RTLN3BA\$punk 2026-05-02 23:35:47 -07:00
parent c938d39277
commit e4f9d79635
3 changed files with 73 additions and 3 deletions

View file

@ -153,6 +153,64 @@ async def test_premium_eligible_auto_prefers_premium_over_free(monkeypatch):
assert result.resolved_tier == "premium"
@pytest.mark.asyncio
async def test_premium_eligible_auto_prefers_azure_gpt_5_4(monkeypatch):
from app.config import config
session = _FakeSession(_thread())
monkeypatch.setattr(
config,
"GLOBAL_LLM_CONFIGS",
[
{
"id": -1,
"provider": "AZURE_OPENAI",
"model_name": "gpt-5.1",
"api_key": "k1",
"billing_tier": "premium",
"auto_pin_tier": "A",
"quality_score": 100,
},
{
"id": -2,
"provider": "AZURE_OPENAI",
"model_name": "gpt-5.4",
"api_key": "k2",
"billing_tier": "premium",
"auto_pin_tier": "A",
"quality_score": 10,
},
{
"id": -3,
"provider": "OPENROUTER",
"model_name": "openai/gpt-5.4",
"api_key": "k3",
"billing_tier": "premium",
"auto_pin_tier": "B",
"quality_score": 100,
},
],
)
async def _allowed(*_args, **_kwargs):
return _FakeQuotaResult(allowed=True)
monkeypatch.setattr(
"app.services.auto_model_pin_service.TokenQuotaService.premium_get_usage",
_allowed,
)
result = await resolve_or_get_pinned_llm_config_id(
session,
thread_id=1,
search_space_id=10,
user_id="00000000-0000-0000-0000-000000000001",
selected_llm_config_id=0,
)
assert result.resolved_llm_config_id == -2
assert result.resolved_tier == "premium"
@pytest.mark.asyncio
async def test_next_turn_reuses_existing_pin(monkeypatch):
from app.config import config