Skip to content

Commit

Permalink
Reset 'tpc_phase' to zero during 'tpc_abort'/'tpc_finish'.
Browse files Browse the repository at this point in the history
Closes #31.
  • Loading branch information
tseaver committed Dec 7, 2016
1 parent a64dcae commit c7eb0d9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions repoze/sendmail/delivery.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def _finish(self, final_state):
if self.transaction is None:
raise ValueError("Not in a transaction")
self.state = final_state
self.tpc_phase = 0

def commit(self, trans):
if self.transaction is None:
Expand Down
4 changes: 4 additions & 0 deletions repoze/sendmail/tests/test_delivery.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def test__finish_w_transaction(self):
mdm.join_transaction(txn)
mdm._finish(2)
self.assertEqual(mdm.state, 2)
self.assertEqual(mdm.tpc_phase, 0)

def test_commit_wo_transaction(self):
mdm = self._makeOne(object)
Expand Down Expand Up @@ -251,6 +252,7 @@ def _callable(*args):
mdm.tpc_finish(txn)
self.assertEqual(_called, [(1, 2)])
self.assertEqual(mdm.state, MailDataManagerState.TPC_FINISHED)
self.assertEqual(mdm.tpc_phase, 0)

def test_tpc_abort_wo_transaction(self):
mdm = self._makeOne()
Expand Down Expand Up @@ -287,6 +289,7 @@ def test_tpc_abort_begun_ok(self):
mdm.tpc_phase = 1
mdm.tpc_abort(txn)
self.assertEqual(mdm.state, MailDataManagerState.TPC_ABORTED)
self.assertEqual(mdm.tpc_phase, 0)

def test_tpc_abort_voted_ok(self):
from ..delivery import MailDataManagerState
Expand All @@ -296,6 +299,7 @@ def test_tpc_abort_voted_ok(self):
mdm.tpc_phase = 2
mdm.tpc_abort(txn)
self.assertEqual(mdm.state, MailDataManagerState.TPC_ABORTED)
self.assertEqual(mdm.tpc_phase, 0)


class TestAbstractMailDelivery(unittest.TestCase):
Expand Down

0 comments on commit c7eb0d9

Please sign in to comment.