From 836bc1a3a4f3b64d90b0bed57bcdf9a819a05f68 Mon Sep 17 00:00:00 2001 From: extreme4all <> Date: Tue, 19 Mar 2024 21:58:49 +0100 Subject: [PATCH] cleanup --- tests/conftest.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 89f59e2..92be3c9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -16,24 +16,24 @@ from src.core import server # noqa: E402 from src.core.fastapi.dependencies.session import get_session # noqa: E402 +# Create an async SQLAlchemy engine +engine = create_async_engine( + "mysql+aiomysql://root:root_bot_buster@localhost:3307/playerdata", + pool_timeout=30, + pool_recycle=30, + echo=True, + pool_pre_ping=True, +) + +# Create a session factory +SessionFactory = sessionmaker( + bind=engine, + expire_on_commit=False, + class_=AsyncSession, # Use AsyncSession for asynchronous operations +) + async def get_session_override(): - # for some reason this has to be in here - # Create an async SQLAlchemy engine - engine = create_async_engine( - "mysql+aiomysql://root:root_bot_buster@localhost:3307/playerdata", - pool_timeout=30, - pool_recycle=30, - echo=True, - pool_pre_ping=True, - ) - - # Create a session factory - SessionFactory = sessionmaker( - bind=engine, - expire_on_commit=False, - class_=AsyncSession, # Use AsyncSession for asynchronous operations - ) async with SessionFactory() as session: session: AsyncSession yield session