This repository has been archived on 2026-03-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Timmy-time-dashboard/tests/dashboard/test_tasks_api.py
Alexander Whitestone e36a1dc939 fix: resolve 6 dashboard bugs and rebuild Task Queue + Work Orders (#144) (#144)
Round 2+3 bug fix batch:

1. Ollama timeout: Add request_timeout=300 to prevent socket read errors
   on complex 30-60s prompts (production crash fix)

2. Memory API: Create missing HTMX partial templates (memory_facts.html,
   memory_results.html) so Save/Search buttons work

3. CALM page: Add create_tables() call so SQLAlchemy tables exist on
   first request (was returning HTTP 500)

4. Task Queue: Full SQLite-backed rebuild with CRUD endpoints, HTMX
   partials, and action buttons (approve/veto/pause/cancel/retry)

5. Work Orders: Full SQLite-backed rebuild with submit/approve/reject/
   execute pipeline and HTMX polling partials

6. Memory READ tool: Add memory_read function so Timmy stops calling
   read_file when trying to recall stored facts

Also: Close GitHub issues #115, #114, #112, #110 as won't-fix.
Comment on #107 confirming prune_memories() already wired to startup.

Tests: 33 new tests across 4 test files, all passing.
Full suite: 1155 passed, 2 pre-existing failures (hands_shell).

Co-authored-by: Trip T <trip@local>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 23:21:30 -05:00

92 lines
2.8 KiB
Python

"""Tests for the Task Queue API endpoints.
Verifies task CRUD operations and the dashboard page rendering.
"""
def test_tasks_page_returns_200(client):
response = client.get("/tasks")
assert response.status_code == 200
assert "TASK QUEUE" in response.text
def test_create_task(client):
"""POST /api/tasks returns 201 with task JSON."""
response = client.post("/api/tasks", json={
"title": "Fix the memory bug",
"priority": "high",
})
assert response.status_code == 201
data = response.json()
assert data["title"] == "Fix the memory bug"
assert data["priority"] == "high"
assert data["status"] == "pending_approval"
assert "id" in data
def test_list_tasks(client):
"""GET /api/tasks returns JSON array."""
response = client.get("/api/tasks")
assert response.status_code == 200
assert isinstance(response.json(), list)
def test_create_and_list_roundtrip(client):
"""Creating a task makes it appear in the list."""
client.post("/api/tasks", json={"title": "Roundtrip test"})
response = client.get("/api/tasks")
tasks = response.json()
assert any(t["title"] == "Roundtrip test" for t in tasks)
def test_update_task_status(client):
"""PATCH /api/tasks/{id}/status updates the task."""
create = client.post("/api/tasks", json={"title": "To approve"})
task_id = create.json()["id"]
response = client.patch(
f"/api/tasks/{task_id}/status",
json={"status": "approved"},
)
assert response.status_code == 200
assert response.json()["status"] == "approved"
def test_delete_task(client):
"""DELETE /api/tasks/{id} removes the task."""
create = client.post("/api/tasks", json={"title": "To delete"})
task_id = create.json()["id"]
response = client.delete(f"/api/tasks/{task_id}")
assert response.status_code == 200
# Verify it's gone
tasks = client.get("/api/tasks").json()
assert not any(t["id"] == task_id for t in tasks)
def test_create_task_missing_title_422(client):
"""POST /api/tasks without title returns 422."""
response = client.post("/api/tasks", json={"priority": "high"})
assert response.status_code == 422
def test_create_task_via_form(client):
"""POST /tasks/create via form creates and returns task card HTML."""
response = client.post("/tasks/create", data={
"title": "Form task",
"description": "Created via form",
"priority": "normal",
"assigned_to": "",
})
assert response.status_code == 200
assert "Form task" in response.text
def test_pending_partial(client):
"""GET /tasks/pending returns HTML partial."""
client.post("/api/tasks", json={"title": "Pending task"})
response = client.get("/tasks/pending")
assert response.status_code == 200
assert "Pending task" in response.text