fix(tests): add autouse cache-isolation fixture to get_available_models test files

Fixes the CI failure introduced by #817: test_model_resolver::test_custom_endpoint_uses_model_config_api_key_for_model_discovery was failing with KeyError: 'auth' due to the 60s TTL cache in get_available_models() being populated by test_byok_model_dropdown.py tests that ran earlier. Added autouse _isolate_models_cache fixture to 5 test files. Full suite 1747/1747, QA harness green.
This commit is contained in:
nesquena-hermes
2026-04-21 17:41:05 -07:00
committed by GitHub
parent 8f1f582caf
commit 2d8bccdd96
5 changed files with 84 additions and 0 deletions

View File

@@ -3,6 +3,20 @@ import pytest
import api.config as _cfg
@pytest.fixture(autouse=True)
def _isolate_models_cache():
"""Invalidate the models TTL cache before and after every test in this file."""
try:
_cfg.invalidate_models_cache()
except Exception:
pass
yield
try:
_cfg.invalidate_models_cache()
except Exception:
pass
def _available_models_with_cfg(cfg_override):
"""Helper: temporarily patch config.cfg, call get_available_models(), restore."""
old_cfg = dict(_cfg.cfg)