- src/timmy/ — Agno agent wrapper (llama3.2 via Ollama, SQLite memory, TIMMY_SYSTEM_PROMPT) - src/dashboard/ — FastAPI + HTMX + Jinja2 Mission Control UI - /health + /health/status (Ollama ping, HTMX 30s poll) - /agents list + /agents/timmy/chat (HTMX form submission) - static/style.css — dark terminal mission-control aesthetic - tests/ — 27 pytest tests (prompts, agent config, dashboard routes); no Ollama required - pyproject.toml — hatchling build, pytest configured with pythonpath=src https://claude.ai/code/session_01M4L3R98N5fgXFZRvV8X9b6
80 lines
2.3 KiB
Python
80 lines
2.3 KiB
Python
from unittest.mock import MagicMock, patch
|
|
|
|
|
|
def test_create_timmy_returns_agent():
|
|
"""create_timmy should delegate to Agno Agent with correct config."""
|
|
with patch("timmy.agent.Agent") as MockAgent, \
|
|
patch("timmy.agent.Ollama"), \
|
|
patch("timmy.agent.SqliteDb"):
|
|
|
|
mock_instance = MagicMock()
|
|
MockAgent.return_value = mock_instance
|
|
|
|
from timmy.agent import create_timmy
|
|
result = create_timmy()
|
|
|
|
assert result is mock_instance
|
|
MockAgent.assert_called_once()
|
|
|
|
|
|
def test_create_timmy_agent_name():
|
|
with patch("timmy.agent.Agent") as MockAgent, \
|
|
patch("timmy.agent.Ollama"), \
|
|
patch("timmy.agent.SqliteDb"):
|
|
|
|
from timmy.agent import create_timmy
|
|
create_timmy()
|
|
|
|
kwargs = MockAgent.call_args.kwargs
|
|
assert kwargs["name"] == "Timmy"
|
|
|
|
|
|
def test_create_timmy_uses_llama32():
|
|
with patch("timmy.agent.Agent"), \
|
|
patch("timmy.agent.Ollama") as MockOllama, \
|
|
patch("timmy.agent.SqliteDb"):
|
|
|
|
from timmy.agent import create_timmy
|
|
create_timmy()
|
|
|
|
MockOllama.assert_called_once_with(id="llama3.2")
|
|
|
|
|
|
def test_create_timmy_history_config():
|
|
with patch("timmy.agent.Agent") as MockAgent, \
|
|
patch("timmy.agent.Ollama"), \
|
|
patch("timmy.agent.SqliteDb"):
|
|
|
|
from timmy.agent import create_timmy
|
|
create_timmy()
|
|
|
|
kwargs = MockAgent.call_args.kwargs
|
|
assert kwargs["add_history_to_context"] is True
|
|
assert kwargs["num_history_runs"] == 10
|
|
assert kwargs["markdown"] is True
|
|
|
|
|
|
def test_create_timmy_custom_db_file():
|
|
with patch("timmy.agent.Agent"), \
|
|
patch("timmy.agent.Ollama"), \
|
|
patch("timmy.agent.SqliteDb") as MockDb:
|
|
|
|
from timmy.agent import create_timmy
|
|
create_timmy(db_file="custom.db")
|
|
|
|
MockDb.assert_called_once_with(db_file="custom.db")
|
|
|
|
|
|
def test_create_timmy_embeds_system_prompt():
|
|
from timmy.prompts import TIMMY_SYSTEM_PROMPT
|
|
|
|
with patch("timmy.agent.Agent") as MockAgent, \
|
|
patch("timmy.agent.Ollama"), \
|
|
patch("timmy.agent.SqliteDb"):
|
|
|
|
from timmy.agent import create_timmy
|
|
create_timmy()
|
|
|
|
kwargs = MockAgent.call_args.kwargs
|
|
assert kwargs["description"] == TIMMY_SYSTEM_PROMPT
|