Tweak tests

This commit is contained in:
Thomas Sileo 2022-07-10 15:29:51 +02:00
parent c3c4475e24
commit 229feb23db
2 changed files with 10 additions and 12 deletions

View file

@ -4,13 +4,11 @@ import pytest
from fastapi.testclient import TestClient from fastapi.testclient import TestClient
from app.database import Base from app.database import Base
from app.database import SessionLocal
from app.database import async_engine from app.database import async_engine
from app.database import async_session from app.database import async_session
from app.database import engine from app.database import engine
from app.main import app from app.main import app
from tests.factories import _Session
# _Session = orm.sessionmaker(bind=engine, autocommit=False, autoflush=False)
@pytest.fixture @pytest.fixture
@ -26,9 +24,9 @@ async def async_db_session():
@pytest.fixture @pytest.fixture
def db() -> Generator: def db() -> Generator:
Base.metadata.create_all(bind=engine) Base.metadata.create_all(bind=engine)
# sess = orm.sessionmaker(bind=engine)() try:
yield _Session yield SessionLocal()
# yield orm.scoped_session(orm.sessionmaker(bind=engine)) finally:
try: try:
Base.metadata.drop_all(bind=engine) Base.metadata.drop_all(bind=engine)
except Exception: except Exception:

View file

@ -11,10 +11,10 @@ from app import actor
from app import models from app import models
from app.actor import RemoteActor from app.actor import RemoteActor
from app.ap_object import RemoteObject from app.ap_object import RemoteObject
from app.database import engine from app.database import SessionLocal
from app.database import now from app.database import now
_Session = orm.scoped_session(orm.sessionmaker(bind=engine)) _Session = orm.scoped_session(SessionLocal)
def generate_key() -> tuple[str, str]: def generate_key() -> tuple[str, str]: