Beispiel #1
0
    def test_transaction_rollback(self):
        """Test rolling back a transaction."""

        tx = Transaction()

        self.assertTrue(tx._stack, "Transaction has no stack")
        self.assertEqual(1, len(begins), "Incorrect number of TrasactionBegin events")
        self.assertEqual(
            0, len(commits), "Incorrect number of TransactionCommit events"
        )
        self.assertEqual(
            0, len(rollbacks), "Incorrect number of TransactionRollback events"
        )

        tx.rollback()

        self.assertEqual(1, len(begins), "Incorrect number of TrasactionBegin events")
        self.assertEqual(
            0, len(commits), "Incorrect number of TransactionCommit events"
        )
        self.assertEqual(
            1, len(rollbacks), "Incorrect number of TransactionRollback events"
        )

        self.assertFalse(tx._stack, "Transaction stack is not empty")
Beispiel #2
0
    def test_transaction(self):
        """Test basic transaction functionality."""

        tx = Transaction()
        tx.rollback()

        tx = Transaction()
        tx.commit()
Beispiel #3
0
    def test_transaction(self):
        """Test basic transaction functionality."""

        tx = Transaction()
        tx.rollback()

        tx = Transaction()
        tx.commit()
Beispiel #4
0
    def test_transaction_commit_after_rollback(self):
        tx = Transaction()
        tx2 = Transaction()

        tx2.rollback()

        tx.commit()
        self.assertEquals(1, len(begins))
        self.assertEquals(0, len(commits))
        self.assertEquals(1, len(rollbacks))
Beispiel #5
0
def test_transaction_stack(event_manager):
    """Test the transaction stack."""

    tx1 = Transaction(event_manager)
    tx2 = Transaction(event_manager)

    with pytest.raises(TransactionError):
        tx1.commit()

    tx2.rollback()
    tx1.rollback()
Beispiel #6
0
    def test_transaction_stack(self):
        """Test the transaction stack."""

        tx1 = Transaction()
        tx2 = Transaction()

        try:
            self.assertRaises(TransactionError, tx1.commit)
        finally:
            tx2.rollback()
            tx1.rollback()
    def test_transaction_stack(self):
        """Test the transaction stack."""

        tx1 = Transaction()
        tx2 = Transaction()

        try:
            self.assertRaises(TransactionError, tx1.commit)
        finally:
            tx2.rollback()
            tx1.rollback()
Beispiel #8
0
    def test_transaction_rollback(self):
        tx = Transaction()
        self.assertTrue(tx._stack)
        self.assertEquals(1, len(begins))
        self.assertEquals(0, len(commits))
        self.assertEquals(0, len(rollbacks))

        tx.rollback()
        self.assertEquals(1, len(begins))
        self.assertEquals(0, len(commits))
        self.assertEquals(1, len(rollbacks))

        self.assertFalse(tx._stack)
Beispiel #9
0
def test_transaction_commit_after_rollback(event_manager):
    """Test committing one transaction after rolling back another
    transaction."""

    tx1 = Transaction(event_manager)
    tx2 = Transaction(event_manager)

    tx2.rollback()
    tx1.commit()

    assert 1 == len(begins), "Incorrect number of TrasactionBegin events"
    assert 0 == len(commits), "Incorrect number of TransactionCommit events"
    assert 1 == len(rollbacks), "Incorrect number of TransactionRollback events"
Beispiel #10
0
    def test_transaction_commit_after_rollback(self):
        """Test committing one transaction after rolling back another
        transaction."""
        
        tx1 = Transaction()
        tx2 = Transaction()

        tx2.rollback()
        tx1.commit()
        
        self.assertEquals(1, len(begins), 'Incorrect number of TrasactionBegin events')
        self.assertEquals(0, len(commits), 'Incorrect number of TransactionCommit events')
        self.assertEquals(1, len(rollbacks), 'Incorrect number of TransactionRollback events')
Beispiel #11
0
    def test_transaction_commit_after_rollback(self):
        """Test committing one transaction after rolling back another
        transaction."""

        tx1 = Transaction()
        tx2 = Transaction()

        tx2.rollback()
        tx1.commit()

        self.assertEquals(1, len(begins),
                          'Incorrect number of TrasactionBegin events')
        self.assertEquals(0, len(commits),
                          'Incorrect number of TransactionCommit events')
        self.assertEquals(1, len(rollbacks),
                          'Incorrect number of TransactionRollback events')
Beispiel #12
0
def test_transaction_rollback(event_manager):
    """Test rolling back a transaction."""

    tx = Transaction(event_manager)

    assert tx._stack, "Transaction has no stack"
    assert 1 == len(begins), "Incorrect number of TrasactionBegin events"
    assert 0 == len(commits), "Incorrect number of TransactionCommit events"
    assert 0 == len(rollbacks), "Incorrect number of TransactionRollback events"

    tx.rollback()

    assert 1 == len(begins), "Incorrect number of TrasactionBegin events"
    assert 0 == len(commits), "Incorrect number of TransactionCommit events"
    assert 1 == len(rollbacks), "Incorrect number of TransactionRollback events"

    assert not tx._stack, "Transaction stack is not empty"
Beispiel #13
0
    def test_transaction_rollback(self):
        """Test rolling back a transaction."""

        tx = Transaction()

        self.assertTrue(tx._stack, 'Transaction has no stack')
        self.assertEquals(1, len(begins),
                          'Incorrect number of TrasactionBegin events')
        self.assertEquals(0, len(commits),
                          'Incorrect number of TransactionCommit events')
        self.assertEquals(0, len(rollbacks),
                          'Incorrect number of TransactionRollback events')

        tx.rollback()

        self.assertEquals(1, len(begins),
                          'Incorrect number of TrasactionBegin events')
        self.assertEquals(0, len(commits),
                          'Incorrect number of TransactionCommit events')
        self.assertEquals(1, len(rollbacks),
                          'Incorrect number of TransactionRollback events')

        self.assertFalse(tx._stack, 'Transaction stack is not empty')