# #region RoutesTestsConftest [TYPE Module] [C:1] [SEMANTICS test, fixture, mock, conftest]
# @BRIEF Shared low-fidelity test doubles for API route test modules.

# Set required env vars before any app imports
import os

os.environ.setdefault("SECRET_KEY", "test-secret-key-for-testing")
os.environ.setdefault("AUTH_DATABASE_URL", "sqlite:///:memory:test_auth")
os.environ.setdefault("DEV_MODE", "true")
class FakeQuery:
    """Shared chainable query stub for route tests.
    WARNING: filter() is predicate-blind — all ownership and permission filters are
    ignored. Tests using FakeQuery cannot verify scoped data access. This is a
    known limitation; do not use for permission-sensitive test paths without a
    spec-guarded replacement.
    """
    def __init__(self, rows):
        self._rows = list(rows)
        self._seen_predicates = []
    def filter(self, *args, **kwargs):
        # Predicate-aware bookkeeping only; no predicate evaluation is performed.
        self._seen_predicates.append((args, kwargs))
        return self
    def order_by(self, *args, **kwargs):
        return self
    def limit(self, limit):
        self._rows = self._rows[:limit]
        return self
    def offset(self, offset):
        self._rows = self._rows[offset:]
        return self
    def first(self):
        return self._rows[0] if self._rows else None
    def all(self):
        return list(self._rows)
    def count(self):
        return len(self._rows)
# #endregion RoutesTestsConftest
