"""Unit tests for remote ollama_pull matching (stdlib helpers).""" from importlib.util import module_from_spec, spec_from_file_location from pathlib import Path _ROOT = Path(__file__).resolve().parents[1] _SPEC = spec_from_file_location( "ollama_pull_remote", _ROOT / "src" / "gpu_rent" / "remote" / "ollama_pull.py", ) assert _SPEC and _SPEC.loader _mod = module_from_spec(_SPEC) _SPEC.loader.exec_module(_mod) already_have = _mod.already_have def test_exact_tag_only(): have = {"qwen2.5:3b", "qwen2.5:7b"} assert already_have(have, "qwen2.5:7b") assert not already_have(have, "qwen2.5:14b") assert already_have(have, "qwen2.5:3b") def test_latest_alias(): assert already_have({"foo:latest"}, "foo") assert already_have({"foo"}, "foo:latest") assert not already_have({"foo:3b"}, "foo")