34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
|
|
def test_startup_hook_warms_the_string_snapshot_cache(monkeypatch) -> None:
|
|
from apps.web import pipeline_backend
|
|
from apps.web.vue3 import main
|
|
|
|
calls = []
|
|
monkeypatch.setattr(
|
|
pipeline_backend,
|
|
"load_string_snapshot",
|
|
lambda root: calls.append(root),
|
|
)
|
|
|
|
main.warm_string_species_snapshot_cache()
|
|
|
|
assert calls == [pipeline_backend.STRING_SPECIES_SNAPSHOT_ROOT]
|
|
assert main.warm_string_species_snapshot_cache in main.app.router.on_startup
|
|
|
|
|
|
def test_string_snapshot_warm_failure_does_not_abort_web_startup(monkeypatch, capsys) -> None:
|
|
from apps.web import pipeline_backend
|
|
from apps.web.vue3 import main
|
|
from gfa_core.string_species_registry import StringSnapshotError
|
|
|
|
def fail_to_warm(_root):
|
|
raise StringSnapshotError("snapshot unavailable", code="string_registry_unavailable")
|
|
|
|
monkeypatch.setattr(pipeline_backend, "load_string_snapshot", fail_to_warm)
|
|
|
|
main.warm_string_species_snapshot_cache()
|
|
|
|
assert "STRING snapshot cache warm failed" in capsys.readouterr().out
|