873f53b9fc
- Remove PostgreSQL-specific server_default from User.email_inbound_token. The column has a Python-side default (secrets.token_urlsafe) that works for both SQLite and PostgreSQL. The gen_random_bytes() server_default caused sqlite table creation to fail. - Add missing back_populates relationships to stub models so SQLAlchemy mapper configuration succeeds. Purchase.user and Store.user_accounts were missing, causing "has no property" errors during Base.metadata.create_all. - Auto-fix ruff import sorting (I001) across all source and test files. - Manually fix line-too-long (E501) in config.py. Co-Authored-By: Paperclip <noreply@paperclip.ing>
25 lines
562 B
Python
25 lines
562 B
Python
"""Shared test fixtures for pipeline tests."""
|
|
|
|
import pytest
|
|
from sqlalchemy import create_engine
|
|
from sqlalchemy.orm import sessionmaker
|
|
|
|
from receiptwitness.shared.models import Base
|
|
|
|
|
|
@pytest.fixture
|
|
def engine():
|
|
"""In-memory SQLite engine for unit tests."""
|
|
eng = create_engine("sqlite:///:memory:")
|
|
Base.metadata.create_all(eng)
|
|
yield eng
|
|
eng.dispose()
|
|
|
|
|
|
@pytest.fixture
|
|
def session(engine):
|
|
"""SQLAlchemy session bound to in-memory SQLite."""
|
|
factory = sessionmaker(bind=engine)
|
|
with factory() as sess:
|
|
yield sess
|