feat: code quality audit + autoresearch integration + infra hardening (#150)

This commit is contained in:
Alexander Whitestone
2026-03-08 12:50:44 -04:00
committed by GitHub
parent fd0ede0d51
commit ae3bb1cc21
186 changed files with 5129 additions and 3289 deletions

View File

@@ -5,13 +5,13 @@ agent tools on /tools, notification bell /api/notifications,
and Ollama timeout parameter.
"""
from unittest.mock import patch, MagicMock
from unittest.mock import MagicMock, patch
# ---------------------------------------------------------------------------
# Fix 1: /calm no longer returns 500
# ---------------------------------------------------------------------------
def test_calm_page_returns_200(client):
"""GET /calm should render without error now that tables are created."""
response = client.get("/calm")
@@ -29,6 +29,7 @@ def test_calm_morning_ritual_form_returns_200(client):
# Fix 2: /api/queue/status endpoint exists
# ---------------------------------------------------------------------------
def test_queue_status_returns_json(client):
"""GET /api/queue/status returns valid JSON instead of 404."""
response = client.get("/api/queue/status?assigned_to=default")
@@ -50,10 +51,13 @@ def test_queue_status_default_idle(client):
def test_queue_status_reflects_running_task(client):
"""Queue status shows working when a task is running."""
# Create a task and set it to running
create = client.post("/api/tasks", json={
"title": "Running task",
"assigned_to": "default",
})
create = client.post(
"/api/tasks",
json={
"title": "Running task",
"assigned_to": "default",
},
)
task_id = create.json()["id"]
client.patch(f"/api/tasks/{task_id}/status", json={"status": "approved"})
client.patch(f"/api/tasks/{task_id}/status", json={"status": "running"})
@@ -68,6 +72,7 @@ def test_queue_status_reflects_running_task(client):
# Fix 3: Bootstrap JS present in base.html (creative tabs)
# ---------------------------------------------------------------------------
def test_base_html_has_bootstrap_js(client):
"""base.html should include bootstrap.bundle.min.js for tab switching."""
response = client.get("/")
@@ -86,6 +91,7 @@ def test_creative_page_returns_200(client):
# Fix 4: Swarm Live WebSocket sends initial state
# ---------------------------------------------------------------------------
def test_swarm_live_page_returns_200(client):
"""GET /swarm/live renders the live dashboard page."""
response = client.get("/swarm/live")
@@ -95,6 +101,7 @@ def test_swarm_live_page_returns_200(client):
def test_swarm_live_websocket_sends_initial_state(client):
"""WebSocket at /swarm/live sends initial_state on connect."""
import json
with client.websocket_connect("/swarm/live") as ws:
data = ws.receive_json()
assert data["type"] == "initial_state"
@@ -108,6 +115,7 @@ def test_swarm_live_websocket_sends_initial_state(client):
# Fix 5: Agent tools populated on /tools page
# ---------------------------------------------------------------------------
def test_tools_page_returns_200(client):
"""GET /tools loads successfully."""
response = client.get("/tools")
@@ -120,6 +128,7 @@ def test_tools_page_shows_agent_capabilities(client):
# The tools registry always has at least the built-in tools
# If tools are registered, we should NOT see the empty message
from timmy.tools import get_all_available_tools
if get_all_available_tools():
assert "No agents registered yet" not in response.text
assert "Timmy" in response.text
@@ -137,6 +146,7 @@ def test_tools_api_stats_returns_json(client):
# Fix 6: Notification bell dropdown + /api/notifications
# ---------------------------------------------------------------------------
def test_notifications_api_returns_json(client):
"""GET /api/notifications returns a JSON array."""
response = client.get("/api/notifications")
@@ -156,14 +166,16 @@ def test_notifications_bell_dropdown_in_html(client):
# Fix 0b: Ollama timeout parameter
# ---------------------------------------------------------------------------
def test_create_timmy_uses_timeout_not_request_timeout():
"""create_timmy() should pass timeout=300, not request_timeout."""
with patch("timmy.agent.Ollama") as mock_ollama, \
patch("timmy.agent.SqliteDb"), \
patch("timmy.agent.Agent"):
with patch("timmy.agent.Ollama") as mock_ollama, patch("timmy.agent.SqliteDb"), patch(
"timmy.agent.Agent"
):
mock_ollama.return_value = MagicMock()
from timmy.agent import create_timmy
try:
create_timmy()
except Exception:
@@ -171,8 +183,7 @@ def test_create_timmy_uses_timeout_not_request_timeout():
if mock_ollama.called:
_, kwargs = mock_ollama.call_args
assert "request_timeout" not in kwargs, \
"Should use 'timeout', not 'request_timeout'"
assert "request_timeout" not in kwargs, "Should use 'timeout', not 'request_timeout'"
assert kwargs.get("timeout") == 300
@@ -180,14 +191,18 @@ def test_create_timmy_uses_timeout_not_request_timeout():
# Task lifecycle e2e: create → approve → run → complete
# ---------------------------------------------------------------------------
def test_task_full_lifecycle(client):
"""Test full task lifecycle: create → approve → running → completed."""
# Create
create = client.post("/api/tasks", json={
"title": "Lifecycle test",
"priority": "high",
"assigned_to": "default",
})
create = client.post(
"/api/tasks",
json={
"title": "Lifecycle test",
"priority": "high",
"assigned_to": "default",
},
)
assert create.status_code == 201
task_id = create.json()["id"]
@@ -234,6 +249,7 @@ def test_task_full_lifecycle(client):
# Pages that were broken — verify they return 200
# ---------------------------------------------------------------------------
def test_all_dashboard_pages_return_200(client):
"""Smoke test: all main dashboard routes return 200."""
pages = [