[Zope3-checkins] CVS: Zope3/src/zodb/storage/tests - undo.py:1.11.2.3

Jeremy Hylton jeremy@zope.com
Thu, 17 Apr 2003 19:00:13 -0400


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

Modified Files:
      Tag: jeremy-new-pack-branch
	undo.py 
Log Message:
Add a test that fails for FileStorage, DemoStorage, and MemoryStorage.

Darn Berkeley storage passes ;-).


=== Zope3/src/zodb/storage/tests/undo.py 1.11.2.2 => 1.11.2.3 ===
--- Zope3/src/zodb/storage/tests/undo.py:1.11.2.2	Thu Apr 17 15:54:39 2003
+++ Zope3/src/zodb/storage/tests/undo.py	Thu Apr 17 19:00:12 2003
@@ -601,6 +601,42 @@
                 self.assertEqual(obj.value, i)
             root.items()
 
+    def testPackAfterUndoManyTimes(self):
+        db = DB(self._storage)
+        cn = db.open()
+        rt = cn.root()
+
+        rt["test"] = MinPO(1)
+        get_transaction().commit()
+        rt["test2"] = MinPO(2)
+        get_transaction().commit()
+        rt["test"] = MinPO(3)
+        txn = get_transaction()
+        txn.note("root of undo")
+        txn.commit()
+
+        packtimes = []
+        for i in range(10):
+            L = db.undoInfo()
+            db.undo(L[0]["id"])
+            txn = get_transaction()
+            txn.note("undo %d" % i)
+            txn.commit()
+
+            cn.sync()
+            self.assertEqual(rt["test"].value, i % 2 and 3 or 1)
+            
+            packtimes.append(time.time())
+            snooze()
+
+        for t in packtimes:
+            self._storage.pack(t)
+            cn.sync()
+            cn._cache.clear()
+            # The last undo set the value to 3 and pack should
+            # never change that.
+            self.assertEqual(rt["test"].value, 3)
+
     def testTransactionalUndoIterator(self):
         # check that data_txn set in iterator makes sense
         if not hasattr(self._storage, "iterator"):