[Zope-Checkins] CVS: Zope2 - TransactionalUndoVersionStorage.py:1.3
Jim Fulton
jim@digicool.com
Thu, 12 Apr 2001 19:35:32 -0400 (EDT)
Update of /cvs-repository/Zope2/lib/python/ZODB/tests
In directory korak:/tmp/cvs-serv9912
Modified Files:
TransactionalUndoVersionStorage.py
Log Message:
Some tests didn't recognize that when an object hasn't been modified
in a version, we fall back to non-version data.
Undo wasn't tested properly. The tests didn't get the undo ids
from the transaction log.
--- Updated File TransactionalUndoVersionStorage.py in package Zope2/lib/python/ZODB --
--- TransactionalUndoVersionStorage.py 2001/04/11 22:05:53 1.2
+++ TransactionalUndoVersionStorage.py 2001/04/12 23:35:31 1.3
@@ -13,8 +13,10 @@
revid_a = self._dostore(oid, data=91)
revid_b = self._dostore(oid, revid=revid_a, data=92, version=version)
revid_c = self._dostore(oid, revid=revid_b, data=93, version=version)
+ info=self._storage.undoInfo()
+ tid=info[0]['id']
self._storage.tpc_begin(self._transaction)
- oids = self._storage.transactionalUndo(revid_c, self._transaction)
+ oids = self._storage.transactionalUndo(tid, self._transaction)
self._storage.tpc_vote(self._transaction)
self._storage.tpc_finish(self._transaction)
assert len(oids) == 1
@@ -32,14 +34,20 @@
self._storage.tpc_finish(self._transaction)
assert len(oids) == 1
assert oids[0] == oid
- self.assertRaises(POSException.VersionError,
- self._storage.load,
- oid, version)
+
+ #JF# No, because we fall back to non-version data.
+ #JF# self.assertRaises(POSException.VersionError,
+ #JF# self._storage.load,
+ #JF# oid, version)
+ data, revid = self._storage.load(oid, version)
+ assert pickle.loads(data) == 92
data, revid = self._storage.load(oid, '')
assert pickle.loads(data) == 92
# ...and undo the commit
+ info=self._storage.undoInfo()
+ tid=info[0]['id']
self._storage.tpc_begin(self._transaction)
- oids = self._storage.transactionalUndo(revid, self._transaction)
+ oids = self._storage.transactionalUndo(tid, self._transaction)
self._storage.tpc_vote(self._transaction)
self._storage.tpc_finish(self._transaction)
assert len(oids) == 1
@@ -57,14 +65,19 @@
assert oids[0] == oid
# The object should not exist in the version now, but it should exist
# in the non-version
- self.assertRaises(POSException.VersionError,
- self._storage.load,
- oid, version)
+ #JF# No, because we fall back
+ #JF# self.assertRaises(POSException.VersionError,
+ #JF# self._storage.load,
+ #JF# oid, version)
+ data, revid = self._storage.load(oid, version)
+ assert pickle.loads(data) == 91
data, revid = self._storage.load(oid, '')
assert pickle.loads(data) == 91
# Now undo the abort
+ info=self._storage.undoInfo()
+ tid=info[0]['id']
self._storage.tpc_begin(self._transaction)
- oids = self._storage.transactionalUndo(revid, self._transaction)
+ oids = self._storage.transactionalUndo(tid, self._transaction)
self._storage.tpc_vote(self._transaction)
self._storage.tpc_finish(self._transaction)
assert len(oids) == 1
--- Updated File TransactionalUndoVersionStorage.py in package Zope2 --
--- TransactionalUndoVersionStorage.py 2001/04/11 22:05:53 1.2
+++ TransactionalUndoVersionStorage.py 2001/04/12 23:35:31 1.3
@@ -13,8 +13,10 @@
revid_a = self._dostore(oid, data=91)
revid_b = self._dostore(oid, revid=revid_a, data=92, version=version)
revid_c = self._dostore(oid, revid=revid_b, data=93, version=version)
+ info=self._storage.undoInfo()
+ tid=info[0]['id']
self._storage.tpc_begin(self._transaction)
- oids = self._storage.transactionalUndo(revid_c, self._transaction)
+ oids = self._storage.transactionalUndo(tid, self._transaction)
self._storage.tpc_vote(self._transaction)
self._storage.tpc_finish(self._transaction)
assert len(oids) == 1
@@ -32,14 +34,20 @@
self._storage.tpc_finish(self._transaction)
assert len(oids) == 1
assert oids[0] == oid
- self.assertRaises(POSException.VersionError,
- self._storage.load,
- oid, version)
+
+ #JF# No, because we fall back to non-version data.
+ #JF# self.assertRaises(POSException.VersionError,
+ #JF# self._storage.load,
+ #JF# oid, version)
+ data, revid = self._storage.load(oid, version)
+ assert pickle.loads(data) == 92
data, revid = self._storage.load(oid, '')
assert pickle.loads(data) == 92
# ...and undo the commit
+ info=self._storage.undoInfo()
+ tid=info[0]['id']
self._storage.tpc_begin(self._transaction)
- oids = self._storage.transactionalUndo(revid, self._transaction)
+ oids = self._storage.transactionalUndo(tid, self._transaction)
self._storage.tpc_vote(self._transaction)
self._storage.tpc_finish(self._transaction)
assert len(oids) == 1
@@ -57,14 +65,19 @@
assert oids[0] == oid
# The object should not exist in the version now, but it should exist
# in the non-version
- self.assertRaises(POSException.VersionError,
- self._storage.load,
- oid, version)
+ #JF# No, because we fall back
+ #JF# self.assertRaises(POSException.VersionError,
+ #JF# self._storage.load,
+ #JF# oid, version)
+ data, revid = self._storage.load(oid, version)
+ assert pickle.loads(data) == 91
data, revid = self._storage.load(oid, '')
assert pickle.loads(data) == 91
# Now undo the abort
+ info=self._storage.undoInfo()
+ tid=info[0]['id']
self._storage.tpc_begin(self._transaction)
- oids = self._storage.transactionalUndo(revid, self._transaction)
+ oids = self._storage.transactionalUndo(tid, self._transaction)
self._storage.tpc_vote(self._transaction)
self._storage.tpc_finish(self._transaction)
assert len(oids) == 1