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:
@@ -19,7 +19,7 @@ templates = Jinja2Templates(directory="templates")
|
||||
@router.get("/")
|
||||
async def focus_view(request: Request, focus_date: Optional[str] = None, db: AsyncSession = Depends(get_db)):
|
||||
sidebar = await get_sidebar_data(db)
|
||||
target_date = focus_date or str(date.today())
|
||||
target_date = date.fromisoformat(focus_date) if focus_date else date.today()
|
||||
|
||||
result = await db.execute(text("""
|
||||
SELECT df.*, t.title, t.priority, t.status as task_status,
|
||||
@@ -72,15 +72,16 @@ async def add_to_focus(
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
repo = BaseRepository("daily_focus", db)
|
||||
parsed_date = date.fromisoformat(focus_date)
|
||||
# Get next sort order
|
||||
result = await db.execute(text("""
|
||||
SELECT COALESCE(MAX(sort_order), 0) + 10 FROM daily_focus
|
||||
WHERE focus_date = :fd AND is_deleted = false
|
||||
"""), {"fd": focus_date})
|
||||
"""), {"fd": parsed_date})
|
||||
next_order = result.scalar()
|
||||
|
||||
await repo.create({
|
||||
"task_id": task_id, "focus_date": focus_date,
|
||||
"task_id": task_id, "focus_date": parsed_date,
|
||||
"sort_order": next_order, "completed": False,
|
||||
})
|
||||
return RedirectResponse(url=f"/focus?focus_date={focus_date}", status_code=303)
|
||||
|
||||
@@ -180,7 +180,7 @@ async def manual_entry(
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
"""Add a manual time entry (no start/stop, just duration)."""
|
||||
start_at = f"{date}T12:00:00+00:00"
|
||||
start_at = datetime.fromisoformat(f"{date}T12:00:00+00:00")
|
||||
|
||||
await db.execute(text("""
|
||||
INSERT INTO time_entries (task_id, start_at, end_at, duration_minutes, notes, is_deleted, created_at)
|
||||
|
||||
Reference in New Issue
Block a user