Commit 5f274be4 authored by Barry Warsaw's avatar Barry Warsaw

checkUndoInVersion(): Change all the `assert's to self.assertEqual()

via a convenient local variable.
parent c9852e88
......@@ -30,6 +30,8 @@ class TransactionalUndoVersionStorage:
return self._dostore(*args, **kwargs)
def checkUndoInVersion(self):
eq = self.assertEqual
unless = self.failUnless
oid = self._storage.new_oid()
version = 'one'
revid_a = self._dostore(oid, data=MinPO(91))
......@@ -44,31 +46,31 @@ class TransactionalUndoVersionStorage:
oids = self._storage.transactionalUndo(tid, t)
self._storage.tpc_vote(t)
self._storage.tpc_finish(t)
assert len(oids) == 1
assert oids[0] == oid
eq(len(oids), 1)
eq(oids[0], oid)
data, revid = self._storage.load(oid, '')
assert revid == revid_a
assert zodb_unpickle(data) == MinPO(91)
eq(revid, revid_a)
eq(zodb_unpickle(data), MinPO(91))
data, revid = self._storage.load(oid, version)
assert revid > revid_b and revid > revid_c
assert zodb_unpickle(data) == MinPO(92)
unless(revid > revid_b and revid > revid_c)
eq(zodb_unpickle(data), MinPO(92))
# Now commit the version...
t = Transaction()
self._storage.tpc_begin(t)
oids = self._storage.commitVersion(version, '', t)
self._storage.tpc_vote(t)
self._storage.tpc_finish(t)
assert len(oids) == 1
assert oids[0] == oid
eq(len(oids), 1)
eq(oids[0], oid)
#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 zodb_unpickle(data) == MinPO(92)
eq(zodb_unpickle(data), MinPO(92))
data, revid = self._storage.load(oid, '')
assert zodb_unpickle(data) == MinPO(92)
eq(zodb_unpickle(data), MinPO(92))
# ...and undo the commit
info=self._storage.undoInfo()
tid=info[0]['id']
......@@ -77,20 +79,20 @@ class TransactionalUndoVersionStorage:
oids = self._storage.transactionalUndo(tid, t)
self._storage.tpc_vote(t)
self._storage.tpc_finish(t)
assert len(oids) == 1
assert oids[0] == oid
eq(len(oids), 1)
eq(oids[0], oid)
data, revid = self._storage.load(oid, version)
assert zodb_unpickle(data) == MinPO(92)
eq(zodb_unpickle(data), MinPO(92))
data, revid = self._storage.load(oid, '')
assert zodb_unpickle(data) == MinPO(91)
eq(zodb_unpickle(data), MinPO(91))
# Now abort the version
t = Transaction()
self._storage.tpc_begin(t)
oids = self._storage.abortVersion(version, t)
self._storage.tpc_vote(t)
self._storage.tpc_finish(t)
assert len(oids) == 1
assert oids[0] == oid
eq(len(oids), 1)
eq(oids[0], oid)
# The object should not exist in the version now, but it should exist
# in the non-version
#JF# No, because we fall back
......@@ -98,9 +100,9 @@ class TransactionalUndoVersionStorage:
#JF# self._storage.load,
#JF# oid, version)
data, revid = self._storage.load(oid, version)
assert zodb_unpickle(data) == MinPO(91)
eq(zodb_unpickle(data), MinPO(91))
data, revid = self._storage.load(oid, '')
assert zodb_unpickle(data) == MinPO(91)
eq(zodb_unpickle(data), MinPO(91))
# Now undo the abort
info=self._storage.undoInfo()
tid=info[0]['id']
......@@ -109,13 +111,13 @@ class TransactionalUndoVersionStorage:
oids = self._storage.transactionalUndo(tid, t)
self._storage.tpc_vote(t)
self._storage.tpc_finish(t)
assert len(oids) == 1
assert oids[0] == oid
eq(len(oids), 1)
eq(oids[0], oid)
# And the object should be back in versions 'one' and ''
data, revid = self._storage.load(oid, version)
assert zodb_unpickle(data) == MinPO(92)
eq(zodb_unpickle(data), MinPO(92))
data, revid = self._storage.load(oid, '')
assert zodb_unpickle(data) == MinPO(91)
eq(zodb_unpickle(data), MinPO(91))
def checkUndoCommitVersion(self):
def load_value(oid, version=''):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment