[Zodb-checkins] SVN: ZODB/branches/jim-thready/src/Z Various test fixes to account for fact that undone oids can now be

Jim Fulton jim at zope.com
Sun Jan 24 14:02:37 EST 2010


Log message for revision 108447:
  Various test fixes to account for fact that undone oids can now be
  returned by tpc_vote, rather than undo. Also added some missing vote
  calls (sheesh).
  

Changed:
  U   ZODB/branches/jim-thready/src/ZEO/tests/Cache.py
  U   ZODB/branches/jim-thready/src/ZODB/tests/ConflictResolution.py
  U   ZODB/branches/jim-thready/src/ZODB/tests/StorageTestBase.py
  U   ZODB/branches/jim-thready/src/ZODB/tests/TransactionalUndoStorage.py

-=-
Modified: ZODB/branches/jim-thready/src/ZEO/tests/Cache.py
===================================================================
--- ZODB/branches/jim-thready/src/ZEO/tests/Cache.py	2010-01-24 19:02:35 UTC (rev 108446)
+++ ZODB/branches/jim-thready/src/ZEO/tests/Cache.py	2010-01-24 19:02:37 UTC (rev 108447)
@@ -37,14 +37,11 @@
         # Now start an undo transaction
         t = Transaction()
         t.note('undo1')
-        self._storage.tpc_begin(t)
+        oids = self._begin_undos_vote(t, tid)
 
-        tid, oids = self._storage.undo(tid, t)
-
         # Make sure this doesn't load invalid data into the cache
         self._storage.load(oid, '')
 
-        self._storage.tpc_vote(t)
         self._storage.tpc_finish(t)
 
         assert len(oids) == 1

Modified: ZODB/branches/jim-thready/src/ZODB/tests/ConflictResolution.py
===================================================================
--- ZODB/branches/jim-thready/src/ZODB/tests/ConflictResolution.py	2010-01-24 19:02:35 UTC (rev 108446)
+++ ZODB/branches/jim-thready/src/ZODB/tests/ConflictResolution.py	2010-01-24 19:02:37 UTC (rev 108447)
@@ -158,6 +158,7 @@
         t = Transaction()
         self._storage.tpc_begin(t)
         self._storage.undo(tid, t)
+        self._storage.tpc_vote(t)
         self._storage.tpc_finish(t)
 
     def checkUndoUnresolvable(self):
@@ -177,7 +178,5 @@
         info = self._storage.undoInfo()
         tid = info[1]['id']
         t = Transaction()
-        self._storage.tpc_begin(t)
-        self.assertRaises(UndoError, self._storage.undo,
-                          tid, t)
+        self.assertRaises(UndoError, self._begin_undos_vote, t, tid)
         self._storage.tpc_abort(t)

Modified: ZODB/branches/jim-thready/src/ZODB/tests/StorageTestBase.py
===================================================================
--- ZODB/branches/jim-thready/src/ZODB/tests/StorageTestBase.py	2010-01-24 19:02:35 UTC (rev 108446)
+++ ZODB/branches/jim-thready/src/ZODB/tests/StorageTestBase.py	2010-01-24 19:02:37 UTC (rev 108447)
@@ -210,10 +210,11 @@
         t.note(note or "undo")
         self._storage.tpc_begin(t)
         undo_result = self._storage.undo(tid, t)
-        self._storage.tpc_vote(t)
+        vote_result = self._storage.tpc_vote(t)
         self._storage.tpc_finish(t)
         if expected_oids is not None:
-            oids = undo_result[1]
+            oids = undo_result and undo_result[1] or []
+            oids.extend(oid for (oid, _) in vote_result or ())
             self.assertEqual(len(oids), len(expected_oids), repr(oids))
             for oid in expected_oids:
                 self.assert_(oid in oids)

Modified: ZODB/branches/jim-thready/src/ZODB/tests/TransactionalUndoStorage.py
===================================================================
--- ZODB/branches/jim-thready/src/ZODB/tests/TransactionalUndoStorage.py	2010-01-24 19:02:35 UTC (rev 108446)
+++ ZODB/branches/jim-thready/src/ZODB/tests/TransactionalUndoStorage.py	2010-01-24 19:02:37 UTC (rev 108447)
@@ -101,12 +101,20 @@
             for rec in txn:
                 pass
 
