Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

test(conftest): keep the models.dev foreground fetch and askill reconcile off the network (#2541)

Call White23e97c912294
diff --git a/pyproject.toml b/pyproject.toml
index be7ea6e81..a6cd4bee2 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -176,7 +176,7 @@ markers = [
"allow_foreign_signals(reason): opt out of the autouse guard that refuses os.kill/os.killpg to processes the test did not start (state the reason)",
"reap_processes: kill every process the test started that is still running when it ends, and after a killed run (tests/process_reaper.py)",
"real_web_push_sender: opt out of the autouse stub that keeps the delayed Web Push sender from outliving a test, for tests that drive the sender directly",
- "real_catalog_refresh: opt out of the autouse stub that keeps the remote model catalog and models.dev refreshes from outliving a test, for tests that drive a refresh directly",
+ "real_catalog_refresh: opt out of the autouse stubs that keep the remote model catalog and models.dev fetches off the network and off threads that outlive a test, for tests that drive a refresh or fetch directly",
]
[dependency-groups]
diff --git a/tests/conftest.py b/tests/conftest.py
index 6b9a40d8e..4c0de68c3 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -455,17 +455,27 @@ def _no_background_web_push(request: pytest.FixtureRequest, monkeypatch) -> list
return pushed
+def _models_dev_unreachable(_previous: dict) -> dict:
+ raise OSError("tests do not fetch models.dev")
+
+
@pytest.fixture(autouse=True)
-def _no_background_catalog_refresh(request: pytest.FixtureRequest, monkeypatch) -> None:
- """Keep the remote catalog refreshes off threads that outlive their test.
+def _no_catalog_fetch(request: pytest.FixtureRequest, monkeypatch) -> None:
+ """Keep the remote catalog fetches off the network and off threads that outlive their test.
Reading the backend model catalog or the models.dev catalog from a fresh home
finds its cache stale and starts a daemon thread that fetches over the network
and only then resolves the state directory to write the cache, usually after
the test has ended -- the same shape as the Web Push sender, and the real-home
tripwire caught both writing the developer's state. Each scheduler reports
- that no refresh started. ``real_catalog_refresh`` opts out a test that drives
- the refresh itself.
+ that no refresh started.
+
+ A foreground read of models.dev with no fresh copy fetches on the caller's
+ thread: Model Hub reads it whenever it seeds Vibey, so any such test fetched
+ models.dev and a slow answer held its CI shard until the watchdog. That fetch
+ fails here as it does offline, so the reader keeps a stale copy or reports
+ the catalog unavailable. ``real_catalog_refresh`` opts out a test that drives
+ a refresh or fetch itself.
"""
if request.node.get_closest_marker("real_catalog_refresh"):
@@ -477,6 +487,9 @@ def _no_background_catalog_refresh(request: pytest.FixtureRequest, monkeypatch)
module = _module_this_test_can_import(name)
if module is not None:
monkeypatch.setattr(module, scheduler, lambda: False)
+ models_dev = _module_this_test_can_import("vibe.models_dev_catalog")
+ if models_dev is not None:
+ monkeypatch.setattr(models_dev, "_fetch_catalog", _models_dev_unreachable)
@pytest.fixture(autouse=True)
diff --git a/tests/test_models_dev_catalog.py b/tests/test_models_dev_catalog.py
index e2dda008d..a10c66c7d 100644
--- a/tests/test_models_dev_catalog.py
+++ b/tests/test_models_dev_catalog.py
@@ -52,6 +52,7 @@ def _catalog():
}
[email protected]_catalog_refresh
def test_models_dev_search_normalizes_editable_metadata(monkeypatch, tmp_path):
cache_path = tmp_path / "models-dev.json"
monkeypatch.setattr(models_dev_catalog, "_cache_path", lambda: cache_path)
@@ -109,6 +110,7 @@ def test_models_dev_search_preserves_validator_accepted_long_names(monkeypatch):
assert match["display_name"] == display_name
[email protected]_catalog_refresh
def test_models_dev_search_uses_fresh_cache_without_network(monkeypatch, tmp_path):
cache_path = tmp_path / "models-dev.json"
monkeypatch.setattr(models_dev_catalog, "_cache_path", lambda: cache_path)
@@ -131,6 +133,7 @@ def test_models_dev_search_uses_fresh_cache_without_network(monkeypatch, tmp_pat
assert models_dev_catalog.search_models_dev("deepseek/deepseek-v4")[0]["models_dev_id"] == "deepseek/deepseek-v4"
[email protected]_catalog_refresh
def test_models_dev_search_falls_back_to_stale_cache(monkeypatch, tmp_path):
cache_path = tmp_path / "models-dev.json"
monkeypatch.setattr(models_dev_catalog, "_cache_path", lambda: cache_path)
@@ -153,6 +156,7 @@ def test_models_dev_search_falls_back_to_stale_cache(monkeypatch, tmp_path):
assert models_dev_catalog.search_models_dev("DeepSeek V4")[0]["context_window"] == 1_048_576
[email protected]_catalog_refresh
def test_models_dev_stale_cache_is_scoped_to_its_url(monkeypatch, tmp_path):
cache_path = tmp_path / "models-dev.json"
monkeypatch.setattr(models_dev_catalog, "_cache_path", lambda: cache_path)
diff --git a/tests/test_update_checker_platforms.py b/tests/test_update_checker_platforms.py
index 6c15ed74e..004a9c377 100644
--- a/tests/test_update_checker_platforms.py
+++ b/tests/test_update_checker_platforms.py
@@ -20,6 +20,14 @@ from core.update_checker import UpdateChecker
RELEASE_URL_101 = "https://github.com/avibe-bot/avibe/releases/tag/v1.0.1"
[email protected](autouse=True)
+def _no_askill_reconcile(monkeypatch):
+ """Every update check also reconciles the managed askill, which downloads it from GitHub
+ when the machine has none (#2531). The tests of that reconcile patch their own stand-in."""
+
+ monkeypatch.setattr("vibe.api.reconcile_askill_auto_update", lambda: {"ok": True, "skipped": True})
+
+
class _StubSettingsManager:
def __init__(self, store):
self._store = store
@@ -1069,7 +1077,6 @@ def _backend_auto_update_checker(monkeypatch, tmp_path, sqlite_schema_db_factory
lambda name: {"ok": True, "enabled": True, "installed": True, **runtimes[name]},
)
monkeypatch.setattr("vibe.api.install_agent", install)
- monkeypatch.setattr("vibe.api.reconcile_askill_auto_update", lambda: {"ok": True, "skipped": True})
monkeypatch.setattr(
update_checker,
"_fetch_pypi_version_sync",