[Zodb-checkins] CVS: ZODB4/src/zodb/storage/tests - undo.py:1.16.6.1

Jeremy Hylton jeremy at zope.com
Thu Jun 19 16:09:32 EDT 2003


Update of /cvs-repository/ZODB4/src/zodb/storage/tests
In directory cvs.zope.org:/tmp/cvs-serv26582/storage/tests

Modified Files:
      Tag: ZODB3-2-merge
	undo.py 
Log Message:
Add a new test that combines pack and undoLog().

Put them in the undo tests, because every storage implements pack() but
some don't have a useful undoLog().


=== ZODB4/src/zodb/storage/tests/undo.py 1.16 => 1.16.6.1 ===
--- ZODB4/src/zodb/storage/tests/undo.py:1.16	Fri May 16 17:36:57 2003
+++ ZODB4/src/zodb/storage/tests/undo.py	Thu Jun 19 15:09:31 2003
@@ -766,3 +766,76 @@
                 break
         else:
             self.fail('transaction not found')
+
+    def testPackUndoLog(self):
+        self._initroot()
+        eq = self.assertEqual
+        raises = self.assertRaises
+        # Create a `persistent' object
+        obj = self._newobj()
+        obj.value = 1
+        oid = obj._p_oid
+        # Commit two different revisions
+        revid1 = self._dostore(oid, data=obj)
+        obj.value = 2
+        snooze()
+        packtime = time.time()
+        snooze()
+        revid2 = self._dostore(oid, revid=revid1, data=obj)
+        # Now pack the first transaction
+        self.assertEqual(3, len(self._storage.undoLog()))
+        self._storage.pack(packtime)
+        # The undo log contains only the most resent transaction
+        self.assertEqual(1, len(self._storage.undoLog()))
+
+    def dont_testPackUndoLogUndoable(self):
+        # XXX This test was copied from ZODB3, but no effort was made
+        # to convert the code to make it work in ZODB4.
+        
+        # A disabled test. I wanted to test that the content of the
+        # undo log was consistent, but every storage appears to
+        # include something slightly different. If the result of this
+        # method is only used to fill a GUI then this difference
+        # doesnt matter.  Perhaps re-enable this test once we agree
+        # what should be asserted.
+
+        self._initroot()
+        # Create two `persistent' object
+        obj1 = self._newobj()
+        oid1 = obj1.getoid()
+        obj1.value = 1
+        obj2 = self._newobj()
+        oid2 = obj2.getoid()
+        obj2.value = 2
+        
+        # Commit the first revision of each of them
+        revid11 = self._dostoreNP(oid1, data=pickle.dumps(obj1),
+                                  description="1-1")
+        revid22 = self._dostoreNP(oid2, data=pickle.dumps(obj2),
+                                  description="2-2")
+        
+        # remember the time. everything above here will be packed away
+        snooze()
+        packtime = time.time()
+        snooze()
+        # Commit two revisions of the first object
+        obj1.value = 3
+        revid13 = self._dostoreNP(oid1, revid=revid11,
+                                  data=pickle.dumps(obj1), description="1-3")
+        obj1.value = 4
+        revid14 = self._dostoreNP(oid1, revid=revid13,
+                                  data=pickle.dumps(obj1), description="1-4")
+        # Commit one revision of the second object
+        obj2.value = 5
+        revid25 = self._dostoreNP(oid2, revid=revid22,
+                                  data=pickle.dumps(obj2), description="2-5")
+        # Now pack
+        self.assertEqual(6,len(self._storage.undoLog()))
+        print '\ninitial undoLog was'
+        for r in self._storage.undoLog(): print r
+        self._storage.pack(packtime, referencesf)
+        # The undo log contains only two undoable transaction.
+        print '\nafter packing undoLog was'
+        for r in self._storage.undoLog(): print r
+        # what can we assert about that?
+




More information about the Zodb-checkins mailing list