2a9ebe24: Implement auth endpoints (register/login/JWT) with SQLAlchemy

This commit is contained in:
OpenClaw Agent
2026-04-16 12:51:02 +00:00
parent ef5b32143a
commit 135d4111bb
12 changed files with 417 additions and 8 deletions

View File

@@ -1,9 +1,8 @@
"""Pytest configuration and fixtures."""
import pytest
from fastapi.testclient import TestClient
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.orm import sessionmaker, Session
from sqlalchemy.pool import StaticPool
from app.main import app
@@ -22,8 +21,11 @@ TestingSessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engin
@pytest.fixture(scope="function")
def db_session():
def db_session() -> Session:
"""Create a fresh database for each test."""
# Import models to ensure they're registered with Base
from app.models.user import User # noqa: F401
Base.metadata.create_all(bind=engine)
db = TestingSessionLocal()
try:
@@ -34,7 +36,7 @@ def db_session():
@pytest.fixture(scope="function")
def client(db_session):
def client(db_session: Session) -> TestClient:
"""Create a test client with fresh database."""
def override_get_db():