Beispiel #1
0
    async def test_transaction_accessor(self, async_engine):
        async with async_engine.connect() as conn:
            is_none(conn.get_transaction())
            is_false(conn.in_transaction())
            is_false(conn.in_nested_transaction())

            trans = await conn.begin()

            is_true(conn.in_transaction())
            is_false(conn.in_nested_transaction())

            is_(
                trans.sync_transaction, conn.get_transaction().sync_transaction
            )

            nested = await conn.begin_nested()

            is_true(conn.in_transaction())
            is_true(conn.in_nested_transaction())

            is_(
                trans.sync_transaction, conn.get_transaction().sync_transaction
            )

            await nested.commit()

            is_true(conn.in_transaction())
            is_false(conn.in_nested_transaction())

            await trans.rollback()

            is_none(conn.get_transaction())
            is_false(conn.in_transaction())
            is_false(conn.in_nested_transaction())
Beispiel #2
0
    async def test_transaction_accessor(self, async_connection):
        conn = async_connection
        is_none(conn.get_transaction())
        is_false(conn.in_transaction())
        is_false(conn.in_nested_transaction())

        trans = await conn.begin()

        is_true(conn.in_transaction())
        is_false(conn.in_nested_transaction())

        is_(trans.sync_transaction, conn.get_transaction().sync_transaction)

        nested = await conn.begin_nested()

        is_true(conn.in_transaction())
        is_true(conn.in_nested_transaction())

        is_(
            conn.get_nested_transaction().sync_transaction,
            nested.sync_transaction,
        )
        eq_(conn.get_nested_transaction(), nested)

        is_(trans.sync_transaction, conn.get_transaction().sync_transaction)

        await nested.commit()

        is_true(conn.in_transaction())
        is_false(conn.in_nested_transaction())

        await trans.rollback()

        is_none(conn.get_transaction())
        is_false(conn.in_transaction())
        is_false(conn.in_nested_transaction())