Commit e581a120 authored by Jim Fulton's avatar Jim Fulton

Fixed: Synchonizers that registered with transaction managers when

  transactions were in progress didn't have their newTransaction
  methods called to let them know of the in-progress transactions.
parent a1504282
Changes
=======
1.6.1 (unreleased)
------------------
- Fixed: Synchonizers that registered with transaction managers when
transactions were in progress didn't have their newTransaction
methods called to let them know of the in-progress transactions.
1.6.0 (2016-05-21)
------------------
......
......@@ -89,6 +89,8 @@ class TransactionManager(object):
""" See ITransactionManager.
"""
self._synchs.add(synch)
if self._txn is not None:
synch.newTransaction(self._txn)
def unregisterSynch(self, synch):
""" See ITransactionManager.
......
......@@ -442,6 +442,27 @@ class TransactionManagerTests(unittest.TestCase):
assert nosub1._p_jar.ctpc_abort == 1
def test_notify_transaction_late_comers(self):
# If a datamanager registers for synchonization after a
# transaction has started, we should call newTransaction so it
# can do necessry setup.
import mock
from .. import TransactionManager
manager = TransactionManager()
sync1 = mock.MagicMock()
manager.registerSynch(sync1)
sync1.newTransaction.assert_not_called()
t = manager.begin()
sync1.newTransaction.assert_called_with(t)
sync2 = mock.MagicMock()
manager.registerSynch(sync2)
sync2.newTransaction.assert_called_with(t)
# for, um, completeness
t.commit()
for s in sync1, sync2:
s.beforeCompletion.assert_called_with(t)
s.afterCompletion.assert_called_with(t)
class AttemptTests(unittest.TestCase):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment