test(models): pin live-rebuild budget in model-cache metadata tests

The three get_available_models() tests in tests/test_model_cache_metadata.py
depend on the rebuild finishing inside _LIVE_REBUILD_BUDGET_SECONDS (4.0s).
On a loaded host the rebuild exceeds it and api/config.py::get_available_models
serves the over-budget stale payload, failing the rebuilt-metadata assertions.

Pin the budget to 0.0 (synchronous rebuild), the same pattern already used by
tests/test_issue2513_custom_provider_remote_models.py and
tests/test_copilot_provider_model_settings_not_allowlist.py.

Closes #7735
This commit is contained in:
webtecnica committed 2026-09-22 22:58:20 -03:00
1 parent 18db77a132
commit 67135b3b1e
1 file changed
+9
+9
View File
@@ -112,6 +112,9 @@ def test_load_models_cache_from_disk_rejects_partial_metadata_cache(
def test_get_available_models_ignores_invalid_ttl_memory_cache(monkeypatch):
# Pin the budget so a slow/loaded host cannot blow the global 4s limit and
# serve the over-budget stale payload instead of the rebuilt catalog.
monkeypatch.setattr(config, "_LIVE_REBUILD_BUDGET_SECONDS", 0.0, raising=False)
_reset_memory_cache()
stale_cache = {
@@ -152,6 +155,9 @@ def test_get_available_models_does_not_use_disk_cache_after_config_mtime_change(
):
cache_path = tmp_path / "models_cache.json"
monkeypatch.setattr(config, "_models_cache_path", cache_path)
# Pin the budget so the rebuild cannot exceed the global 4s limit and
# serve the over-budget stale payload instead of the rebuilt catalog.
monkeypatch.setattr(config, "_LIVE_REBUILD_BUDGET_SECONDS", 0.0, raising=False)
cache_path.write_text(
json.dumps(
{
@@ -194,6 +200,9 @@ def test_get_available_models_ignores_legacy_disk_cache_and_rebuilds(
):
cache_path = tmp_path / "models_cache.json"
monkeypatch.setattr(config, "_models_cache_path", cache_path)
# Pin the budget so the rebuild cannot exceed the global 4s limit and
# serve the legacy stale disk groups instead of the rebuilt catalog.
monkeypatch.setattr(config, "_LIVE_REBUILD_BUDGET_SECONDS", 0.0, raising=False)
cache_path.write_text(
json.dumps(
{