Commit 1f74a566 authored by Jim Fulton's avatar Jim Fulton

Change the undo tests to use the normal undo framework to avoid

spurious failures.
parent 76b0cc57
...@@ -104,16 +104,9 @@ class BlobUndoTests(unittest.TestCase): ...@@ -104,16 +104,9 @@ class BlobUndoTests(unittest.TestCase):
root['blob'] = Blob() root['blob'] = Blob()
transaction.commit() transaction.commit()
serial = base64.encodestring(blob_storage._tid) database.undo(database.undoLog(0, 1)[0]['id'])
# undo the creation of the previously added blob
transaction.begin()
database.undo(serial, blob_storage._transaction)
transaction.commit() transaction.commit()
connection.close()
connection = database.open()
root = connection.root()
# the blob footprint object should exist no longer # the blob footprint object should exist no longer
self.assertRaises(KeyError, root.__getitem__, 'blob') self.assertRaises(KeyError, root.__getitem__, 'blob')
database.close() database.close()
...@@ -135,21 +128,11 @@ class BlobUndoTests(unittest.TestCase): ...@@ -135,21 +128,11 @@ class BlobUndoTests(unittest.TestCase):
blob.open('w').write('this is state 2') blob.open('w').write('this is state 2')
transaction.commit() transaction.commit()
transaction.begin()
blob = root['blob']
self.assertEqual(blob.open('r').read(), 'this is state 2')
transaction.abort()
serial = base64.encodestring(blob_storage._tid)
transaction.begin() database.undo(database.undoLog(0, 1)[0]['id'])
blob_storage.undo(serial, blob_storage._transaction)
transaction.commit() transaction.commit()
transaction.begin()
blob = root['blob']
self.assertEqual(blob.open('r').read(), 'this is state 1') self.assertEqual(blob.open('r').read(), 'this is state 1')
transaction.abort()
database.close() database.close()
def testUndoAfterConsumption(self): def testUndoAfterConsumption(self):
...@@ -171,21 +154,10 @@ class BlobUndoTests(unittest.TestCase): ...@@ -171,21 +154,10 @@ class BlobUndoTests(unittest.TestCase):
blob.consumeFile('consume2') blob.consumeFile('consume2')
transaction.commit() transaction.commit()
transaction.begin() database.undo(database.undoLog(0, 1)[0]['id'])
blob = root['blob']
self.assertEqual(blob.open('r').read(), 'this is state 2')
transaction.abort()
serial = base64.encodestring(blob_storage._tid)
transaction.begin()
blob_storage.undo(serial, blob_storage._transaction)
transaction.commit() transaction.commit()
transaction.begin()
blob = root['blob']
self.assertEqual(blob.open('r').read(), 'this is state 1') self.assertEqual(blob.open('r').read(), 'this is state 1')
transaction.abort()
database.close() database.close()
...@@ -207,27 +179,17 @@ class BlobUndoTests(unittest.TestCase): ...@@ -207,27 +179,17 @@ class BlobUndoTests(unittest.TestCase):
blob.open('w').write('this is state 2') blob.open('w').write('this is state 2')
transaction.commit() transaction.commit()
serial = base64.encodestring(blob_storage._tid) database.undo(database.undoLog(0, 1)[0]['id'])
transaction.begin()
database.undo(serial)
transaction.commit() transaction.commit()
transaction.begin()
blob = root['blob']
self.assertEqual(blob.open('r').read(), 'this is state 1') self.assertEqual(blob.open('r').read(), 'this is state 1')
transaction.abort()
serial = base64.encodestring(blob_storage._tid) serial = base64.encodestring(blob_storage._tid)
transaction.begin() database.undo(database.undoLog(0, 1)[0]['id'])
database.undo(serial)
transaction.commit() transaction.commit()
transaction.begin()
blob = root['blob']
self.assertEqual(blob.open('r').read(), 'this is state 2') self.assertEqual(blob.open('r').read(), 'this is state 2')
transaction.abort()
database.close() database.close()
...@@ -244,24 +206,15 @@ class BlobUndoTests(unittest.TestCase): ...@@ -244,24 +206,15 @@ class BlobUndoTests(unittest.TestCase):
root['blob'] = blob root['blob'] = blob
transaction.commit() transaction.commit()
serial = base64.encodestring(blob_storage._tid) database.undo(database.undoLog(0, 1)[0]['id'])
transaction.begin()
database.undo(serial)
transaction.commit() transaction.commit()
self.assertRaises(KeyError, root.__getitem__, 'blob') self.assertRaises(KeyError, root.__getitem__, 'blob')
serial = base64.encodestring(blob_storage._tid) database.undo(database.undoLog(0, 1)[0]['id'])
transaction.begin()
database.undo(serial)
transaction.commit() transaction.commit()
transaction.begin()
blob = root['blob']
self.assertEqual(blob.open('r').read(), 'this is state 1') self.assertEqual(blob.open('r').read(), 'this is state 1')
transaction.abort()
database.close() database.close()
......
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