forked from Rockachopa/Timmy-time-dashboard
feat: add automated Nexus zone screenshot capture script (#1492)
Co-authored-by: Alexander Whitestone <alexander@alexanderwhitestone.com> Co-committed-by: Alexander Whitestone <alexander@alexanderwhitestone.com>
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
import json
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from infrastructure.models.multimodal import (
|
||||
DEFAULT_FALLBACK_CHAINS,
|
||||
KNOWN_MODEL_CAPABILITIES,
|
||||
@@ -10,11 +12,14 @@ from infrastructure.models.multimodal import (
|
||||
ModelInfo,
|
||||
MultiModalManager,
|
||||
get_model_for_capability,
|
||||
get_multimodal_manager,
|
||||
model_supports_tools,
|
||||
model_supports_vision,
|
||||
pull_model_with_fallback,
|
||||
)
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# ModelCapability enum
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -507,3 +512,41 @@ class TestModelInfoPopulation:
|
||||
assert info.is_pulled is True
|
||||
assert info.size_mb == 4 * 1024 # 4 GiB in MiB
|
||||
assert info.description == "test"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# _pull_model — non-200 status branch (lines 480-481)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class TestPullModelNon200:
|
||||
def test_pull_non_200_returns_false(self):
|
||||
mgr = _make_manager([])
|
||||
pull_resp = MagicMock()
|
||||
pull_resp.__enter__ = MagicMock(return_value=pull_resp)
|
||||
pull_resp.__exit__ = MagicMock(return_value=False)
|
||||
pull_resp.status = 500 # Non-200 response
|
||||
|
||||
with patch("urllib.request.urlopen", return_value=pull_resp):
|
||||
assert mgr._pull_model("some-model:1b") is False
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# get_multimodal_manager singleton (line 552)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class TestGetMultimodalManager:
|
||||
def test_creates_singleton(self):
|
||||
with (
|
||||
patch("infrastructure.models.multimodal._multimodal_manager", None),
|
||||
patch("urllib.request.urlopen", side_effect=ConnectionError("no ollama")),
|
||||
):
|
||||
mgr = get_multimodal_manager()
|
||||
assert isinstance(mgr, MultiModalManager)
|
||||
|
||||
def test_returns_existing_singleton(self):
|
||||
sentinel = _make_manager(None)
|
||||
with patch("infrastructure.models.multimodal._multimodal_manager", sentinel):
|
||||
mgr = get_multimodal_manager()
|
||||
assert mgr is sentinel
|
||||
|
||||
Reference in New Issue
Block a user