Skip to content

Commit

Permalink
Add unit test for the case when ollama is down
Browse files Browse the repository at this point in the history
  • Loading branch information
taketwo committed May 29, 2024
1 parent b028308 commit bf83e21
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/test_ollama.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from unittest.mock import patch

from httpx import ConnectError

from llm import get_models_with_aliases
from llm.plugins import pm

Expand Down Expand Up @@ -47,3 +49,9 @@ def test_registered_models(mock_ollama_list):
for model, (name, aliases) in zip(registered_ollama_models, expected):
assert model.model.model_id == name
assert model.aliases == aliases


@patch("llm_ollama.ollama.list")
def test_registered_models_when_ollama_is_down(mock_ollama_list):
mock_ollama_list.side_effect = ConnectError("[Errno 111] Connection refused")
assert not any(isinstance(m.model, Ollama) for m in get_models_with_aliases())

0 comments on commit bf83e21

Please sign in to comment.