[loop-cycle-34] fix: mock Ollama model resolution in create_timmy tests (#121) (#126)
Some checks failed
Tests / lint (push) Has been cancelled
Tests / test (push) Has been cancelled

This commit was merged in pull request #126.
This commit is contained in:
2026-03-15 08:20:00 -04:00
parent cf48b7d904
commit 466ad08d7d
3 changed files with 24 additions and 0 deletions

View File

@@ -159,6 +159,8 @@ def test_create_timmy_uses_timeout_not_request_timeout():
patch("timmy.agent.Ollama") as mock_ollama,
patch("timmy.agent.SqliteDb"),
patch("timmy.agent.Agent"),
patch("timmy.agent._resolve_model_with_fallback", return_value=("llama3.2:3b", False)),
patch("timmy.agent._check_model_available", return_value=True),
):
mock_ollama.return_value = MagicMock()

View File

@@ -6,6 +6,8 @@ def test_create_timmy_custom_db_file():
patch("timmy.agent.Agent"),
patch("timmy.agent.Ollama"),
patch("timmy.agent.SqliteDb") as MockDb,
patch("timmy.agent._resolve_model_with_fallback", return_value=("llama3.2:3b", False)),
patch("timmy.agent._check_model_available", return_value=True),
):
from timmy.agent import create_timmy
@@ -20,6 +22,8 @@ def test_create_timmy_embeds_system_prompt():
patch("timmy.agent.Agent") as MockAgent,
patch("timmy.agent.Ollama"),
patch("timmy.agent.SqliteDb"),
patch("timmy.agent._resolve_model_with_fallback", return_value=("llama3.2:3b", False)),
patch("timmy.agent._check_model_available", return_value=True),
):
from timmy.agent import create_timmy
@@ -44,6 +48,8 @@ def test_create_timmy_passes_ollama_url_to_model():
patch("timmy.agent.Agent"),
patch("timmy.agent.Ollama") as MockOllama,
patch("timmy.agent.SqliteDb"),
patch("timmy.agent._resolve_model_with_fallback", return_value=("llama3.2:3b", False)),
patch("timmy.agent._check_model_available", return_value=True),
):
from timmy.agent import create_timmy
@@ -64,6 +70,8 @@ def test_create_timmy_respects_custom_ollama_url():
patch("timmy.agent.Ollama") as MockOllama,
patch("timmy.agent.SqliteDb"),
patch("timmy.agent.settings") as mock_settings,
patch("timmy.agent._resolve_model_with_fallback", return_value=("llama3.2:3b", False)),
patch("timmy.agent._check_model_available", return_value=True),
):
mock_settings.ollama_model = "llama3.2"
mock_settings.ollama_url = custom_url
@@ -112,6 +120,8 @@ def test_create_timmy_explicit_ollama_ignores_autodetect():
patch("timmy.agent.Agent") as MockAgent,
patch("timmy.agent.Ollama"),
patch("timmy.agent.SqliteDb"),
patch("timmy.agent._resolve_model_with_fallback", return_value=("llama3.2:3b", False)),
patch("timmy.agent._check_model_available", return_value=True),
):
from timmy.agent import create_timmy
@@ -235,6 +245,8 @@ def test_create_timmy_includes_tools_for_large_model():
patch("timmy.agent.SqliteDb"),
patch("timmy.agent.create_full_toolkit", return_value=mock_toolkit),
patch("timmy.agent.settings") as mock_settings,
patch("timmy.agent._resolve_model_with_fallback", return_value=("llama3.1", False)),
patch("timmy.agent._check_model_available", return_value=True),
):
mock_settings.ollama_model = "llama3.1"
mock_settings.ollama_url = "http://localhost:11434"
@@ -260,6 +272,8 @@ def test_create_timmy_no_unsupported_agent_kwargs():
patch("timmy.agent.Agent") as MockAgent,
patch("timmy.agent.Ollama"),
patch("timmy.agent.SqliteDb"),
patch("timmy.agent._resolve_model_with_fallback", return_value=("llama3.2:3b", False)),
patch("timmy.agent._check_model_available", return_value=True),
):
from timmy.agent import create_timmy
@@ -293,6 +307,8 @@ def test_create_timmy_no_extra_kwargs():
patch("timmy.agent.Agent") as MockAgent,
patch("timmy.agent.Ollama"),
patch("timmy.agent.SqliteDb"),
patch("timmy.agent._resolve_model_with_fallback", return_value=("llama3.2:3b", False)),
patch("timmy.agent._check_model_available", return_value=True),
):
from timmy.agent import create_timmy
@@ -317,6 +333,8 @@ def test_create_timmy_skip_mcp_omits_mcp_tools():
patch("timmy.agent.SqliteDb"),
patch("timmy.mcp_tools.create_gitea_mcp_tools") as mock_gitea_mcp,
patch("timmy.mcp_tools.create_filesystem_mcp_tools") as mock_fs_mcp,
patch("timmy.agent._resolve_model_with_fallback", return_value=("llama3.2:3b", False)),
patch("timmy.agent._check_model_available", return_value=True),
):
from timmy.agent import create_timmy
@@ -335,6 +353,8 @@ def test_create_timmy_default_includes_mcp_tools():
patch("timmy.agent.SqliteDb"),
patch("timmy.mcp_tools.create_gitea_mcp_tools", return_value=None) as mock_gitea_mcp,
patch("timmy.mcp_tools.create_filesystem_mcp_tools", return_value=None) as mock_fs_mcp,
patch("timmy.agent._resolve_model_with_fallback", return_value=("llama3.1", False)),
patch("timmy.agent._check_model_available", return_value=True),
):
from timmy.agent import create_timmy

View File

@@ -50,6 +50,8 @@ def test_main_agent_sets_timeout():
patch("timmy.agent.Ollama") as mock_ollama,
patch("timmy.agent.SqliteDb"),
patch("timmy.agent.Agent"),
patch("timmy.agent._resolve_model_with_fallback", return_value=("llama3.2:3b", False)),
patch("timmy.agent._check_model_available", return_value=True),
):
mock_ollama.return_value = MagicMock()