fix: mock _warmup_model in agent tests to prevent Ollama network calls (#159)
This commit is contained in:
@@ -8,6 +8,7 @@ def test_create_timmy_custom_db_file():
|
||||
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),
|
||||
patch("timmy.agent._warmup_model", return_value=True),
|
||||
):
|
||||
from timmy.agent import create_timmy
|
||||
|
||||
@@ -24,6 +25,7 @@ def test_create_timmy_embeds_system_prompt():
|
||||
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),
|
||||
patch("timmy.agent._warmup_model", return_value=True),
|
||||
):
|
||||
from timmy.agent import create_timmy
|
||||
|
||||
@@ -50,6 +52,7 @@ def test_create_timmy_passes_ollama_url_to_model():
|
||||
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),
|
||||
patch("timmy.agent._warmup_model", return_value=True),
|
||||
):
|
||||
from timmy.agent import create_timmy
|
||||
|
||||
@@ -72,6 +75,7 @@ def test_create_timmy_respects_custom_ollama_url():
|
||||
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),
|
||||
patch("timmy.agent._warmup_model", return_value=True),
|
||||
):
|
||||
mock_settings.ollama_model = "llama3.2"
|
||||
mock_settings.ollama_url = custom_url
|
||||
@@ -122,6 +126,7 @@ def test_create_timmy_explicit_ollama_ignores_autodetect():
|
||||
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),
|
||||
patch("timmy.agent._warmup_model", return_value=True),
|
||||
):
|
||||
from timmy.agent import create_timmy
|
||||
|
||||
@@ -225,6 +230,7 @@ def test_create_timmy_no_tools_for_small_model():
|
||||
patch("timmy.agent.create_full_toolkit", return_value=mock_toolkit),
|
||||
patch("timmy.agent._resolve_model_with_fallback", return_value=("llama3.2:3b", False)),
|
||||
patch("timmy.agent._check_model_available", return_value=True),
|
||||
patch("timmy.agent._warmup_model", return_value=True),
|
||||
):
|
||||
from timmy.agent import create_timmy
|
||||
|
||||
@@ -247,6 +253,7 @@ def test_create_timmy_includes_tools_for_large_model():
|
||||
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),
|
||||
patch("timmy.agent._warmup_model", return_value=True),
|
||||
):
|
||||
mock_settings.ollama_model = "llama3.1"
|
||||
mock_settings.ollama_url = "http://localhost:11434"
|
||||
@@ -274,6 +281,7 @@ def test_create_timmy_no_unsupported_agent_kwargs():
|
||||
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),
|
||||
patch("timmy.agent._warmup_model", return_value=True),
|
||||
):
|
||||
from timmy.agent import create_timmy
|
||||
|
||||
@@ -309,6 +317,7 @@ def test_create_timmy_no_extra_kwargs():
|
||||
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),
|
||||
patch("timmy.agent._warmup_model", return_value=True),
|
||||
):
|
||||
from timmy.agent import create_timmy
|
||||
|
||||
@@ -335,6 +344,7 @@ def test_create_timmy_skip_mcp_omits_mcp_tools():
|
||||
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),
|
||||
patch("timmy.agent._warmup_model", return_value=True),
|
||||
):
|
||||
from timmy.agent import create_timmy
|
||||
|
||||
@@ -355,6 +365,7 @@ def test_create_timmy_default_includes_mcp_tools():
|
||||
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),
|
||||
patch("timmy.agent._warmup_model", return_value=True),
|
||||
):
|
||||
from timmy.agent import create_timmy
|
||||
|
||||
|
||||
Reference in New Issue
Block a user