[Zodb-checkins] CVS: ZODB3/ZODB/tests - RevisionStorage.py:1.4.2.1

Jeremy Hylton cvs-admin at zope.org
Wed Nov 12 12:25:16 EST 2003


Update of /cvs-repository/ZODB3/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv2024/ZODB/tests

Modified Files:
      Tag: ZODB3-mvcc-2-branch
	RevisionStorage.py 
Log Message:
Add a couple tests of loadNonCurrent().



=== ZODB3/ZODB/tests/RevisionStorage.py 1.4 => 1.4.2.1 ===
--- ZODB3/ZODB/tests/RevisionStorage.py:1.4	Thu Oct  2 14:17:17 2003
+++ ZODB3/ZODB/tests/RevisionStorage.py	Wed Nov 12 12:25:13 2003
@@ -15,6 +15,7 @@
 
 from ZODB.tests.MinPO import MinPO
 from ZODB.tests.StorageTestBase import zodb_unpickle, zodb_pickle
+from ZODB.utils import p64, u64
 
 ZERO = '\0'*8
 
@@ -31,3 +32,49 @@
         for revid, value in revisions.items():
             data = self._storage.loadSerial(oid, revid)
             self.assertEqual(zodb_unpickle(data), value)
+
+    def checkLoadNonCurrent(self):
+        # Store 10 revisions of one object and then make sure that we
+        # can get all the non-current revisions back.
+        oid = self._storage.new_oid()
+        revs = []
+        revid = None
+        for i in range(10):
+            revid = self._dostore(oid, revid, data=MinPO(i))
+            revs.append(self._storage.loadEx(oid, ""))
+            
+        prev = u64(revs[0][2])
+        for i in range(1, 10):
+            tid = revs[i][2]
+            cur = u64(tid)
+            middle = prev + (cur - prev) / 2
+            prev = cur
+            t = self._storage.loadNonCurrent(oid, p64(middle))
+            self.assert_(t is not None)
+            data, serial, start, end = t
+            self.assertEqual(revs[i-1][0], data)
+            self.assertEqual(tid, end)
+            
+
+    def checkLoadNonCurrentEdges(self):
+        # Check the edges cases for a non-current load.
+        oid = self._storage.new_oid()
+        revid1 = self._dostore(oid, data=MinPO(1))
+        
+        self.assertEqual(self._storage.loadNonCurrent(oid, p64(0)), None)
+        self.assertEqual(self._storage.loadNonCurrent(oid, revid1), None)
+        
+        cur = p64(u64(revid1) + 1)
+        data, serial, start, end = self._storage.loadNonCurrent(oid, cur)
+        self.assertEqual(zodb_unpickle(data), MinPO(1))
+        self.assertEqual(start, revid1)
+        self.assertEqual(end, None)
+
+        revid2 = self._dostore(oid, revid=revid1, data=MinPO(2))
+        data, serial, start, end = self._storage.loadNonCurrent(oid, cur)
+        self.assertEqual(zodb_unpickle(data), MinPO(1))
+        self.assertEqual(start, revid1)
+        self.assertEqual(end, revid2)
+
+    # XXX There are other edge cases to handle, including undo and
+    # pack.




More information about the Zodb-checkins mailing list