[Zodb-checkins] CVS: ZODB3/ZODB/tests -
TransactionalUndoStorage.py:1.32.8.3
Jeremy Hylton
jeremy at zope.com
Tue Jul 15 15:18:06 EDT 2003
Update of /cvs-repository/ZODB3/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv2583/ZODB/tests
Modified Files:
Tag: zodb33-devel-branch
TransactionalUndoStorage.py
Log Message:
Simple undo helper method.
=== ZODB3/ZODB/tests/TransactionalUndoStorage.py 1.32.8.2 => 1.32.8.3 ===
--- ZODB3/ZODB/tests/TransactionalUndoStorage.py:1.32.8.2 Mon Jul 7 17:43:40 2003
+++ ZODB3/ZODB/tests/TransactionalUndoStorage.py Tue Jul 15 14:18:01 2003
@@ -99,6 +99,15 @@
for rec in txn:
pass
+ def undo(self, tid, note):
+ t = Transaction()
+ t.note(note)
+ self._storage.tpc_begin(t)
+ oids = self._storage.transactionalUndo(tid, t)
+ self._storage.tpc_vote(t)
+ self._storage.tpc_finish(t)
+ return oids
+
def checkSimpleTransactionalUndo(self):
eq = self.assertEqual
oid = self._storage.new_oid()
@@ -109,12 +118,7 @@
info = self._storage.undoInfo()
tid = info[0]['id']
# Now start an undo transaction
- t = Transaction()
- t.note('undo1')
- self._storage.tpc_begin(t)
- oids = self._storage.transactionalUndo(tid, t)
- self._storage.tpc_vote(t)
- self._storage.tpc_finish(t)
+ oids = self.undo(tid, "undo1")
eq(len(oids), 1)
eq(oids[0], oid)
data, revid = self._storage.load(oid, '')
@@ -122,12 +126,7 @@
# Do another one
info = self._storage.undoInfo()
tid = info[2]['id']
- t = Transaction()
- t.note('undo2')
- self._storage.tpc_begin(t)
- oids = self._storage.transactionalUndo(tid, t)
- self._storage.tpc_vote(t)
- self._storage.tpc_finish(t)
+ oids = self.undo(tid, "undo2")
eq(len(oids), 1)
eq(oids[0], oid)
data, revid = self._storage.load(oid, '')
@@ -135,12 +134,7 @@
# Try to undo the first record
info = self._storage.undoInfo()
tid = info[4]['id']
- t = Transaction()
- t.note('undo3')
- self._storage.tpc_begin(t)
- oids = self._storage.transactionalUndo(tid, t)
- self._storage.tpc_vote(t)
- self._storage.tpc_finish(t)
+ oids = self.undo(tid, "undo3")
eq(len(oids), 1)
eq(oids[0], oid)
# This should fail since we've undone the object's creation
@@ -149,11 +143,7 @@
# And now let's try to redo the object's creation
info = self._storage.undoInfo()
tid = info[0]['id']
- t = Transaction()
- self._storage.tpc_begin(t)
- oids = self._storage.transactionalUndo(tid, t)
- self._storage.tpc_vote(t)
- self._storage.tpc_finish(t)
+ oids = self.undo(tid, "undo4")
eq(len(oids), 1)
eq(oids[0], oid)
data, revid = self._storage.load(oid, '')
@@ -163,14 +153,14 @@
def checkCreationUndoneGetSerial(self):
# create an object
oid = self._storage.new_oid()
- revid = self._dostore(oid, data=MinPO(23))
+ self._dostore(oid, data=MinPO(23))
# undo its creation
info = self._storage.undoInfo()
tid = info[0]['id']
t = Transaction()
t.note('undo1')
self._storage.tpc_begin(t)
- oids = self._storage.transactionalUndo(tid, t)
+ self._storage.transactionalUndo(tid, t)
self._storage.tpc_vote(t)
self._storage.tpc_finish(t)
# Check that calling getSerial on an uncreated object raises a KeyError
@@ -502,7 +492,7 @@
packtime = time.time()
snooze() # time.time() now distinct from packtime
revid2 = self._dostore(oid, revid=revid1, data=MinPO(52))
- revid3 = self._dostore(oid, revid=revid2, data=MinPO(53))
+ self._dostore(oid, revid=revid2, data=MinPO(53))
# Now get the undo log
info = self._storage.undoInfo()
eq(len(info), 3)
More information about the Zodb-checkins
mailing list