Esempio n. 1
0
    def test_success(self):
        with Transaction() as action:
            action.test.success()
            action.test.success()
            action.test.success()

        action = Transaction()
        action.start()
        action.test.success()
        action.test.success()
        action.test.success()
        action.end(False)

        self.assertEqual(counter["execute"], 6)
        self.assertEqual(counter["commit"], 6)
        self.assertEqual(counter["revert"], 0)
Esempio n. 2
0
    def test_rollback(self):
        with self.assertRaises(RuntimeError):
            with Transaction() as action:
                action.test.success()
                action.test.success()
                action.test.success()
                raise RuntimeError()

        action = Transaction()
        action.start()
        action.test.success()
        action.test.success()
        action.test.success()
        action.end(True)

        self.assertEqual(counter["execute"], 6)
        self.assertEqual(counter["commit"], 0)
        self.assertEqual(counter["revert"], 6)