from pathlib import Path from gpu_rent.llm_runtime import ( gguf_filename_from_url, parse_llamacpp_models, write_llamacpp_models_preset, ) def test_gguf_filename_from_url(): url = ( "https://huggingface.co/org/repo/resolve/main/" "Qwen2.5-3B-Instruct-Q4_K_M.gguf" ) assert gguf_filename_from_url(url) == "Qwen2.5-3B-Instruct-Q4_K_M.gguf" def test_write_and_parse_llamacpp_preset(tmp_path: Path): path = tmp_path / "llamacpp-models.yaml" write_llamacpp_models_preset(path, "light") entries = parse_llamacpp_models(path) assert len(entries) == 1 assert entries[0].default is True assert "Qwen2.5-3B" in entries[0].url assert entries[0].url.startswith("https://") def test_parse_llamacpp_empty(tmp_path: Path): path = tmp_path / "llamacpp-models.yaml" write_llamacpp_models_preset(path, "empty") assert parse_llamacpp_models(path) == []