def test_commit_from_another_thread(self): transaction = self.client.new_transaction() t = Thread(target=transaction.begin) t.start() t.join() with self.assertRaises(TransactionError): transaction.commit()
def test_begin_and_commit_transaction(self): transaction = self.client.new_transaction() transaction.begin() self.assertIsNotNone(transaction.id) self.assertEqual(transaction.state, hazelcast.transaction._STATE_ACTIVE) transaction.commit() self.assertEqual(transaction.state, hazelcast.transaction._STATE_COMMITTED)
def test_commit_transaction_twice(self): transaction = self.client.new_transaction() transaction.begin() transaction.commit() with self.assertRaises(TransactionError): transaction.commit()
def test_commit_inactive_transaction(self): transaction = self.client.new_transaction() with self.assertRaises(TransactionError): transaction.commit()
def test_timeout(self): transaction = self.client.new_transaction(timeout=0.001) transaction.begin() time.sleep(0.1) with self.assertRaises(TransactionError): transaction.commit()