"""download_models tests. No network in CI; we test the 'already present → skip' short-circuit by faking the expected files, and that main() wires the SigLIP fetch. (Camie download retired with the tagger, #1199.) """ from unittest.mock import patch from backend.app.scripts import download_models as dm def test_ensure_siglip_skips_when_present(tmp_path, monkeypatch): monkeypatch.setattr(dm, "MODEL_ROOT", tmp_path) sig = tmp_path / "siglip" sig.mkdir(parents=True) (sig / "config.json").write_text("{}") (sig / "model.safetensors").write_bytes(b"x") with patch.object(dm, "_snapshot") as snap: dm.ensure_siglip() snap.assert_not_called() def test_ensure_siglip_downloads_when_missing(tmp_path, monkeypatch): monkeypatch.setattr(dm, "MODEL_ROOT", tmp_path) with patch.object(dm, "_snapshot") as snap: dm.ensure_siglip() snap.assert_called_once() def test_main_fetches_siglip(monkeypatch): calls = [] monkeypatch.setattr(dm, "ensure_siglip", lambda: calls.append("siglip")) assert dm.main() == 0 assert calls == ["siglip"]