Add pre-commit hook enforcing 30s test suite time limit (#132)

This commit is contained in:
Alexander Whitestone
2026-03-05 19:45:38 -05:00
committed by GitHub
parent aff3edb06a
commit 2b97da9e9c
65 changed files with 356 additions and 611 deletions

View File

@@ -11,13 +11,13 @@ def test_index_returns_200(client):
def test_index_contains_title(client):
response = client.get("/")
assert "TIMMY TIME" in response.text
assert "MISSION CONTROL" in response.text
def test_index_contains_chat_interface(client):
response = client.get("/")
# Timmy panel loads dynamically via HTMX; verify the trigger attribute is present
assert 'hx-get="/agents/timmy/panel"' in response.text
# Agent panel loads dynamically via HTMX; verify the trigger attribute is present
assert 'hx-get="/agents/default/panel"' in response.text
# ── Health ────────────────────────────────────────────────────────────────────
@@ -79,49 +79,49 @@ def test_agents_list(client):
data = response.json()
assert "agents" in data
ids = [a["id"] for a in data["agents"]]
assert "orchestrator" in ids
assert "default" in ids
def test_agents_list_timmy_metadata(client):
def test_agents_list_metadata(client):
response = client.get("/agents")
orch = next(a for a in response.json()["agents"] if a["id"] == "orchestrator")
assert orch["name"] == "Orchestrator"
assert orch["model"] == "llama3.1:8b-instruct"
assert orch["type"] == "local"
agent = next(a for a in response.json()["agents"] if a["id"] == "default")
assert agent["name"] == "Agent"
assert agent["model"] == "llama3.1:8b-instruct"
assert agent["type"] == "local"
# ── Chat ──────────────────────────────────────────────────────────────────────
def test_chat_timmy_success(client):
def test_chat_agent_success(client):
with patch(
"dashboard.routes.agents.timmy_chat",
"dashboard.routes.agents.agent_chat",
return_value="Operational and ready.",
):
response = client.post("/agents/timmy/chat", data={"message": "status?"})
response = client.post("/agents/default/chat", data={"message": "status?"})
assert response.status_code == 200
assert "status?" in response.text
assert "Operational" in response.text
def test_chat_timmy_shows_user_message(client):
with patch("dashboard.routes.agents.timmy_chat", return_value="Acknowledged."):
response = client.post("/agents/timmy/chat", data={"message": "hello there"})
def test_chat_agent_shows_user_message(client):
with patch("dashboard.routes.agents.agent_chat", return_value="Acknowledged."):
response = client.post("/agents/default/chat", data={"message": "hello there"})
assert "hello there" in response.text
def test_chat_timmy_ollama_offline(client):
def test_chat_agent_ollama_offline(client):
# Without Ollama, chat returns an error but still shows the user message.
response = client.post("/agents/timmy/chat", data={"message": "ping"})
response = client.post("/agents/default/chat", data={"message": "ping"})
assert response.status_code == 200
assert "ping" in response.text
def test_chat_timmy_requires_message(client):
response = client.post("/agents/timmy/chat", data={})
def test_chat_agent_requires_message(client):
response = client.post("/agents/default/chat", data={})
assert response.status_code == 422
@@ -129,44 +129,40 @@ def test_chat_timmy_requires_message(client):
def test_history_empty_shows_init_message(client):
response = client.get("/agents/timmy/history")
response = client.get("/agents/default/history")
assert response.status_code == 200
assert "Mission Control initialized" in response.text
def test_history_records_user_and_agent_messages(client):
with patch("dashboard.routes.agents.timmy_chat", return_value="I am operational."):
client.post("/agents/timmy/chat", data={"message": "status check"})
with patch("dashboard.routes.agents.agent_chat", return_value="I am operational."):
client.post("/agents/default/chat", data={"message": "status check"})
response = client.get("/agents/timmy/history")
response = client.get("/agents/default/history")
assert "status check" in response.text
# Queue acknowledgment is NOT logged as an agent message; the real
# agent response is logged later by the task processor.
def test_history_records_error_when_offline(client):
# In async mode, if queuing succeeds the user message is recorded
# and the actual response is logged later by the task processor.
client.post("/agents/timmy/chat", data={"message": "ping"})
client.post("/agents/default/chat", data={"message": "ping"})
response = client.get("/agents/timmy/history")
response = client.get("/agents/default/history")
assert "ping" in response.text
def test_history_clear_resets_to_init_message(client):
with patch("dashboard.routes.agents.timmy_chat", return_value="Acknowledged."):
client.post("/agents/timmy/chat", data={"message": "hello"})
with patch("dashboard.routes.agents.agent_chat", return_value="Acknowledged."):
client.post("/agents/default/chat", data={"message": "hello"})
response = client.delete("/agents/timmy/history")
response = client.delete("/agents/default/history")
assert response.status_code == 200
assert "Mission Control initialized" in response.text
def test_history_empty_after_clear(client):
with patch("dashboard.routes.agents.timmy_chat", return_value="OK."):
client.post("/agents/timmy/chat", data={"message": "test"})
with patch("dashboard.routes.agents.agent_chat", return_value="OK."):
client.post("/agents/default/chat", data={"message": "test"})
client.delete("/agents/timmy/history")
response = client.get("/agents/timmy/history")
client.delete("/agents/default/history")
response = client.get("/agents/default/history")
assert "test" not in response.text
assert "Mission Control initialized" in response.text