+    def _begin_undos_vote(self, t, *tids):
+        self._storage.tpc_begin(t)
+        oids = []
+        for tid in tids:
+            undo_result = self._storage.undo(tid, t)
+            if undo_result:
+                oids.extend(undo_result[1])
+        oids.extend(oid for (oid, _) in self._storage.tpc_vote(t) or ())
+        return oids
+
     def undo(self, tid, note):
         t = Transaction()
         t.note(note)
-        self._storage.tpc_begin(t)
-        oids = self._storage.undo(tid, t)
-        self._storage.tpc_vote(t)
+        oids = self._begin_undos_vote(t, tid)
         self._storage.tpc_finish(t)
         return oids
 
@@ -152,9 +160,7 @@
         tid = info[0]['id']
         t = Transaction()
         t.note('undo1')
-        self._storage.tpc_begin(t)
-        self._storage.undo(tid, t)
-        self._storage.tpc_vote(t)
+        self._begin_undos_vote(t, tid)
         self._storage.tpc_finish(t)
         # Check that calling getTid on an uncreated object raises a KeyError
         # The current version of FileStorage fails this test
@@ -281,14 +287,10 @@
         tid = info[0]['id']
         tid1 = info[1]['id']
         t = Transaction()
-        self._storage.tpc_begin(t)
-        tid, oids = self._storage.undo(tid, t)
-        tid, oids1 = self._storage.undo(tid1, t)
-        self._storage.tpc_vote(t)
+        oids = self._begin_undos_vote(t, tid, tid1)
         self._storage.tpc_finish(t)
         # We get the finalization stuff called an extra time:
-        eq(len(oids), 2)
-        eq(len(oids1), 2)
+        eq(len(oids), 4)
         unless(oid1 in oids)
         unless(oid2 in oids)
         data, revid1 = self._storage.load(oid1, '')
@@ -355,9 +357,7 @@
         info = self._storage.undoInfo()
         tid = info[1]['id']
         t = Transaction()
-        self._storage.tpc_begin(t)
-        tid, oids = self._storage.undo(tid, t)
-        self._storage.tpc_vote(t)
+        oids = self._begin_undos_vote(t, tid)
         self._storage.tpc_finish(t)
         eq(len(oids), 1)
         self.failUnless(oid1 in oids)
@@ -368,11 +368,6 @@
         eq(zodb_unpickle(data), MinPO(54))
         self._iterate()
 
-
-    def __undo_and_vote(self, tid, t):
-        self._storage.undo(tid, t)
-        self._storage.tpc_vote(t)
-
     def checkNotUndoable(self):
         eq = self.assertEqual
         # Set things up so we've got a transaction that can't be undone
@@ -384,8 +379,7 @@
         info = self._storage.undoInfo()
         tid = info[1]['id']
         t = Transaction()
-        self._storage.tpc_begin(t)
-        self.assertRaises(POSException.UndoError, self.__undo_and_vote, tid, t)
+        self.assertRaises(POSException.UndoError, self._begin_undos_vote, t, tid)
         self._storage.tpc_abort(t)
         # Now have more fun: object1 and object2 are in the same transaction,
         # which we'll try to undo to, but one of them has since modified in
@@ -421,8 +415,7 @@
         info = self._storage.undoInfo()
         tid = info[1]['id']
         t = Transaction()
-        self._storage.tpc_begin(t)
-        self.assertRaises(POSException.UndoError, self.__undo_and_vote, tid, t)
+        self.assertRaises(POSException.UndoError, self._begin_undos_vote, t, tid)
         self._storage.tpc_abort(t)
         self._iterate()
 
@@ -439,7 +432,7 @@
         # So, basically, this makes sure that undo info doesn't depend
         # on file positions.  We change the file positions in an undo
         # record by packing.
-        
+
         # Add a few object revisions
         oid = '\0'*8
         revid0 = self._dostore(oid, data=MinPO(50))
@@ -462,9 +455,7 @@
         self.assertEqual(len(info2), 2)
         # And now attempt to undo the last transaction
         t = Transaction()
-        self._storage.tpc_begin(t)
-        tid, oids = self._storage.undo(tid, t)
-        self._storage.tpc_vote(t)
+        oids = self._begin_undos_vote(t, tid)
         self._storage.tpc_finish(t)
         self.assertEqual(len(oids), 1)
         self.assertEqual(oids[0], oid)



More information about the Zodb-checkins mailing list