[Zope3-checkins] CVS: Zope3/src/zodb/storage/tests - version.py:1.3.4.3 undo.py:1.5.4.3 recovery.py:1.4.4.5
Jeremy Hylton
jeremy@zope.com
Wed, 12 Mar 2003 16:12:31 -0500
Update of /cvs-repository/Zope3/src/zodb/storage/tests
In directory cvs.zope.org:/tmp/cvs-serv19187/storage/tests
Modified Files:
Tag: opaque-pickles-branch
version.py undo.py recovery.py
Log Message:
Fix the last remaining problems with undo and versions.
Remove max argument from versions() YAGNI!
Refactor a lot more code to use _read_data_header().
Twiddle tests to add some txn notes for readability.
=== Zope3/src/zodb/storage/tests/version.py 1.3.4.2 => 1.3.4.3 ===
--- Zope3/src/zodb/storage/tests/version.py:1.3.4.2 Tue Mar 11 18:37:57 2003
+++ Zope3/src/zodb/storage/tests/version.py Wed Mar 12 16:11:58 2003
@@ -122,10 +122,6 @@
unless('one' in versions)
unless('two' in versions)
unless('three' in versions)
- # Now flex the `max' argument
- versions = self._storage.versions(1)
- self.assertEqual(len(versions), 1)
- unless('one' in versions or 'two' in versions or 'three' in versions)
def _setup_version(self, version='test-version'):
# Store some revisions in the non-version
=== Zope3/src/zodb/storage/tests/undo.py 1.5.4.2 => 1.5.4.3 ===
--- Zope3/src/zodb/storage/tests/undo.py:1.5.4.2 Mon Mar 10 17:45:00 2003
+++ Zope3/src/zodb/storage/tests/undo.py Wed Mar 12 16:11:58 2003
@@ -44,9 +44,11 @@
def _transaction_newserial(self, oid):
return self.__serials[oid]
- def _multi_obj_transaction(self, objs):
+ def _multi_obj_transaction(self, objs, note=None):
newrevs = {}
t = Transaction()
+ if note:
+ t.note(note)
self._storage.tpcBegin(t)
self._transaction_begin()
for oid, rev, data in objs:
@@ -261,17 +263,17 @@
# Store two objects in the same transaction
d = self._multi_obj_transaction([(oid1, revid1, p30),
(oid2, revid2, p50),
- ])
+ ], "first update")
eq(d[oid1], d[oid2])
# Update those same two objects
d = self._multi_obj_transaction([(oid1, d[oid1], p31),
(oid2, d[oid2], p51),
- ])
+ ], "second update")
eq(d[oid1], d[oid2])
# Update those same two objects
d = self._multi_obj_transaction([(oid1, d[oid1], p32),
(oid2, d[oid2], p52),
- ])
+ ], "third update")
eq(d[oid1], d[oid2])
revid1 = self._transaction_newserial(oid1)
revid2 = self._transaction_newserial(oid2)
@@ -286,14 +288,12 @@
tid = info[0]['id']
tid1 = info[1]['id']
t = Transaction()
+ t.note("undo transaction containing two objects")
self._storage.tpcBegin(t)
oids = self._storage.undo(tid, t)
oids1 = self._storage.undo(tid1, t)
self._storage.tpcVote(t)
self._storage.tpcFinish(t)
- # We get the finalization stuff called an extra time:
-## self._storage.tpc_vote(t)
-## self._storage.tpc_finish(t)
eq(len(oids), 2)
eq(len(oids1), 2)
unless(oid1 in oids)
@@ -306,6 +306,7 @@
info = self._storage.undoInfo()
tid = info[0]['id']
t = Transaction()
+ t.note("undo the undo")
self._storage.tpcBegin(t)
oids = self._storage.undo(tid, t)
self._storage.tpcVote(t)
=== Zope3/src/zodb/storage/tests/recovery.py 1.4.4.4 => 1.4.4.5 ===
--- Zope3/src/zodb/storage/tests/recovery.py:1.4.4.4 Wed Mar 12 12:28:46 2003
+++ Zope3/src/zodb/storage/tests/recovery.py Wed Mar 12 16:11:58 2003
@@ -80,6 +80,16 @@
siter.close()
def checkRecoverUndoInVersion(self):
+
+ def checkObj(oid, version, v_data, nv_data):
+ # Cause test to fail if object oid has wrong data.
+ # Last two args are MinPO value on version and non-version.
+ data, revid = self._storage.load(oid, "")
+ self.assertEqual(zodb_unpickle(data).value, nv_data)
+ data, revid = self._storage.load(oid, version)
+ self.assertEqual(zodb_unpickle(data).value, v_data)
+
+
oid = self._storage.newObjectId()
version = "aVersion"
revid_a = self._dostore(oid, data=MinPO(91))
@@ -105,11 +115,7 @@
self._undo(self._storage.undoInfo()[0]['id'], oid)
self.assert_(not self._storage.versionEmpty(version))
- # check the data is what we expect it to be
- data, revid = self._storage.load(oid, version)
- self.assertEqual(zodb_unpickle(data), MinPO(92))
- data, revid = self._storage.load(oid, '')
- self.assertEqual(zodb_unpickle(data), MinPO(91))
+ checkObj(oid, version, 92, 91)
# and swap the storages
tmp = self._storage
@@ -119,11 +125,7 @@
self._undo(self._storage.undoInfo()[0]['id'], oid)
self.assert_(not self._storage.versionEmpty(version))
- # check the data is what we expect it to be
- data, revid = self._storage.load(oid, version)
- self.assertEqual(zodb_unpickle(data), MinPO(92))
- data, revid = self._storage.load(oid, '')
- self.assertEqual(zodb_unpickle(data), MinPO(91))
+ checkObj(oid, version, 92, 91)
# swap them back
self._storage = tmp