async def test_startup_configure_async_session(): from fastapi_sqla.asyncio_support import _AsyncSession, startup startup() async with _AsyncSession() as session: res = await session.execute(text("SELECT 123")) assert res.scalar() == 123
async def test_all_opened_async_sessions_are_within_the_same_transaction( async_sqla_connection, async_session, singer_cls ): from fastapi_sqla.asyncio_support import _AsyncSession async_session.add(singer_cls(id=1, name="Bob Marley", country="Jamaica")) await async_session.commit() other_session = _AsyncSession(bind=async_sqla_connection) assert await other_session.get(singer_cls, 1)
async def async_session(async_sqla_connection): from fastapi_sqla.asyncio_support import _AsyncSession session = _AsyncSession(bind=async_sqla_connection) yield session await session.close()