def test_is_transaction_in_progress(self):
     # is_transaction_in_progress() returns False when all
     # transactions have been aborted.
     transaction.abort()
     self.failIf(isolation.is_transaction_in_progress())
     # is_transaction_in_progress() returns True when a
     # transactions has begun.
     self.createTransaction()
     self.failUnless(isolation.is_transaction_in_progress())
 def test_is_transaction_in_progress(self):
     # is_transaction_in_progress() returns False when all
     # transactions have been aborted.
     transaction.abort()
     self.assertFalse(isolation.is_transaction_in_progress())
     # is_transaction_in_progress() returns True when a
     # transactions has begun.
     self.createTransaction()
     self.assertTrue(isolation.is_transaction_in_progress())
Exemple #3
0
 def test_transaction(self):
     # The WonkingBase.transaction context manager ensures that no
     # transaction is in progress on entry, commits on a successful
     # exit, or aborts the transaction on failure.
     transaction_manager = StubTransactionManager()
     base = WorkingBase()
     base.init(self.email, transaction_manager, self.logger)
     transaction.commit()
     with base.transaction:
         self.assertFalse(is_transaction_in_progress())
         self.assertEqual([], transaction_manager.log)
         self.factory.makeEmail('*****@*****.**', self.person)
         self.assertTrue(is_transaction_in_progress())
         self.assertEqual([], transaction_manager.log)
     self.assertEqual(['commit'], transaction_manager.log)
 def test_transaction(self):
     # The WonkingBase.transaction context manager ensures that no
     # transaction is in progress on entry, commits on a successful
     # exit, or aborts the transaction on failure.
     transaction_manager = StubTransactionManager()
     base = WorkingBase()
     base.init(self.email, transaction_manager, self.logger)
     transaction.commit()
     with base.transaction:
         self.assertFalse(is_transaction_in_progress())
         self.assertEqual([], transaction_manager.log)
         self.factory.makeEmail("*****@*****.**", self.person)
         self.assertTrue(is_transaction_in_progress())
         self.assertEqual([], transaction_manager.log)
     self.assertEqual(["commit"], transaction_manager.log)
Exemple #5
0
 def test_transaction_with_open_transaction(self):
     # On entry, WorkingBase.transaction will raise an exception if
     # a transaction is in progress.
     transaction_manager = StubTransactionManager()
     base = WorkingBase()
     base.init(self.email, transaction_manager, self.logger)
     self.assertTrue(is_transaction_in_progress())
     self.assertRaises(TransactionInProgress, base.transaction.__enter__)
 def test_transaction_with_open_transaction(self):
     # On entry, WorkingBase.transaction will raise an exception if
     # a transaction is in progress.
     transaction_manager = StubTransactionManager()
     base = WorkingBase()
     base.init(self.email, transaction_manager, self.logger)
     self.assertTrue(is_transaction_in_progress())
     self.assertRaises(TransactionInProgress, base.transaction.__enter__)
Exemple #7
0
 def test_transaction_with_exception(self):
     # If an exception is raised when the transaction context
     # manager is active, the transaction will be aborted and the
     # exception re-raised.
     transaction_manager = StubTransactionManager()
     base = WorkingBase()
     base.init(self.email, transaction_manager, self.logger)
     transaction.commit()
     try:
         with base.transaction:
             raise RuntimeError("Nothing really.")
     except RuntimeError:
         self.assertFalse(is_transaction_in_progress())
         self.assertEqual(['abort'], transaction_manager.log)
     else:
         self.fail("Exception not re-raised from context manager.")
 def test_transaction_with_exception(self):
     # If an exception is raised when the transaction context
     # manager is active, the transaction will be aborted and the
     # exception re-raised.
     transaction_manager = StubTransactionManager()
     base = WorkingBase()
     base.init(self.email, transaction_manager, self.logger)
     transaction.commit()
     try:
         with base.transaction:
             raise RuntimeError("Nothing really.")
     except RuntimeError:
         self.assertFalse(is_transaction_in_progress())
         self.assertEqual(["abort"], transaction_manager.log)
     else:
         self.fail("Exception not re-raised from context manager.")