Tweak tests

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

View File

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