Fix tests: ConnectionKey not MagicMock
Co-authored-by: alpha-nerd <alpha-nerd@users.noreply.bitfreedom.net>
This commit is contained in:
parent
6d7c51e327
commit
0d2da579c5
2 changed files with 26 additions and 2 deletions
|
|
@ -73,12 +73,24 @@ class TestFetchAvailableModels:
|
|||
|
||||
async def test_returns_empty_on_connection_error(self):
|
||||
cfg = _make_cfg(ollama_eps=[MOCK_OLLAMA_EP], llama_eps=[])
|
||||
from aiohttp.connector import ConnectionKey
|
||||
import aiohttp
|
||||
with patch.object(router, "config", cfg), aioresponses() as m:
|
||||
conn_key = ConnectionKey(
|
||||
host="mock-ollama",
|
||||
port=11434,
|
||||
is_ssl=False,
|
||||
ssl=None,
|
||||
proxy=None,
|
||||
proxy_host=None,
|
||||
proxy_port=None,
|
||||
proxy_auth=None,
|
||||
connector_owner=True,
|
||||
)
|
||||
m.get(
|
||||
f"{MOCK_OLLAMA_EP}/api/tags",
|
||||
exception=aiohttp.ClientConnectorError(
|
||||
connection_key=MagicMock(host="mock-ollama", port=11434),
|
||||
connection_key=conn_key,
|
||||
os_error=OSError(111, "refused"),
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import asyncio
|
|||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import aiohttp
|
||||
from aiohttp.connector import ConnectionKey
|
||||
import pytest
|
||||
|
||||
import router
|
||||
|
|
@ -188,8 +189,19 @@ class TestDedupeOnKeys:
|
|||
|
||||
class TestFormatConnectionIssue:
|
||||
def test_connector_error_message(self):
|
||||
conn_key = ConnectionKey(
|
||||
host="localhost",
|
||||
port=11434,
|
||||
is_ssl=False,
|
||||
ssl=None,
|
||||
proxy=None,
|
||||
proxy_host=None,
|
||||
proxy_port=None,
|
||||
proxy_auth=None,
|
||||
connector_owner=True,
|
||||
)
|
||||
err = aiohttp.ClientConnectorError(
|
||||
connection_key=MagicMock(host="localhost", port=11434),
|
||||
connection_key=conn_key,
|
||||
os_error=OSError(111, "Connection refused"),
|
||||
)
|
||||
msg = router._format_connection_issue("http://localhost:11434", err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue