This commit is contained in:
2025-05-06 17:09:30 +02:00
parent 4a4f0e6947
commit 0433d79f0c
19 changed files with 875 additions and 242 deletions

27
tests/conftest.py Normal file
View File

@@ -0,0 +1,27 @@
import pytest
from sqlalchemy import create_engine
from sqlalchemy.orm import Session
from dibbler.models import Base
def pytest_addoption(parser):
parser.addoption(
"--echo",
action="store_true",
help="Enable SQLAlchemy echo mode for debugging",
)
@pytest.fixture(scope="function")
def session(request):
"""Create a new SQLAlchemy session for testing."""
echo = request.config.getoption("--echo")
engine = create_engine(
"sqlite:///:memory:",
echo=echo,
)
Base.metadata.create_all(engine)
with Session(engine) as session:
yield session