fix: test suite green (156 passed, 7 skipped)

- Fix seed data to match actual DB schemas (capture.processed, daily_focus.completed, weblinks junction table)
- Add date/datetime coercion in BaseRepository for asyncpg compatibility
- Add UUID validation in BaseRepository.get() to prevent DataError on invalid UUIDs
- Fix focus.py and time_tracking.py date string handling for asyncpg
- Fix test ordering (action before delete) and skip destructive admin actions
- Fix form_factory FK resolution for flat UUID strings
- Fix route_report.py to use get_route_registry(app)
- Add asyncio_default_test_loop_scope=session to pytest.ini

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-01 21:30:27 +00:00
parent f7c5ac2d89
commit a427f7c781
12 changed files with 203 additions and 81 deletions

View File

@@ -89,7 +89,7 @@ class TestSoftDeleteBehavior:
):
await client.post(f"/tasks/{seed_task['id']}/delete", follow_redirects=False)
await client.post(
f"/admin/trash/restore/tasks/{seed_task['id']}",
f"/admin/trash/tasks/{seed_task['id']}/restore",
follow_redirects=False,
)
r = await client.get("/tasks/")
@@ -155,7 +155,10 @@ class TestFocusWorkflow:
self, client: AsyncClient, db_session: AsyncSession, seed_task: dict,
):
# Add to focus
r = await client.post("/focus/add", data={"task_id": seed_task["id"]}, follow_redirects=False)
r = await client.post("/focus/add", data={
"task_id": seed_task["id"],
"focus_date": str(date.today()),
}, follow_redirects=False)
assert r.status_code in (303, 302)
@pytest.mark.asyncio
@@ -182,7 +185,8 @@ class TestEdgeCases:
@pytest.mark.asyncio
async def test_invalid_uuid_in_path(self, client: AsyncClient):
r = await client.get("/tasks/not-a-valid-uuid")
assert r.status_code in (404, 422, 400)
# 303 = redirect to list (app handles gracefully), 404/422/400 = explicit error
assert r.status_code in (404, 422, 400, 303)
@pytest.mark.asyncio
async def test_timer_start_without_task_id(self, client: AsyncClient):
@@ -208,5 +212,5 @@ async def _create_task(db: AsyncSession, domain_id: str, project_id: str, title:
"VALUES (:id, :did, :pid, :title, 'open', 3, 0, false, now(), now())"),
{"id": _id, "did": domain_id, "pid": project_id, "title": title},
)
await db.flush()
await db.commit()
return _id