[Zodb-checkins] CVS: ZODB3/ZODB/tests - RevisionStorage.py:1.4.2.2
Jeremy Hylton
cvs-admin at zope.org
Wed Nov 12 15:27:13 EST 2003
Update of /cvs-repository/ZODB3/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv31269/ZODB/tests
Modified Files:
Tag: ZODB3-mvcc-2-branch
RevisionStorage.py
Log Message:
Working implementation of loadNonCurrent() for FileStorage.
Add two new tests of loadNonCurrent().
=== ZODB3/ZODB/tests/RevisionStorage.py 1.4.2.1 => 1.4.2.2 ===
--- ZODB3/ZODB/tests/RevisionStorage.py:1.4.2.1 Wed Nov 12 12:25:13 2003
+++ ZODB3/ZODB/tests/RevisionStorage.py Wed Nov 12 15:26:41 2003
@@ -54,11 +54,14 @@
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()
+
+ self.assertRaises(KeyError, self._storage.loadNonCurrent,
+ oid, p64(0))
+
revid1 = self._dostore(oid, data=MinPO(1))
self.assertEqual(self._storage.loadNonCurrent(oid, p64(0)), None)
@@ -76,5 +79,49 @@
self.assertEqual(start, revid1)
self.assertEqual(end, revid2)
- # XXX There are other edge cases to handle, including undo and
- # pack.
+ def checkLoadNonCurrentOld(self):
+ # Look for a very old revision. With the BaseStorage implementation
+ # this should require multple history() calls.
+ oid = self._storage.new_oid()
+ revs = []
+ revid = None
+ for i in range(50):
+ revid = self._dostore(oid, revid, data=MinPO(i))
+ revs.append(revid)
+
+ data, serial, start, end = self._storage.loadNonCurrent(oid, revs[12])
+ self.assertEqual(zodb_unpickle(data), MinPO(11))
+ self.assertEqual(start, revs[11])
+ self.assertEqual(end, revs[12])
+
+
+ # XXX Is it okay to assume everyone testing against RevisionStorage
+ # implements undo?
+
+ def checkLoadNonCurrentUndo(self):
+ # Do several transactions then undo them.
+ oid = self._storage.new_oid()
+ revid = None
+ for i in range(5):
+ revid = self._dostore(oid, revid, data=MinPO(i))
+ revs = []
+ for i in range(4):
+ info = self._storage.undoInfo()
+ tid = info[0]["id"]
+ # Always undo the most recent txn, so the value will
+ # alternate between 3 and 4.
+ self._undo(tid, [oid])
+ revs.append(self._storage.loadEx(oid, ""))
+
+ for i, (data, serial, tid) in enumerate(revs):
+ t = self._storage.loadNonCurrent(oid, p64(u64(tid) + 1))
+ self.assertEqual(data, t[0])
+ self.assertEqual(serial, t[1])
+ self.assertEqual(tid, t[2])
+ if i < 3:
+ self.assertEqual(revs[i+1][2], t[3])
+ else:
+ self.assertEqual(None, t[3])
+
+
+ # XXX There are other edge cases to handle, including pack.
More information about the Zodb-checkins
mailing list