Files
lifeos-dev/tests/route_report.py
M Dombaugh a427f7c781 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>
2026-03-01 21:30:27 +00:00

66 lines
2.2 KiB
Python

"""
Route Registry Report
=====================
Run inside the container to see exactly what the introspection engine
discovers from the live app. Use this to verify before running tests.
Usage:
docker exec lifeos-dev python -m tests.route_report
"""
from __future__ import annotations
import sys
sys.path.insert(0, "/app")
from tests.registry import ALL_ROUTES, PREFIX_TO_SEED # noqa: E402
from tests.introspect import dump_registry_report, get_route_registry, RouteKind # noqa: E402
from main import app # noqa: E402
def main():
print(dump_registry_report(app))
reg = get_route_registry(app)
print("\n" + "=" * 70)
print("SUMMARY")
print("=" * 70)
print(f" Total routes: {len(reg['all'])}")
print(f" GET (no params): {len(reg['get_no_params'])}")
print(f" GET (with params): {len(reg['get_with_params'])}")
print(f" POST create: {len(reg['post_create'])}")
print(f" POST edit: {len(reg['post_edit'])}")
print(f" POST delete: {len(reg['post_delete'])}")
print(f" POST action/toggle: {len(reg['post_action'])}")
print(f" Entity prefixes: {len(reg['by_prefix'])}")
print()
# Warn about POST routes with no discovered form fields
for r in reg["post_create"]:
if not r.form_fields:
print(f" WARNING: {r.path} has no discovered Form() fields")
for r in reg["post_edit"]:
if not r.form_fields:
print(f" WARNING: {r.path} has no discovered Form() fields")
# Show seed mapping coverage
print()
print("PREFIX_TO_SEED coverage:")
print("-" * 70)
for prefix in sorted(reg["by_prefix"].keys()):
has_seed = prefix in PREFIX_TO_SEED and PREFIX_TO_SEED[prefix] is not None
marker = "OK" if has_seed else "SKIP (no seed)"
print(f" {prefix:30s} {marker}")
print()
print("Form field details for create routes:")
print("-" * 70)
for r in reg["post_create"]:
if r.form_fields:
fields = [f" {f.name}: {f.annotation}{'*' if f.required else ''}" for f in r.form_fields]
print(f"\n {r.path}")
print("\n".join(fields))
if __name__ == "__main__":
main()