Commit c5eb6391 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Rewrite of database manager tests.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1996 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent f4cb2c1e
...@@ -34,6 +34,7 @@ class StorageMySQSLdbTests(NeoTestBase): ...@@ -34,6 +34,7 @@ class StorageMySQSLdbTests(NeoTestBase):
# db manager # db manager
database = '%s@%s' % (NEO_SQL_USER, NEO_SQL_DATABASE) database = '%s@%s' % (NEO_SQL_USER, NEO_SQL_DATABASE)
self.db = MySQLDatabaseManager(database) self.db = MySQLDatabaseManager(database)
self.db.setup()
def tearDown(self): def tearDown(self):
self.db.close() self.db.close()
...@@ -43,15 +44,7 @@ class StorageMySQSLdbTests(NeoTestBase): ...@@ -43,15 +44,7 @@ class StorageMySQSLdbTests(NeoTestBase):
call = self.db.conn.mockGetNamedCalls('query')[call] call = self.db.conn.mockGetNamedCalls('query')[call]
call.checkArgs('BEGIN') call.checkArgs('BEGIN')
def test_01_p64(self): def test_MySQLDatabaseManagerInit(self):
self.assertEquals(p64(0), '\0' * 8)
self.assertEquals(p64(1), '\0' * 7 +'\1')
def test_02_u64(self):
self.assertEquals(u64('\0' * 8), 0)
self.assertEquals(u64('\0' * 7 + '\n'), 10)
def test_03_MySQLDatabaseManagerInit(self):
db = MySQLDatabaseManager('%s@%s' % (NEO_SQL_USER, NEO_SQL_DATABASE)) db = MySQLDatabaseManager('%s@%s' % (NEO_SQL_USER, NEO_SQL_DATABASE))
# init # init
self.assertEquals(db.db, NEO_SQL_DATABASE) self.assertEquals(db.db, NEO_SQL_DATABASE)
...@@ -60,7 +53,7 @@ class StorageMySQSLdbTests(NeoTestBase): ...@@ -60,7 +53,7 @@ class StorageMySQSLdbTests(NeoTestBase):
self.assertTrue(isinstance(db.conn, MySQLdb.connection)) self.assertTrue(isinstance(db.conn, MySQLdb.connection))
self.assertEquals(db.isUnderTransaction(), False) self.assertEquals(db.isUnderTransaction(), False)
def test_05_begin(self): def test_begin(self):
# no current transaction # no current transaction
self.db.conn = Mock({ }) self.db.conn = Mock({ })
self.assertEquals(self.db.isUnderTransaction(), False) self.assertEquals(self.db.isUnderTransaction(), False)
...@@ -68,14 +61,14 @@ class StorageMySQSLdbTests(NeoTestBase): ...@@ -68,14 +61,14 @@ class StorageMySQSLdbTests(NeoTestBase):
self.checkCalledQuery(query='COMMIT') self.checkCalledQuery(query='COMMIT')
self.assertEquals(self.db.isUnderTransaction(), True) self.assertEquals(self.db.isUnderTransaction(), True)
def test_06_commit(self): def test_commit(self):
self.db.conn = Mock() self.db.conn = Mock()
self.db.begin() self.db.begin()
self.db.commit() self.db.commit()
self.assertEquals(len(self.db.conn.mockGetNamedCalls('commit')), 1) self.assertEquals(len(self.db.conn.mockGetNamedCalls('commit')), 1)
self.assertEquals(self.db.isUnderTransaction(), False) self.assertEquals(self.db.isUnderTransaction(), False)
def test_06_rollback(self): def test_rollback(self):
# rollback called and no current transaction # rollback called and no current transaction
self.db.conn = Mock({ }) self.db.conn = Mock({ })
self.db.under_transaction = True self.db.under_transaction = True
...@@ -83,7 +76,7 @@ class StorageMySQSLdbTests(NeoTestBase): ...@@ -83,7 +76,7 @@ class StorageMySQSLdbTests(NeoTestBase):
self.assertEquals(len(self.db.conn.mockGetNamedCalls('rollback')), 1) self.assertEquals(len(self.db.conn.mockGetNamedCalls('rollback')), 1)
self.assertEquals(self.db.isUnderTransaction(), False) self.assertEquals(self.db.isUnderTransaction(), False)
def test_07_query1(self): def test_query1(self):
# fake result object # fake result object
from array import array from array import array
result_object = Mock({ result_object = Mock({
...@@ -101,7 +94,7 @@ class StorageMySQSLdbTests(NeoTestBase): ...@@ -101,7 +94,7 @@ class StorageMySQSLdbTests(NeoTestBase):
self.assertEquals(len(calls), 1) self.assertEquals(len(calls), 1)
calls[0].checkArgs('QUERY') calls[0].checkArgs('QUERY')
def test_07_query2(self): def test_query2(self):
# test the OperationalError exception # test the OperationalError exception
# fake object, raise exception during the first call # fake object, raise exception during the first call
from MySQLdb import OperationalError from MySQLdb import OperationalError
...@@ -121,7 +114,7 @@ class StorageMySQSLdbTests(NeoTestBase): ...@@ -121,7 +114,7 @@ class StorageMySQSLdbTests(NeoTestBase):
self.db.query('QUERY') self.db.query('QUERY')
self.assertTrue(self.connect_called) self.assertTrue(self.connect_called)
def test_07_query3(self): def test_query3(self):
# OperationalError > raise DatabaseFailure exception # OperationalError > raise DatabaseFailure exception
from MySQLdb import OperationalError from MySQLdb import OperationalError
class FakeConn(object): class FakeConn(object):
...@@ -132,11 +125,11 @@ class StorageMySQSLdbTests(NeoTestBase): ...@@ -132,11 +125,11 @@ class StorageMySQSLdbTests(NeoTestBase):
self.db.conn = FakeConn() self.db.conn = FakeConn()
self.assertRaises(DatabaseFailure, self.db.query, 'QUERY') self.assertRaises(DatabaseFailure, self.db.query, 'QUERY')
def test_08_escape(self): def test_escape(self):
self.assertEquals(self.db.escape('a"b'), 'a\\"b') self.assertEquals(self.db.escape('a"b'), 'a\\"b')
self.assertEquals(self.db.escape("a'b"), "a\\'b") self.assertEquals(self.db.escape("a'b"), "a\\'b")
def test_09_setup(self): def test_setup(self):
# create all tables # create all tables
self.db.conn = Mock() self.db.conn = Mock()
self.db.setup() self.db.setup()
...@@ -148,49 +141,29 @@ class StorageMySQSLdbTests(NeoTestBase): ...@@ -148,49 +141,29 @@ class StorageMySQSLdbTests(NeoTestBase):
calls = self.db.conn.mockGetNamedCalls('query') calls = self.db.conn.mockGetNamedCalls('query')
self.assertEquals(len(calls), 7) self.assertEquals(len(calls), 7)
def test_10_getConfiguration(self): def test_configuration(self):
# check if a configuration entry is well read
self.db.setup()
# doesn't exists, raise
self.assertRaises(KeyError, self.db.getConfiguration, 'a')
self.db.query("insert into config values ('a', 'b');")
result = self.db.getConfiguration('a')
# exists, check result
self.assertEquals(result, 'b')
def test_11_setConfiguration(self):
# check if a configuration entry is well written # check if a configuration entry is well written
self.db.setup()
self.db.setConfiguration('a', 'c') self.db.setConfiguration('a', 'c')
result = self.db.getConfiguration('a') result = self.db.getConfiguration('a')
self.assertEquals(result, 'c') self.assertEquals(result, 'c')
def checkConfigEntry(self, get_call, set_call, value): def checkConfigEntry(self, get_call, set_call, value):
# generic test for all configuration entries accessors # generic test for all configuration entries accessors
self.db.setup()
self.assertRaises(KeyError, get_call) self.assertRaises(KeyError, get_call)
set_call(value) set_call(value)
self.assertEquals(get_call(), value) self.assertEquals(get_call(), value)
set_call(value * 2) set_call(value * 2)
self.assertEquals(get_call(), value * 2) self.assertEquals(get_call(), value * 2)
def test_12_UUID(self): def test_UUID(self):
self.checkConfigEntry( self.checkConfigEntry(self.db.getUUID, self.db.setUUID, 'TEST_VALUE')
get_call=self.db.getUUID,
set_call=self.db.setUUID,
value='TEST_VALUE')
def test_13_NumPartitions(self): def test_NumPartitions(self):
self.checkConfigEntry( self.checkConfigEntry(self.db.getNumPartitions,
get_call=self.db.getNumPartitions, self.db.setNumPartitions, 10)
set_call=self.db.setNumPartitions,
value=10)
def test_14_Name(self): def test_Name(self):
self.checkConfigEntry( self.checkConfigEntry(self.db.getName, self.db.setName, 'TEST_NAME')
get_call=self.db.getName,
set_call=self.db.setName,
value='TEST_NAME')
def test_15_PTID(self): def test_15_PTID(self):
self.checkConfigEntry( self.checkConfigEntry(
...@@ -198,479 +171,401 @@ class StorageMySQSLdbTests(NeoTestBase): ...@@ -198,479 +171,401 @@ class StorageMySQSLdbTests(NeoTestBase):
set_call=self.db.setPTID, set_call=self.db.setPTID,
value=self.getPTID(1)) value=self.getPTID(1))
def test_16_getPartitionTable(self): def test_getPartitionTable(self):
# insert an entry and check it ptid = self.getPTID(1)
self.db.setup() uuid1, uuid2 = self.getNewUUID(), self.getNewUUID()
rid, uuid, state = '\x00' * 8, '\x00' * 16, 0 cell1 = (0, uuid1, CellStates.OUT_OF_DATE)
self.db.query("insert into pt (rid, uuid, state) values ('%s', '%s', %d)" % cell2 = (1, uuid1, CellStates.UP_TO_DATE)
(dump(rid), dump(uuid), state)) self.db.setPartitionTable(ptid, [cell1, cell2])
pt = self.db.getPartitionTable() result = self.db.getPartitionTable()
self.assertEquals(pt, [(0L, uuid, state)]) self.assertEqual(result, [cell1, cell2])
def test_17_getLastOID(self):
self.db.setup()
an_oid = '\x01' * 8
self.db.setLastOID(an_oid)
result = self.db.getLastOID()
self.assertEquals(result, an_oid)
def test_18_getLastTID(self): def test_getLastOID(self):
oid1 = self.getOID(1)
self.db.setLastOID(oid1)
result1 = self.db.getLastOID()
self.assertEquals(result1, oid1)
def getOIDs(self, count):
return [self.getOID(i) for i in xrange(count)]
def getTIDs(self, count):
tid_list = [self.getNextTID()]
while len(tid_list) != count:
tid_list.append(self.getNextTID(tid_list[-1]))
return tid_list
def getTransaction(self, oid_list):
transaction = (oid_list, 'user', 'desc', 'ext', False)
object_list = [(oid, 1, 0, '', None) for oid in oid_list]
return (transaction, object_list)
def checkSet(self, list1, list2):
self.assertEqual(set(list1), set(list2))
def test_getLastTID(self):
tid1, tid2, tid3, tid4 = self.getTIDs(4)
oid1, oid2 = self.getOIDs(2)
txn, objs = self.getTransaction([oid1, oid2])
# max TID is in obj table # max TID is in obj table
self.db.setup() self.db.storeTransaction(tid1, objs, txn, False)
self.db.query("""insert into trans (tid, oids, user, self.db.storeTransaction(tid2, objs, txn, False)
description, ext) values (1, '', '', '', '')""") self.assertEqual(self.db.getLastTID(), tid2)
self.db.query("""insert into trans (tid, oids, user,
description, ext) values (2, '', '', '', '')""")
result = self.db.getLastTID()
self.assertEquals(result, '\x00' * 7 + '\x02')
# max tid is in ttrans table # max tid is in ttrans table
self.db.query("""insert into ttrans (tid, oids, user, self.db.storeTransaction(tid3, objs, txn)
description, ext) values (3, '', '', '', '')""")
result = self.db.getLastTID() result = self.db.getLastTID()
self.assertEquals(result, '\x00' * 7 + '\x03') self.assertEqual(self.db.getLastTID(), tid3)
# max tid is in tobj (serial) # max tid is in tobj (serial)
self.db.query("""insert into tobj (oid, serial, compression, self.db.storeTransaction(tid4, objs, None)
checksum, value) values (0, 4, 0, 0, '')""") self.assertEqual(self.db.getLastTID(), tid4)
result = self.db.getLastTID()
self.assertEquals(result, '\x00' * 7 + '\x04') def test_getUnfinishedTIDList(self):
tid1, tid2, tid3, tid4 = self.getTIDs(4)
def test_19_getUnfinishedTIDList(self): oid1, oid2 = self.getOIDs(2)
self.db.setup() txn, objs = self.getTransaction([oid1, oid2])
self.db.query("""insert into ttrans (tid, oids, user, # nothing pending
description, ext) values (3, '', '', '', '')""") self.db.storeTransaction(tid1, objs, txn, False)
self.db.query("""insert into tobj (oid, serial, compression, self.checkSet(self.db.getUnfinishedTIDList(), [])
checksum, value) values (0, 4, 0, 0, '')""") # one unfinished txn
result = self.db.getUnfinishedTIDList() self.db.storeTransaction(tid2, objs, txn)
expected = ['\x00' * 7 + '\x03', '\x00' * 7 + '\x04'] self.checkSet(self.db.getUnfinishedTIDList(), [tid2])
self.assertEquals(result, expected) # no changes
self.db.storeTransaction(tid3, objs, None, False)
def test_20_objectPresent(self): self.checkSet(self.db.getUnfinishedTIDList(), [tid2])
self.db.setup() # a second txn known by objs only
oid1, tid1 = '\x00' * 7 + '\x01', '\x00' * 7 + '\x01' self.db.storeTransaction(tid4, objs, None)
oid2, tid2 = '\x00' * 7 + '\x02', '\x00' * 7 + '\x02' self.checkSet(self.db.getUnfinishedTIDList(), [tid2, tid4])
# object not present
self.assertFalse(self.db.objectPresent(oid1, tid1, all=False)) def test_objectPresent(self):
self.assertFalse(self.db.objectPresent(oid1, tid1, all=True)) tid = self.getNextTID()
self.assertFalse(self.db.objectPresent(oid2, tid2, all=False)) oid = self.getOID(1)
self.assertFalse(self.db.objectPresent(oid2, tid2, all=True)) txn, objs = self.getTransaction([oid])
# object present in temp table # not present
self.db.query("""insert into tobj (oid, serial, compression, self.assertFalse(self.db.objectPresent(oid, tid, all=True))
checksum, value) values (%d, %d, 0, 0, '')""" % self.assertFalse(self.db.objectPresent(oid, tid, all=False))
(u64(oid1), u64(tid1))) # available in temp table
self.assertFalse(self.db.objectPresent(oid1, tid1, all=False)) self.db.storeTransaction(tid, objs, txn)
self.assertTrue(self.db.objectPresent(oid1, tid1, all=True)) self.assertTrue(self.db.objectPresent(oid, tid, all=True))
self.assertFalse(self.db.objectPresent(oid2, tid2, all=False)) self.assertFalse(self.db.objectPresent(oid, tid, all=False))
self.assertFalse(self.db.objectPresent(oid2, tid2, all=True)) # available in both tables
# object present in both table self.db.finishTransaction(tid)
self.db.query("""insert into obj (oid, serial, compression, self.assertTrue(self.db.objectPresent(oid, tid, all=True))
checksum, value) values ("%s", "%s", 0, 0, '')""" % self.assertTrue(self.db.objectPresent(oid, tid, all=False))
(u64(oid2), u64(tid2)))
self.assertFalse(self.db.objectPresent(oid1, tid1, all=False)) def test_getObject(self):
self.assertTrue(self.db.objectPresent(oid1, tid1, all=True)) oid1, oid2 = self.getOIDs(2)
self.assertTrue(self.db.objectPresent(oid2, tid2, all=False)) tid1, tid2 = self.getTIDs(2)
self.assertTrue(self.db.objectPresent(oid2, tid2, all=True)) txn1, objs1 = self.getTransaction([oid1])
txn2, objs2 = self.getTransaction([oid1])
def test_21_getObject(self): # non-present
self.db.setup() self.assertEqual(self.db.getObject(oid1, tid1), None)
oid1, tid1 = '\x00' * 7 + '\x01', '\x00' * 7 + '\x01' self.assertEqual(self.db.getObject(oid2, tid2), None)
oid2, tid2 = '\x00' * 7 + '\x02', '\x00' * 7 + '\x02' # one non-commited version
# tid specified and object not present self.db.storeTransaction(tid1, objs1, txn1)
self.assertEqual(self.db.getObject(oid1, tid1), None)
# one commited version
self.db.finishTransaction(tid1)
result = self.db.getObject(oid1, tid1) result = self.db.getObject(oid1, tid1)
self.assertEquals(result, None) self.assertEqual(result, (tid1, None, 1, 0, '', None))
# tid specified and object present self.assertEqual(self.db.getObject(oid1, before_tid=tid1), None)
self.db.query("""insert into obj (oid, serial, compression, # two version available, one non-commited
checksum, value) values (%d, %d, 0, 0, '')""" % self.db.storeTransaction(tid2, objs2, txn2)
(u64(oid1), u64(tid1)))
result = self.db.getObject(oid1, tid1) result = self.db.getObject(oid1, tid1)
self.assertEquals(result, (tid1, None, 0, 0, '', None)) self.assertEqual(result, (tid1, None, 1, 0, '', None))
# before_tid specified, object not present self.assertEqual(self.db.getObject(oid1, before_tid=tid1), None)
result = self.db.getObject(oid2, before_tid=tid2) # two commited versions
self.assertEquals(result, None) self.db.finishTransaction(tid2)
# before_tid specified, object present, no next serial result = self.db.getObject(oid1, tid1)
result = self.db.getObject(oid1, before_tid=tid2) self.assertEqual(result, (tid1, None, 1, 0, '', None))
self.assertEquals(result, (tid1, None, 0, 0, '', None)) result = self.db.getObject(oid1, tid2)
# before_tid specified, object present, next serial exists self.assertEqual(result, (tid2, None, 1, 0, '', None))
self.db.query("""insert into obj (oid, serial, compression,
checksum, value) values (%d, %d, 0, 0, '')""" %
(u64(oid1), u64(tid2)))
result = self.db.getObject(oid1, before_tid=tid2) result = self.db.getObject(oid1, before_tid=tid2)
self.assertEquals(result, (tid1, tid2, 0, 0, '', None)) self.assertEqual(result, (tid1, tid2, 1, 0, '', None))
# no tid specified, retreive last object transaction, object unknown # no tid specified, return the last version
result = self.db.getObject(oid2)
self.assertEquals(result, None)
# same but object found
result = self.db.getObject(oid1) result = self.db.getObject(oid1)
self.assertEquals(result, (tid2, None, 0, 0, '', None)) self.assertEqual(result, (tid2, None, 1, 0, '', None))
def test_23_changePartitionTable(self): def test_setPartitionTable(self):
# two sn, two partitions ptid = self.getPTID(1)
self.db.setup() uuid1, uuid2 = self.getNewUUID(), self.getNewUUID()
ptid = '1' cell1 = (0, uuid1, CellStates.OUT_OF_DATE)
uuid1, uuid2 = '\x00' * 15 + '\x01', '\x00' * 15 + '\x02' cell2 = (1, uuid1, CellStates.UP_TO_DATE)
cells = ( cell3 = (1, uuid1, CellStates.DISCARDED)
(0, uuid1, CellStates.DISCARDED), # no partition table
(1, uuid2, CellStates.UP_TO_DATE), self.assertEqual(self.db.getPartitionTable(), [])
) # set one
self.db.setPTID(INVALID_PTID) self.db.setPartitionTable(ptid, [cell1])
# empty table -> insert for second cell result = self.db.getPartitionTable()
self.db.changePartitionTable(ptid, cells) self.assertEqual(result, [cell1])
result = self.db.query('select rid, uuid, state from pt') # then another
self.assertEquals(len(result), 1) self.db.setPartitionTable(ptid, [cell2])
self.assertEquals(result[0], (1, dump(uuid2), 1)) result = self.db.getPartitionTable()
self.assertEquals(self.db.getPTID(), ptid) self.assertEqual(result, [cell2])
# delete previous entries for a CellStates.DISCARDEDnode # drop discarded cells
self.db.query("delete from pt") self.db.setPartitionTable(ptid, [cell2, cell3])
args = (0, dump(uuid1), CellStates.DISCARDED) result = self.db.getPartitionTable()
self.db.query('insert into pt (rid, uuid, state) values (%d, "%s", %d)' % args) self.assertEqual(result, [])
result = self.db.query('select rid, uuid, state from pt')
self.assertEquals(len(result), 1) def test_changePartitionTable(self):
self.assertEquals(result[0], (0, dump(uuid1), 4)) ptid = self.getPTID(1)
self.assertEquals(self.db.getPTID(), ptid) uuid1, uuid2 = self.getNewUUID(), self.getNewUUID()
self.db.changePartitionTable(ptid, cells) cell1 = (0, uuid1, CellStates.OUT_OF_DATE)
result = self.db.query('select rid, uuid, state from pt') cell2 = (1, uuid1, CellStates.UP_TO_DATE)
self.assertEquals(len(result), 1) cell3 = (1, uuid1, CellStates.DISCARDED)
self.assertEquals(result[0], (1, dump(uuid2), 1)) # no partition table
self.assertEquals(self.db.getPTID(), ptid) self.assertEqual(self.db.getPartitionTable(), [])
# raise exception (config not set), check rollback # set one
self.db.query("drop table config") # will generate the exception self.db.changePartitionTable(ptid, [cell1])
args = (0, uuid1, CellStates.DISCARDED) result = self.db.getPartitionTable()
self.db.query('insert into pt (rid, uuid, state) values (%d, "%s", %d)' % args) self.assertEqual(result, [cell1])
self.assertRaises(MySQLdb.ProgrammingError, # add more entries
self.db.changePartitionTable, ptid, cells) self.db.changePartitionTable(ptid, [cell2])
result = self.db.query('select count(*) from pt where rid=0') result = self.db.getPartitionTable()
self.assertEquals(len(result), 1) self.assertEqual(result, [cell1, cell2])
# drop discarded cells
def test_22_setGetPartitionTable(self): self.db.changePartitionTable(ptid, [cell2, cell3])
# two sn, two partitions result = self.db.getPartitionTable()
self.db.setup() self.assertEqual(result, [cell1])
ptid = '1'
uuid1, uuid2 = '\x00' * 15 + '\x01', '\x00' * 15 + '\x02' def test_dropUnfinishedData(self):
cells = ( oid1, oid2 = self.getOIDs(2)
(0, uuid1, CellStates.DISCARDED), tid1, tid2 = self.getTIDs(2)
(1, uuid2, CellStates.UP_TO_DATE), txn1, objs1 = self.getTransaction([oid1])
) txn2, objs2 = self.getTransaction([oid1])
self.db.setPTID(INVALID_PTID) # nothing
# not empty table, reset -> clean table first self.assertEqual(self.db.getObject(oid1), None)
args = (0, uuid2, CellStates.UP_TO_DATE) self.assertEqual(self.db.getObject(oid2), None)
self.db.query('insert into pt (rid, uuid, state) values (%d, "%s", %d)' % args) self.assertEqual(self.db.getUnfinishedTIDList(), [])
self.db.setPartitionTable(ptid, cells) # one is still pending
result = self.db.query('select rid, uuid, state from pt') self.db.storeTransaction(tid1, objs1, txn1)
self.assertEquals(len(result), 1) self.db.storeTransaction(tid2, objs2, txn2)
self.assertEquals(result[0], (1, dump(uuid2), 1)) self.db.finishTransaction(tid1)
self.assertEquals(self.db.getPTID(), ptid) result = self.db.getObject(oid1)
# delete previous entries for a CellStates.DISCARDEDnode self.assertEqual(result, (tid1, None, 1, 0, '', None))
self.db.query("delete from pt") self.assertEqual(self.db.getObject(oid2), None)
args = (0, uuid1, CellStates.DISCARDED) self.assertEqual(self.db.getUnfinishedTIDList(), [tid2])
self.db.query('insert into pt (rid, uuid, state) values (%d, "%s", %d)' % args) # drop it
result = self.db.query('select rid, uuid, state from pt')
self.assertEquals(len(result), 1)
self.assertEquals(result[0], (0, uuid1, 4))
self.assertEquals(self.db.getPTID(), ptid)
self.db.setPartitionTable(ptid, cells)
result = self.db.query('select rid, uuid, state from pt')
self.assertEquals(len(result), 1)
self.assertEquals(result[0], (1, dump(uuid2), 1))
self.assertEquals(self.db.getPTID(), ptid)
# raise exception (config not set), check rollback
self.db.query("drop table config") # will generate the exception
args = (0, uuid1, CellStates.DISCARDED)
self.db.query('insert into pt (rid, uuid, state) values (%d, "%s", %d)' % args)
self.assertRaises(MySQLdb.ProgrammingError,
self.db.setPartitionTable, ptid, cells)
result = self.db.query('select count(*) from pt where rid=0')
self.assertEquals(len(result), 1)
def test_23_dropUnfinishedData(self):
# delete entries from tobj and ttrans
self.db.setup()
self.db.query("""insert into tobj (oid, serial, compression,
checksum, value) values (0, 4, 0, 0, '')""")
self.db.query("""insert into ttrans (tid, oids, user,
description, ext) values (3, '', '', '', '')""")
self.db.dropUnfinishedData() self.db.dropUnfinishedData()
result = self.db.query('select * from tobj') self.assertEqual(self.db.getUnfinishedTIDList(), [])
self.assertEquals(result, ()) result = self.db.getObject(oid1)
result = self.db.query('select * from ttrans') self.assertEqual(result, (tid1, None, 1, 0, '', None))
self.assertEquals(result, ()) self.assertEqual(self.db.getObject(oid2), None)
def test_24_storeTransaction1(self): def test_storeTransaction(self):
# data set oid1, oid2 = self.getOIDs(2)
tid = '\x00' * 7 + '\x01' tid1, tid2 = self.getTIDs(2)
oid1, oid2 = '\x00' * 7 + '\x01', '\x00' * 7 + '\x02' txn1, objs1 = self.getTransaction([oid1])
object_list = ( (oid1, 0, 0, '', None), (oid2, 0, 0, '', None),) txn2, objs2 = self.getTransaction([oid2])
transaction = ((oid1, oid2), 'user', 'desc', 'ext', False) # nothing in database
# store objects in temporary table self.assertEqual(self.db.getLastTID(), None)
self.db.setup() self.assertEqual(self.db.getUnfinishedTIDList(), [])
self.db.storeTransaction(tid, object_list, transaction=None, temporary=True) self.assertEqual(self.db.getObject(oid1), None)
result = self.db.query('select oid, serial, compression, checksum, value from tobj') self.assertEqual(self.db.getObject(oid2), None)
self.assertEquals(len(result), 2) self.assertEqual(self.db.getTransaction(tid1, True), None)
self.assertEquals(result[0], (1L, 1, 0, 0, '')) self.assertEqual(self.db.getTransaction(tid2, True), None)
self.assertEquals(result[1], (2L, 1, 0, 0, '')) self.assertEqual(self.db.getTransaction(tid1, False), None)
result = self.db.query('select * from obj') self.assertEqual(self.db.getTransaction(tid2, False), None)
self.assertEquals(len(result), 0) # store in temporary tables
# and in obj table self.db.storeTransaction(tid1, objs1, txn1)
self.db.setup(reset=True) self.db.storeTransaction(tid2, objs2, txn2)
self.db.storeTransaction(tid, object_list, transaction=None, temporary=False) result = self.db.getTransaction(tid1, True)
result = self.db.query('select oid, serial, compression, checksum, value from obj') self.assertEqual(result, ([oid1], 'user', 'desc', 'ext', False))
self.assertEquals(len(result), 2) result = self.db.getTransaction(tid2, True)
self.assertEquals(result[0], (1L, 1, 0, 0, '')) self.assertEqual(result, ([oid2], 'user', 'desc', 'ext', False))
self.assertEquals(result[1], (2L, 1, 0, 0, '')) self.assertEqual(self.db.getTransaction(tid1, False), None)
result = self.db.query('select * from tobj') self.assertEqual(self.db.getTransaction(tid2, False), None)
self.assertEquals(len(result), 0) # commit pending transaction
# store transaction in temporary table
self.db.setup(reset=True)
self.db.storeTransaction(tid, (), transaction=transaction, temporary=True)
result = self.db.query('select tid, oids, user, description, ext from ttrans')
self.assertEquals(len(result), 1)
self.assertEquals(result[0], (1L, oid1 + oid2, 'user', 'desc', 'ext',) )
result = self.db.query('select * from trans')
self.assertEquals(len(result), 0)
# and in trans table
self.db.setup(reset=True)
self.db.storeTransaction(tid, (), transaction=transaction, temporary=False)
result = self.db.query('select tid, oids, user, description, ext from trans')
self.assertEquals(len(result), 1)
self.assertEquals(result[0], (1L, oid1 + oid2, 'user', 'desc', 'ext',))
result = self.db.query('select * from ttrans')
self.assertEquals(len(result), 0)
def test_25_askFinishTransaction(self):
# data set
tid1, tid2 = '\x00' * 7 + '\x01', '\x00' * 7 + '\x02'
oid1, oid2 = '\x00' * 7 + '\x01', '\x00' * 7 + '\x02'
object_list = ( (oid1, 0, 0, '', None), (oid2, 0, 0, '', None),)
transaction = ((oid1, oid2), 'u', 'd', 'e', False)
self.db.setup(reset=True)
# store two temporary transactions
self.db.storeTransaction(tid1, object_list, transaction, temporary=True)
self.db.storeTransaction(tid2, object_list, transaction, temporary=True)
result = self.db.query('select count(*) from tobj')
self.assertEquals(result[0][0], 4)
result = self.db.query('select count(*) from ttrans')
self.assertEquals(result[0][0], 2)
# finish t1
self.db.finishTransaction(tid1) self.db.finishTransaction(tid1)
# t1 should be finished self.db.finishTransaction(tid2)
result = self.db.query('select * from obj order by oid asc') result = self.db.getTransaction(tid1, True)
self.assertEquals(len(result), 2) self.assertEqual(result, ([oid1], 'user', 'desc', 'ext', False))
self.assertEquals(result[0], (1L, 1L, 0, 0, '', None)) result = self.db.getTransaction(tid2, True)
self.assertEquals(result[1], (2L, 1L, 0, 0, '', None)) self.assertEqual(result, ([oid2], 'user', 'desc', 'ext', False))
result = self.db.query('select * from trans') result = self.db.getTransaction(tid1, False)
self.assertEquals(len(result), 1) self.assertEqual(result, ([oid1], 'user', 'desc', 'ext', False))
self.assertEquals(result[0], (1L, 0, oid1 + oid2, 'u', 'd', 'e',)) result = self.db.getTransaction(tid2, False)
# t2 should stay in temporary tables self.assertEqual(result, ([oid2], 'user', 'desc', 'ext', False))
result = self.db.query('select * from tobj order by oid asc')
self.assertEquals(len(result), 2) def test_askFinishTransaction(self):
self.assertEquals(result[0], (1L, 2L, 0, 0, '', None)) oid1, oid2 = self.getOIDs(2)
self.assertEquals(result[1], (2L, 2L, 0, 0, '', None)) tid1, tid2 = self.getTIDs(2)
result = self.db.query('select * from ttrans') txn1, objs1 = self.getTransaction([oid1])
self.assertEquals(len(result), 1) txn2, objs2 = self.getTransaction([oid2])
self.assertEquals(result[0], (2L, 0, oid1 + oid2, 'u', 'd', 'e',)) # stored but not finished
self.db.storeTransaction(tid1, objs1, txn1)
def test_26_deleteTransaction(self): self.db.storeTransaction(tid2, objs2, txn2)
# data set result = self.db.getTransaction(tid1, True)
tid1, tid2 = '\x00' * 7 + '\x01', '\x00' * 7 + '\x02' self.assertEqual(result, ([oid1], 'user', 'desc', 'ext', False))
oid1, oid2 = '\x00' * 7 + '\x01', '\x00' * 7 + '\x02' result = self.db.getTransaction(tid2, True)
object_list = ( (oid1, 0, 0, '', None), (oid2, 0, 0, '', None),) self.assertEqual(result, ([oid2], 'user', 'desc', 'ext', False))
transaction = ((oid1, oid2), 'u', 'd', 'e', False) self.assertEqual(self.db.getTransaction(tid1, False), None)
self.db.setup(reset=True) self.assertEqual(self.db.getTransaction(tid2, False), None)
# store two transactions in both state # stored and finished
self.db.storeTransaction(tid1, object_list, transaction, temporary=True) self.db.finishTransaction(tid1)
self.db.storeTransaction(tid2, object_list, transaction, temporary=True) self.db.finishTransaction(tid2)
self.db.storeTransaction(tid1, object_list, transaction, temporary=False) result = self.db.getTransaction(tid1, True)
self.db.storeTransaction(tid2, object_list, transaction, temporary=False) self.assertEqual(result, ([oid1], 'user', 'desc', 'ext', False))
result = self.db.query('select count(*) from tobj') result = self.db.getTransaction(tid2, True)
self.assertEquals(result[0][0], 4) self.assertEqual(result, ([oid2], 'user', 'desc', 'ext', False))
result = self.db.query('select count(*) from ttrans') result = self.db.getTransaction(tid1, False)
self.assertEquals(result[0][0], 2) self.assertEqual(result, ([oid1], 'user', 'desc', 'ext', False))
result = self.db.query('select count(*) from obj') result = self.db.getTransaction(tid2, False)
self.assertEquals(result[0][0], 4) self.assertEqual(result, ([oid2], 'user', 'desc', 'ext', False))
result = self.db.query('select count(*) from trans')
self.assertEquals(result[0][0], 2) def test_deleteTransaction(self):
# delete t1 (all) oid1, oid2 = self.getOIDs(2)
self.db.deleteTransaction(tid1, all=True) tid1, tid2 = self.getTIDs(2)
# t2 not altered txn1, objs1 = self.getTransaction([oid1])
result = self.db.query('select * from tobj order by oid asc') txn2, objs2 = self.getTransaction([oid2])
self.assertEquals(len(result), 2) # delete only from temporary tables
self.assertEquals(result[0], (1L, 2L, 0, 0, '', None)) self.db.storeTransaction(tid1, objs1, txn1)
self.assertEquals(result[1], (2L, 2L, 0, 0, '', None)) self.db.storeTransaction(tid2, objs2, txn2)
result = self.db.query('select * from ttrans') self.db.finishTransaction(tid1)
self.assertEquals(len(result), 1) self.db.deleteTransaction(tid1)
self.assertEquals(result[0], (2L, 0, oid1 + oid2, 'u', 'd', 'e',)) self.db.deleteTransaction(tid2)
result = self.db.query('select * from obj order by oid asc') result = self.db.getTransaction(tid1, True)
self.assertEquals(len(result), 2) self.assertEqual(result, ([oid1], 'user', 'desc', 'ext', False))
self.assertEquals(result[0], (1L, 2L, 0, 0, '', None)) self.assertEqual(self.db.getTransaction(tid2, True), None)
self.assertEquals(result[1], (2L, 2L, 0, 0, '', None)) # delete from all
result = self.db.query('select * from trans') self.db.deleteTransaction(tid1, True)
self.assertEquals(len(result), 1) self.assertEqual(self.db.getTransaction(tid1, True), None)
self.assertEquals(result[0], (2L, 0, oid1 + oid2, 'u', 'd', 'e',)) self.assertEqual(self.db.getTransaction(tid2, True), None)
# store t1 again
self.db.storeTransaction(tid1, object_list, transaction, temporary=True) def test_getTransaction(self):
self.db.storeTransaction(tid1, object_list, transaction, temporary=False) oid1, oid2 = self.getOIDs(2)
# and remove it but only from temporary tables tid1, tid2 = self.getTIDs(2)
self.db.deleteTransaction(tid1, all=False) txn1, objs1 = self.getTransaction([oid1])
# t2 not altered and t1 stay in obj/trans tables txn2, objs2 = self.getTransaction([oid2])
result = self.db.query('select * from tobj order by oid asc') # get from temporary table or not
self.assertEquals(len(result), 2) self.db.storeTransaction(tid1, objs1, txn1)
self.assertEquals(result[0], (1L, 2L, 0, 0, '', None)) self.db.storeTransaction(tid2, objs2, txn2)
self.assertEquals(result[1], (2L, 2L, 0, 0, '', None)) self.db.finishTransaction(tid1)
result = self.db.query('select * from ttrans') result = self.db.getTransaction(tid1, True)
self.assertEquals(len(result), 1) self.assertEqual(result, ([oid1], 'user', 'desc', 'ext', False))
self.assertEquals(result[0], (2L, 0, oid1 + oid2, 'u', 'd', 'e',)) result = self.db.getTransaction(tid2, True)
result = self.db.query('select * from obj order by oid, serial asc') self.assertEqual(result, ([oid2], 'user', 'desc', 'ext', False))
self.assertEquals(len(result), 4) # get from non-temporary only
self.assertEquals(result[0], (1L, 1L, 0, 0, '', None)) result = self.db.getTransaction(tid1, False)
self.assertEquals(result[1], (1L, 2L, 0, 0, '', None)) self.assertEqual(result, ([oid1], 'user', 'desc', 'ext', False))
self.assertEquals(result[2], (2L, 1L, 0, 0, '', None)) self.assertEqual(self.db.getTransaction(tid2, False), None)
self.assertEquals(result[3], (2L, 2L, 0, 0, '', None))
result = self.db.query('select * from trans order by tid asc') def test_getOIDList(self):
self.assertEquals(len(result), 2) # store four objects
self.assertEquals(result[0], (1L, 0, oid1 + oid2, 'u', 'd', 'e',)) oid1, oid2, oid3, oid4 = self.getOIDs(4)
self.assertEquals(result[1], (2L, 0, oid1 + oid2, 'u', 'd', 'e',)) tid = self.getNextTID()
txn, objs = self.getTransaction([oid1, oid2, oid3, oid4])
def test_27_getTransaction(self): self.db.storeTransaction(tid, objs, txn)
# data set self.db.finishTransaction(tid)
tid1, tid2 = '\x00' * 7 + '\x01', '\x00' * 7 + '\x02' # get oids
oid1, oid2 = '\x00' * 7 + '\x01', '\x00' * 7 + '\x02' result = self.db.getOIDList(0, 4, 1, [0])
oids = [oid1, oid2] self.checkSet(result, [oid1, oid2, oid3, oid4])
transaction = ((oid1, oid2), 'u', 'd', 'e', False) result = self.db.getOIDList(0, 4, 2, [0])
self.db.setup(reset=True) self.checkSet(result, [oid1, oid3])
# store t1 in temporary and t2 in persistent tables result = self.db.getOIDList(0, 4, 2, [0, 1])
self.db.storeTransaction(tid1, (), transaction, temporary=True) self.checkSet(result, [oid1, oid2, oid3, oid4])
self.db.storeTransaction(tid2, (), transaction, temporary=False) result = self.db.getOIDList(0, 4, 3, [0])
# get t1 from all -> OK self.checkSet(result, [oid1, oid4])
t = self.db.getTransaction(tid1, all=True) # get a subset of oids
self.assertEquals(t, (oids, 'u', 'd', 'e', False)) result = self.db.getOIDList(2, 4, 1, [0])
# get t1 from no tmp only -> fail self.checkSet(result, [oid1, oid2])
t = self.db.getTransaction(tid1, all=False) result = self.db.getOIDList(0, 2, 1, [0])
self.assertEquals(t, None) self.checkSet(result, [oid3, oid4])
# get t2 from all or not -> always OK result = self.db.getOIDList(0, 1, 3, [0])
t = self.db.getTransaction(tid2, all=True) self.checkSet(result, [oid4])
self.assertEquals(t, (oids, 'u', 'd', 'e', False))
t = self.db.getTransaction(tid2, all=False) def test_getObjectHistory(self):
self.assertEquals(t, (oids, 'u', 'd', 'e', False)) oid = self.getOID(1)
# store wrong oids -> DatabaseFailure tid1, tid2, tid3 = self.getTIDs(3)
self.db.setup(reset=True) txn1, objs1 = self.getTransaction([oid])
self.db.query("""replace into trans (tid, oids, user, description, ext) txn2, objs2 = self.getTransaction([oid])
values ('%s', '%s', 'u', 'd', 'e')""" % (u64(tid1), 'OIDs_')) txn3, objs3 = self.getTransaction([oid])
self.assertRaises(DatabaseFailure, self.db.getTransaction, tid1) # one revision
self.db.storeTransaction(tid1, objs1, txn1)
def test_28_getOIDList(self): self.db.finishTransaction(tid1)
# there are two partitions and two objects in each of them result = self.db.getObjectHistory(oid, 0, 3)
# o1 & o3 in p1, o2 & o4 in p2 self.assertEqual(result, [(tid1, 0)])
self.db.setup(reset=True) result = self.db.getObjectHistory(oid, 1, 1)
tid = '\x00' * 7 + '\x01' self.assertEqual(result, None)
oid1, oid2, oid3, oid4 = ['\x00' * 7 + chr(i) for i in xrange(4)] # two revisions
for oid in (oid1, oid2, oid3, oid4): self.db.storeTransaction(tid2, objs2, txn2)
self.db.query("replace into obj values (%d, %d, 0, 0, '', NULL)" % self.db.finishTransaction(tid2)
(u64(oid), u64(tid))) result = self.db.getObjectHistory(oid, 0, 3)
# get all oids for all partitions self.assertEqual(result, [(tid2, 0), (tid1, 0)])
result = self.db.getOIDList(0, 4, 2, (0, 1)) result = self.db.getObjectHistory(oid, 1, 3)
self.assertEquals(result, [oid4, oid3, oid2, oid1]) self.assertEqual(result, [(tid1, 0)])
# get all oids but from the second with a limit a two result = self.db.getObjectHistory(oid, 2, 3)
result = self.db.getOIDList(1, 2, 2, (0, 1)) self.assertEqual(result, None)
self.assertEquals(result, [oid3, oid2])
# get all oids for the first partition def test_getTIDList(self):
result = self.db.getOIDList(0, 2, 2, (0, )) # use OID generator to know result of tid % N
self.assertEquals(result, [oid3, oid1]) tid1, tid2, tid3, tid4 = self.getOIDs(4)
# get all oids for the second partition with a limit of one oid = self.getOID(1)
result = self.db.getOIDList(0, 1, 2, (1, )) txn1, objs1 = self.getTransaction([oid])
self.assertEquals(result, [oid4]) txn2, objs2 = self.getTransaction([oid])
# get all oids for the second partition with an offset of 3 > nothing txn3, objs3 = self.getTransaction([oid])
result = self.db.getOIDList(3, 2, 2, (1, )) txn4, objs4 = self.getTransaction([oid])
self.assertEquals(result, []) # store four transaction
# get oids for an inexsitant partition -> nothing self.db.storeTransaction(tid1, objs1, txn1)
result = self.db.getOIDList(0, 2, 2, (3, )) self.db.storeTransaction(tid2, objs2, txn2)
self.assertEquals(result, []) self.db.storeTransaction(tid3, objs3, txn3)
self.db.storeTransaction(tid4, objs4, txn4)
def test_29_getObjectHistory(self): self.db.finishTransaction(tid1)
# there is one object with 4 revisions self.db.finishTransaction(tid2)
self.db.setup(reset=True) self.db.finishTransaction(tid3)
tids = ['\x00' * 7 + chr(i) for i in xrange(4)] self.db.finishTransaction(tid4)
oid = '\x00' * 8 # get tids
for tid in tids: result = self.db.getTIDList(0, 4, 1, [0])
self.db.query("replace into obj values (%d, %d, 0, 0, '', NULL)" % self.checkSet(result, [tid1, tid2, tid3, tid4])
(u64(oid), u64(tid))) result = self.db.getTIDList(0, 4, 2, [0])
# unkwown object self.checkSet(result, [tid1, tid3])
result = self.db.getObjectHistory(oid='\x01' * 8) result = self.db.getTIDList(0, 4, 2, [0, 1])
self.assertEquals(result, None) self.checkSet(result, [tid1, tid2, tid3, tid4])
# retreive all revisions result = self.db.getTIDList(0, 4, 3, [0])
result = self.db.getObjectHistory(oid=oid, offset=0, length=4) self.checkSet(result, [tid1, tid4])
expected = [(tid, 0) for tid in reversed(tids)] # get a subset of tids
self.assertEquals(result, expected) result = self.db.getTIDList(2, 4, 1, [0])
# get from the second, limit to 2 revisions self.checkSet(result, [tid1, tid2])
result = self.db.getObjectHistory(oid=oid, offset=1, length=2) result = self.db.getTIDList(0, 2, 1, [0])
expected = [(tids[2], 0), (tids[1], 0)] self.checkSet(result, [tid3, tid4])
self.assertEquals(result, expected) result = self.db.getTIDList(0, 1, 3, [0])
# get from the fifth -> nothing self.checkSet(result, [tid4])
result = self.db.getObjectHistory(oid=oid, offset=4, length=2)
self.assertEquals(result, None) def test_getTIDListPresent(self):
oid = self.getOID(1)
def test_28_getTIDList(self): tid1, tid2, tid3, tid4 = self.getTIDs(4)
# same as for getOIDList, 2 partitions and 4 transactions txn1, objs1 = self.getTransaction([oid])
self.db.setup(reset=True) txn4, objs4 = self.getTransaction([oid])
tids = ['\x00' * 7 + chr(i) for i in xrange(4)] # four tids, two missing
tid1, tid2, tid3, tid4 = tids self.db.storeTransaction(tid1, objs1, txn1)
for tid in tids: self.db.finishTransaction(tid1)
self.db.query("""replace into trans values (%d, '', 'u', 'd', 'e', self.db.storeTransaction(tid4, objs4, txn4)
False)""" % (u64(tid))) self.db.finishTransaction(tid4)
# get all tids for all partitions result = self.db.getTIDListPresent([tid1, tid2, tid3, tid4])
result = self.db.getTIDList(0, 4, 2, (0, 1)) self.checkSet(result, [tid1, tid4])
self.assertEquals(result, [tid4, tid3, tid2, tid1]) result = self.db.getTIDListPresent([tid1, tid2])
# get all tids but from the second with a limit a two self.checkSet(result, [tid1])
result = self.db.getTIDList(1, 2, 2, (0, 1)) self.assertEqual(self.db.getTIDListPresent([tid2, tid3]), [])
self.assertEquals(result, [tid3, tid2])
# get all tids for the first partition def test_getSerialListPresent(self):
result = self.db.getTIDList(0, 2, 2, (0, )) oid1, oid2 = self.getOIDs(2)
self.assertEquals(result, [tid3, tid1]) tid1, tid2, tid3, tid4 = self.getTIDs(4)
# get all tids for the second partition with a limit of one txn1, objs1 = self.getTransaction([oid1])
result = self.db.getTIDList(0, 1, 2, (1, )) txn2, objs2 = self.getTransaction([oid1])
self.assertEquals(result, [tid4]) txn3, objs3 = self.getTransaction([oid2])
# get all tids for the second partition with an offset of 3 > nothing txn4, objs4 = self.getTransaction([oid2])
result = self.db.getTIDList(3, 2, 2, (1, )) # four object, one revision each
self.assertEquals(result, []) self.db.storeTransaction(tid1, objs1, txn1)
# get tids for an inexsitant partition -> nothing self.db.finishTransaction(tid1)
result = self.db.getTIDList(0, 2, 2, (3, )) self.db.storeTransaction(tid4, objs4, txn4)
self.assertEquals(result, []) self.db.finishTransaction(tid4)
result = self.db.getSerialListPresent(oid1, [tid1, tid2])
def test_29_getTIDListPresent(self): self.checkSet(result, [tid1])
# 4 sample transactions result = self.db.getSerialListPresent(oid2, [tid3, tid4])
self.db.setup(reset=True) self.checkSet(result, [tid4])
tid = '\x00' * 7 + '\x01' result = self.db.getSerialListPresent(oid1, [tid2])
tid1, tid2, tid3, tid4 = ['\x00' * 7 + chr(i) for i in xrange(4)] self.assertEqual(result, [])
for tid in (tid1, tid2, tid3, tid4): result = self.db.getSerialListPresent(oid2, [tid3])
self.db.query("""replace into trans values (%d, '', 'u', 'd', 'e', self.assertEqual(result, [])
False)""" % (u64(tid)))
# all match
result = self.db.getTIDListPresent((tid1, tid2, tid3, tid4))
expected = [tid1, tid2, tid3, tid4]
self.assertEquals(sorted(result), expected)
# none match
result = self.db.getTIDListPresent(('\x01' * 8, '\x02' * 8))
self.assertEquals(result, [])
# some match
result = self.db.getTIDListPresent((tid1, tid3))
self.assertEquals(sorted(result), [tid1, tid3])
def test_30_getSerialListPresent(self):
# 4 sample objects
self.db.setup(reset=True)
tids = ['\x00' * 7 + chr(i) for i in xrange(4)]
tid1, tid2, tid3, tid4 = tids
oid = '\x00' * 8
for tid in tids:
self.db.query("replace into obj values (%d, %d, 0, 0, '', NULL)" \
% (u64(oid), u64(tid)))
# all match
result = self.db.getSerialListPresent(oid, tids)
expected = list(tids)
self.assertEquals(sorted(result), expected)
# none match
result = self.db.getSerialListPresent(oid, ('\x01' * 8, '\x02' * 8))
self.assertEquals(result, [])
# some match
result = self.db.getSerialListPresent(oid, (tid1, tid3))
self.assertEquals(sorted(result), [tid1, tid3])
def test__getObjectData(self): def test__getObjectData(self):
db = self.db db = self.db
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment