fix: avoid worker fetch noise when server is offline
This commit is contained in:
+14
-2
@@ -3,6 +3,7 @@ Test API endpoints
|
||||
"""
|
||||
|
||||
import pytest
|
||||
import requests
|
||||
from unittest.mock import patch, MagicMock
|
||||
|
||||
def test_health_check(client):
|
||||
@@ -107,10 +108,21 @@ def test_get_running_models_ollama_offline(client):
|
||||
def test_get_models_ollama_offline(client):
|
||||
"""Test getting models when Ollama is offline"""
|
||||
with patch("requests.get") as mock_get:
|
||||
mock_get.side_effect = Exception("Connection refused")
|
||||
mock_get.side_effect = requests.exceptions.ConnectionError("Connection refused")
|
||||
|
||||
response = client.get("/api/v1/models")
|
||||
assert response.status_code == 500
|
||||
assert response.status_code == 502
|
||||
|
||||
|
||||
def test_get_models_returns_502_when_upstream_is_unavailable(client):
|
||||
"""Non-200 upstream response should remain a 502, not be converted to 500."""
|
||||
with patch("requests.get") as mock_get:
|
||||
mock_response = MagicMock()
|
||||
mock_response.status_code = 503
|
||||
mock_get.return_value = mock_response
|
||||
|
||||
response = client.get("/api/v1/models")
|
||||
assert response.status_code == 502
|
||||
|
||||
def test_get_specific_model(client, mock_models_response):
|
||||
"""Test getting specific model"""
|
||||
|
||||
Reference in New Issue
Block a user