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

@@ -13,6 +13,7 @@ from tests.introspect import introspect_app
# Build route registry from live app
ROUTE_REGISTRY = introspect_app(app)
ALL_ROUTES = ROUTE_REGISTRY # Alias used by test_crud_dynamic.py
# Classify routes into buckets for parametrized tests
GET_NO_PARAMS = [r for r in ROUTE_REGISTRY if "GET" in r.methods and not r.path_params]
@@ -56,14 +57,5 @@ def resolve_path(path_template, seeds):
break
return result
# CRITICAL: Dispose the async engine created at import time.
# It was bound to whatever event loop existed during collection.
# When tests run, pytest-asyncio creates a NEW event loop.
# The engine will lazily recreate its connection pool on that new loop.
try:
from core.database import engine
loop = asyncio.new_event_loop()
loop.run_until_complete(engine.dispose())
loop.close()
except Exception:
pass # If disposal fails, tests will still try to proceed
# Note: Engine disposal is handled by the _reinit_engine fixture in conftest.py.
# It runs within the test event loop, ensuring the pool is recreated correctly.