Skip to content

Commit b641554

Browse files
committed
Reset 'tpc_phase' to zero during 'tpc_abort'/'tpc_finish'.
Closes #31.
1 parent af9b7db commit b641554

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

repoze/sendmail/delivery.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def _finish(self, final_state):
102102
if self.transaction is None:
103103
raise ValueError("Not in a transaction")
104104
self.state = final_state
105+
self.tpc_phase = 0
105106

106107
def commit(self, trans):
107108
if self.transaction is None:

repoze/sendmail/tests/test_delivery.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def test__finish_w_transaction(self):
7979
mdm.join_transaction(txn)
8080
mdm._finish(2)
8181
self.assertEqual(mdm.state, 2)
82+
self.assertEqual(mdm.tpc_phase, 0)
8283

8384
def test_commit_wo_transaction(self):
8485
mdm = self._makeOne(object)
@@ -251,6 +252,7 @@ def _callable(*args):
251252
mdm.tpc_finish(txn)
252253
self.assertEqual(_called, [(1, 2)])
253254
self.assertEqual(mdm.state, MailDataManagerState.TPC_FINISHED)
255+
self.assertEqual(mdm.tpc_phase, 0)
254256

255257
def test_tpc_abort_wo_transaction(self):
256258
mdm = self._makeOne()
@@ -287,6 +289,7 @@ def test_tpc_abort_begun_ok(self):
287289
mdm.tpc_phase = 1
288290
mdm.tpc_abort(txn)
289291
self.assertEqual(mdm.state, MailDataManagerState.TPC_ABORTED)
292+
self.assertEqual(mdm.tpc_phase, 0)
290293

291294
def test_tpc_abort_voted_ok(self):
292295
from ..delivery import MailDataManagerState
@@ -296,6 +299,7 @@ def test_tpc_abort_voted_ok(self):
296299
mdm.tpc_phase = 2
297300
mdm.tpc_abort(txn)
298301
self.assertEqual(mdm.state, MailDataManagerState.TPC_ABORTED)
302+
self.assertEqual(mdm.tpc_phase, 0)
299303

300304

301305
class TestAbstractMailDelivery(unittest.TestCase):

0 commit comments

Comments
 (0)