Add dedicated page for running Ollama models

This commit is contained in:
Luca Sacchi Ricciardi
2026-04-25 11:36:05 +02:00
parent 2f591e55ce
commit 1aee51b0d6
6 changed files with 327 additions and 0 deletions
+34
View File
@@ -46,6 +46,39 @@ def test_get_models(client, mock_models_response):
assert len(data["models"]) == 2
assert data["models"][0]["name"] == "llama2"
def test_get_running_models(client):
"""Test getting running models (ollama ps)."""
with patch("requests.get") as mock_get:
mock_response = MagicMock()
mock_response.status_code = 200
mock_response.json.return_value = {
"models": [
{
"name": "llama3.2:3b",
"size_vram": 2147483648,
"expires_at": "2026-04-24T10:30:00Z"
}
]
}
mock_get.return_value = mock_response
response = client.get("/api/v1/models/running")
assert response.status_code == 200
data = response.json()
assert "models" in data
assert data["total"] == 1
assert data["models"][0]["name"] == "llama3.2:3b"
def test_get_running_models_ollama_offline(client):
"""Test running models when Ollama is offline."""
with patch("requests.get") as mock_get:
mock_get.side_effect = Exception("Connection refused")
response = client.get("/api/v1/models/running")
assert response.status_code == 500
def test_get_models_ollama_offline(client):
"""Test getting models when Ollama is offline"""
with patch("requests.get") as mock_get:
@@ -126,6 +159,7 @@ def test_openapi_schema(client):
assert "paths" in schema
assert "/api/v1/health" in schema["paths"]
assert "/api/v1/models" in schema["paths"]
assert "/api/v1/models/running" in schema["paths"]
assert "/api/v1/models/{model_name}/show" in schema["paths"]
assert "/api/v1/models/{model_name}/pull" not in schema["paths"]