[Zodb-checkins] CVS: Zope2/lib/python/ZODB - TransactionalUndoStorage.py:1.5

Jim Fulton jim@digicool.com
Thu, 12 Apr 2001 16:35:41 -0400 (EDT)


Update of /cvs-repository/Zope2/lib/python/ZODB/tests
In directory korak:/tmp/cvs-serv31416

Modified Files:
	TransactionalUndoStorage.py 
Log Message:
Fixed the test for multiple undos in the same transaction to reflect
the fact that tpc_vote and tpc_finish can be called extra times.

Also added code to same test to undo the transaction that undid
multiple transaction to exercise bug found in FileStorage.



--- Updated File TransactionalUndoStorage.py in package Zope2/lib/python/ZODB --
--- TransactionalUndoStorage.py	2001/04/11 22:04:52	1.4
+++ TransactionalUndoStorage.py	2001/04/12 20:35:40	1.5
@@ -150,6 +150,9 @@
         oids1 = self._storage.transactionalUndo(tid1, self._transaction)
         self._storage.tpc_vote(self._transaction)
         self._storage.tpc_finish(self._transaction)
+        # We get the finalization stuff called an extra time:
+        self._storage.tpc_vote(self._transaction)
+        self._storage.tpc_finish(self._transaction)
         assert len(oids) == 2
         assert len(oids1) == 2
         assert oid1 in oids and oid2 in oids
@@ -158,6 +161,20 @@
         data, revid2 = self._storage.load(oid2, '')
         assert pickle.loads(data) == 50
 
+        # Now try to undo the one we just did to undo, whew
+        info =self._storage.undoInfo()
+        tid = info[0]['id']
+        self._storage.tpc_begin(self._transaction)
+        oids = self._storage.transactionalUndo(tid, self._transaction)
+        self._storage.tpc_vote(self._transaction)
+        self._storage.tpc_finish(self._transaction)
+        assert len(oids) == 2
+        data, revid1 = self._storage.load(oid1, '')
+        assert pickle.loads(data) == 32
+        data, revid2 = self._storage.load(oid2, '')
+        assert pickle.loads(data) == 52
+
+
     def checkTwoObjectUndoAgain(self):
         p32, p33, p52, p53 = map(pickle.dumps, (32, 33, 52, 53))
         # Like the above, but the first revision of the objects are stored in
@@ -212,6 +229,7 @@
         assert pickle.loads(data) == 33
         data, revid2 = self._storage.load(oid2, '')
         assert pickle.loads(data) == 54
+        
 
     def checkNotUndoable(self):
         # Set things up so we've got a transaction that can't be undone