feat: add SQLite persistence models
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import pytest
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import Session, sessionmaker
|
||||
from sqlalchemy.pool import StaticPool
|
||||
|
||||
from app.db.models import Base
|
||||
from app.db.repositories import ActivityRepository, UserRepository
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def db_session() -> Session:
|
||||
engine = create_engine(
|
||||
"sqlite://",
|
||||
connect_args={"check_same_thread": False},
|
||||
poolclass=StaticPool,
|
||||
)
|
||||
Base.metadata.create_all(engine)
|
||||
factory = sessionmaker(bind=engine, expire_on_commit=False)
|
||||
with factory() as session:
|
||||
yield session
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def user_repository(db_session: Session) -> UserRepository:
|
||||
return UserRepository(db_session)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def activity_repository(db_session: Session) -> ActivityRepository:
|
||||
return ActivityRepository(db_session)
|
||||
|
||||
Reference in New Issue
Block a user