feat: fix async tests (#11176)

add tests
This commit is contained in:
Edwin Jose
2025-12-31 16:46:48 -05:00
committed by GitHub
parent 0d3bcd0e05
commit fc2635e00d

View File

@ -201,7 +201,10 @@ async def _delete_transactions_and_vertex_builds(session, flows: list[Flow]):
@pytest.fixture
async def async_client() -> AsyncGenerator:
app = create_app()
async with AsyncClient(app=app, base_url="http://testserver", http2=True) as client:
async with (
LifespanManager(app, startup_timeout=None, shutdown_timeout=None) as manager,
AsyncClient(transport=ASGITransport(app=manager.app), base_url="http://testserver", http2=True) as client,
):
yield client
@ -224,12 +227,15 @@ def session_fixture():
@pytest.fixture
async def async_session():
engine = create_async_engine("sqlite+aiosqlite://", connect_args={"check_same_thread": False}, poolclass=StaticPool)
async with engine.begin() as conn:
await conn.run_sync(SQLModel.metadata.create_all)
async with AsyncSession(engine, expire_on_commit=False) as session:
yield session
async with engine.begin() as conn:
await conn.run_sync(SQLModel.metadata.drop_all)
try:
async with engine.begin() as conn:
await conn.run_sync(SQLModel.metadata.create_all)
async with AsyncSession(engine, expire_on_commit=False) as session:
yield session
async with engine.begin() as conn:
await conn.run_sync(SQLModel.metadata.drop_all)
finally:
await engine.dispose()
class Config: