test(#5619): pin same-path model helper fixtures

This commit is contained in:
Rod Boev committed 2026-07-05 17:13:07 -04:00
1 parent 29e9a27299
commit 05e14b6339
4 files changed
+11

No files matched your search

@@ -96,6 +96,7 @@ def _configure(monkeypatch, tmp_path, *, provider: str, default: str = ""):
},
)
monkeypatch.setattr(config, "_cfg_mtime", 0.0)
monkeypatch.setattr(config, "_cfg_path", config._get_config_path(), raising=False)
config.invalidate_models_cache()
@@ -59,6 +59,7 @@ def _with_ai_gateway_and_custom_provider():
gateway also exposes."""
old_cfg = dict(config.cfg)
old_mtime = config._cfg_mtime
old_path = getattr(config, "_cfg_path", None)
config.cfg.clear()
config.cfg.update(
{
@@ -81,11 +82,13 @@ def _with_ai_gateway_and_custom_provider():
config._cfg_mtime = config.Path(config._get_config_path()).stat().st_mtime
except Exception:
config._cfg_mtime = 0.0
config._cfg_path = config._get_config_path()
def restore():
config.cfg.clear()
config.cfg.update(old_cfg)
config._cfg_mtime = old_mtime
config._cfg_path = old_path
config.invalidate_models_cache()
return restore
+3
View File
@@ -27,12 +27,14 @@ def _force_env_fallback(monkeypatch):
def _run_available_models_with_cfg(monkeypatch, tmp_path, cfg):
old_cfg = dict(config.cfg)
old_mtime = config._cfg_mtime
old_path = getattr(config, "_cfg_path", None)
monkeypatch.setattr(config, "_models_cache_path", tmp_path / "models_cache.json")
monkeypatch.setattr(config, "_get_config_path", lambda: tmp_path / "missing-config.yaml")
monkeypatch.setattr("api.profiles.get_active_hermes_home", lambda: tmp_path, raising=False)
config.cfg.clear()
config.cfg.update(cfg)
config._cfg_mtime = 0.0
config._cfg_path = config._get_config_path()
config.invalidate_models_cache()
try:
return config.get_available_models()
@@ -40,6 +42,7 @@ def _run_available_models_with_cfg(monkeypatch, tmp_path, cfg):
config.cfg.clear()
config.cfg.update(old_cfg)
config._cfg_mtime = old_mtime
config._cfg_path = old_path
config.invalidate_models_cache()
+4
View File
@@ -39,6 +39,7 @@ class _FakeResponse:
def _with_config(model=None, providers=None):
old_cfg = dict(config.cfg)
old_mtime = config._cfg_mtime
old_path = getattr(config, "_cfg_path", None)
config.cfg.clear()
config.cfg["model"] = model or {}
if providers is not None:
@@ -47,6 +48,8 @@ def _with_config(model=None, providers=None):
config._cfg_mtime = config.Path(config._get_config_path()).stat().st_mtime
except Exception:
config._cfg_mtime = 0.0
config._cfg_path = config._get_config_path()
_restore_config._old_path = old_path
return old_cfg, old_mtime
@@ -54,6 +57,7 @@ def _restore_config(old_cfg, old_mtime):
config.cfg.clear()
config.cfg.update(old_cfg)
config._cfg_mtime = old_mtime
config._cfg_path = getattr(_restore_config, "_old_path", None)
def test_openrouter_quota_fetches_key_endpoint_and_sanitizes_response(monkeypatch, tmp_path):