def test_before_request_transaction_active(self): commands.begin() transactions_before = database.command('showLiveTransactions') handlers.transaction_before_request() transactions = database.command('showLiveTransactions') assert_equal(len(transactions['transactions']), 1) assert_not_equal( transactions_before['transactions'][0]['txnid'], transactions['transactions'][0]['txnid'], )
def process_request(self, request): """Begin a transaction if one doesn't already exist.""" transaction_before_request()
def test_before_request_unexpected_error(self, mock_rollback): mock_rollback.side_effect = OperationFailure('daamn!') with assert_raises(OperationFailure): handlers.transaction_before_request()
def test_before_request(self): handlers.transaction_before_request() transactions = database.command('showLiveTransactions') assert_equal(len(transactions['transactions']), 1)