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_memory_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

70 lines
2.3 KiB
Python

"""Tests for the Memory API endpoints.
Verifies that facts can be created, searched, edited, and deleted
through the dashboard memory routes.
"""
def test_memory_page_returns_200(client):
response = client.get("/memory")
assert response.status_code == 200
assert "Memory Browser" in response.text
def test_add_fact_returns_html(client):
"""POST /memory/fact should return HTML partial with the new fact."""
response = client.post("/memory/fact", data={"fact": "Alexander is the operator"})
assert response.status_code == 200
assert "Alexander is the operator" in response.text
def test_add_fact_persists(client):
"""After adding a fact, it should appear on the main memory page."""
client.post("/memory/fact", data={"fact": "Timmy runs on Qwen"})
response = client.get("/memory")
assert response.status_code == 200
assert "Timmy runs on Qwen" in response.text
def test_memory_search_returns_html(client):
"""POST /memory/search should return HTML partial."""
response = client.post("/memory/search", data={"query": "test query"})
assert response.status_code == 200
def test_edit_fact(client):
"""PUT /memory/fact/{id} should update the fact content."""
# First create a fact
client.post("/memory/fact", data={"fact": "Original fact"})
# Get the fact ID from the memory page
page = client.get("/memory")
assert "Original fact" in page.text
# Extract a fact ID from the page (look for fact- pattern)
import re
match = re.search(r'id="fact-([^"]+)"', page.text)
if match:
fact_id = match.group(1)
response = client.put(
f"/memory/fact/{fact_id}",
json={"content": "Updated fact"},
)
assert response.status_code == 200
assert response.json()["success"] is True
def test_delete_fact(client):
"""DELETE /memory/fact/{id} should remove the fact."""
# Create a fact
client.post("/memory/fact", data={"fact": "Fact to delete"})
page = client.get("/memory")
import re
match = re.search(r'id="fact-([^"]+)"', page.text)
if match:
fact_id = match.group(1)
response = client.delete(f"/memory/fact/{fact_id}")
assert response.status_code == 200
assert response.json()["success"] is True