def testLock(self): txn = Transaction(self.getClientUUID(), self.getNextTID()) self.assertFalse(txn.isLocked()) txn.lock() self.assertTrue(txn.isLocked()) # disallow lock more than once self.assertRaises(AssertionError, txn.lock)
def test_getObject(self): oid_1 = self.getOID(1) oid_2 = self.getOID(2) txn = Transaction(self.getClientUUID(), self.getNextTID()) object_info = oid_1, None, None txn.addObject(*object_info) self.assertRaises(KeyError, txn.getObject, oid_2) self.assertEqual(txn.getObject(oid_1), object_info)
def testInit(self): uuid = self.getClientUUID() ttid = self.getNextTID() tid = self.getNextTID() txn = Transaction(uuid, ttid) self.assertEqual(txn.getUUID(), uuid) self.assertEqual(txn.getTTID(), ttid) self.assertEqual(txn.getTID(), None) txn.setTID(tid) self.assertEqual(txn.getTID(), tid) self.assertEqual(txn.getObjectList(), []) self.assertEqual(txn.getOIDList(), [])
def testObjects(self): txn = Transaction(self.getClientUUID(), self.getNextTID()) oid1, oid2 = self.getOID(1), self.getOID(2) object1 = oid1, "0" * 20, None object2 = oid2, "1" * 20, None self.assertEqual(txn.getObjectList(), []) self.assertEqual(txn.getOIDList(), []) txn.addObject(*object1) self.assertEqual(txn.getObjectList(), [object1]) self.assertEqual(txn.getOIDList(), [oid1]) txn.addObject(*object2) self.assertEqual(txn.getObjectList(), [object1, object2]) self.assertEqual(txn.getOIDList(), [oid1, oid2])