-
Stefy Lanza (nextime / spora ) authored
User-scoped dashboard route tests set a session cookie for a synthetic user but only stubbed the database in the route-handler modules — not the one the auth middleware consults. The middleware's "account deleted" guard (get_user_by_id(user_id) is falsy -> redirect to /dashboard/login) therefore bounced every request until httpx raised TooManyRedirects, failing ~32 tests. Add tests/routes/conftest.py with an autouse fixture that wraps DatabaseRegistry.get_config_database so get_user_by_id returns a present user ONLY when the lookup comes from the auth middleware (detected via call stack). Direct database assertions in other tests (e.g. signup cleanup, which expects deleted users to read back as None) keep observing the real database, and tests that install their own get_config_database stub still win. Route suite: TooManyRedirects failures 32 -> 0. Remaining route failures are unrelated pre-existing issues (studio tests await-ing coroutines, a handler awaiting a dict, a stub missing record_dashboard_event, template bootstrap content drift) and are out of scope for this fix. Co-Authored-By:Claude Opus 4.8 <noreply@anthropic.com>
e69ce2d5