Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset 'tpc_phase' to zero during 'tpc_abort' / 'tpc_finish'. #38

Merged
merged 1 commit into from
Dec 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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