MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / test_twophase

Method test_twophase

test/orm/test_transaction.py:415–441  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

413
414 @testing.requires.two_phase_transactions
415 def test_twophase(self):
416 users, Address, addresses, User = (
417 self.tables.users,
418 self.classes.Address,
419 self.tables.addresses,
420 self.classes.User,
421 )
422
423 # TODO: mock up a failure condition here
424 # to ensure a rollback succeeds
425 self.mapper_registry.map_imperatively(User, users)
426 self.mapper_registry.map_imperatively(Address, addresses)
427
428 engine2 = engines.testing_engine()
429 sess = fixture_session(autoflush=False, twophase=True)
430 sess.bind_mapper(User, testing.db)
431 sess.bind_mapper(Address, engine2)
432 sess.begin()
433 u1 = User(name="u1")
434 a1 = Address(email_address="u1@e")
435 sess.add_all((u1, a1))
436 sess.commit()
437 sess.close()
438 engine2.dispose()
439 with testing.db.connect() as conn:
440 eq_(conn.scalar(select(func.count("*")).select_from(users)), 1)
441 eq_(conn.scalar(select(func.count("*")).select_from(addresses)), 1)
442
443 @testing.requires.independent_connections
444 def test_invalidate(self):

Callers

nothing calls this directly

Calls 15

fixture_sessionFunction · 0.90
eq_Function · 0.90
selectFunction · 0.90
map_imperativelyMethod · 0.80
testing_engineMethod · 0.80
UserClass · 0.70
AddressClass · 0.70
bind_mapperMethod · 0.45
beginMethod · 0.45
add_allMethod · 0.45
commitMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected