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: ...@@ -30,6 +30,8 @@ class TransactionalUndoVersionStorage:
return self._dostore(*args, **kwargs) return self._dostore(*args, **kwargs)
def checkUndoInVersion(self): def checkUndoInVersion(self):
eq = self.assertEqual
unless = self.failUnless
oid = self._storage.new_oid() oid = self._storage.new_oid()
version = 'one' version = 'one'
revid_a = self._dostore(oid, data=MinPO(91)) revid_a = self._dostore(oid, data=MinPO(91))
...@@ -44,31 +46,31 @@ class TransactionalUndoVersionStorage: ...@@ -44,31 +46,31 @@ class TransactionalUndoVersionStorage:
oids = self._storage.transactionalUndo(tid, t) oids = self._storage.transactionalUndo(tid, t)
self._storage.tpc_vote(t) self._storage.tpc_vote(t)
self._storage.tpc_finish(t) self._storage.tpc_finish(t)
assert len(oids) == 1 eq(len(oids), 1)
assert oids[0] == oid eq(oids[0], oid)
data, revid = self._storage.load(oid, '') data, revid = self._storage.load(oid, '')
assert revid == revid_a eq(revid, revid_a)
assert zodb_unpickle(data) == MinPO(91) eq(zodb_unpickle(data), MinPO(91))
data, revid = self._storage.load(oid, version) data, revid = self._storage.load(oid, version)
assert revid > revid_b and revid > revid_c unless(revid > revid_b and revid > revid_c)
assert zodb_unpickle(data) == MinPO(92) eq(zodb_unpickle(data), MinPO(92))
# Now commit the version... # Now commit the version...
t = Transaction() t = Transaction()
self._storage.tpc_begin(t) self._storage.tpc_begin(t)
oids = self._storage.commitVersion(version, '', t) oids = self._storage.commitVersion(version, '', t)
self._storage.tpc_vote(t) self._storage.tpc_vote(t)
self._storage.tpc_finish(t) self._storage.tpc_finish(t)
assert len(oids) == 1 eq(len(oids), 1)
assert oids[0] == oid eq(oids[0], oid)
#JF# No, because we fall back to non-version data. #JF# No, because we fall back to non-version data.
#JF# self.assertRaises(POSException.VersionError, #JF# self.assertRaises(POSException.VersionError,
#JF# self._storage.load, #JF# self._storage.load,
#JF# oid, version) #JF# oid, version)
data, revid = self._storage.load(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, '') data, revid = self._storage.load(oid, '')
assert zodb_unpickle(data) == MinPO(92) eq(zodb_unpickle(data), MinPO(92))
# ...and undo the commit # ...and undo the commit
info=self._storage.undoInfo() info=self._storage.undoInfo()
tid=info[0]['id'] tid=info[0]['id']
...@@ -77,20 +79,20 @@ class TransactionalUndoVersionStorage: ...@@ -77,20 +79,20 @@ class TransactionalUndoVersionStorage:
oids = self._storage.transactionalUndo(tid, t) oids = self._storage.transactionalUndo(tid, t)
self._storage.tpc_vote(t) self._storage.tpc_vote(t)
self._storage.tpc_finish(t) self._storage.tpc_finish(t)
assert len(oids) == 1 eq(len(oids), 1)
assert oids[0] == oid eq(oids[0], oid)
data, revid = self._storage.load(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, '') data, revid = self._storage.load(oid, '')
assert zodb_unpickle(data) == MinPO(91) eq(zodb_unpickle(data), MinPO(91))
# Now abort the version # Now abort the version
t = Transaction() t = Transaction()
self._storage.tpc_begin(t) self._storage.tpc_begin(t)
oids = self._storage.abortVersion(version, t) oids = self._storage.abortVersion(version, t)
self._storage.tpc_vote(t) self._storage.tpc_vote(t)
self._storage.tpc_finish(t) self._storage.tpc_finish(t)
assert len(oids) == 1 eq(len(oids), 1)
assert oids[0] == oid eq(oids[0], oid)
# The object should not exist in the version now, but it should exist # The object should not exist in the version now, but it should exist
# in the non-version # in the non-version
#JF# No, because we fall back #JF# No, because we fall back
...@@ -98,9 +100,9 @@ class TransactionalUndoVersionStorage: ...@@ -98,9 +100,9 @@ class TransactionalUndoVersionStorage:
#JF# self._storage.load, #JF# self._storage.load,
#JF# oid, version) #JF# oid, version)
data, revid = self._storage.load(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, '') data, revid = self._storage.load(oid, '')
assert zodb_unpickle(data) == MinPO(91) eq(zodb_unpickle(data), MinPO(91))
# Now undo the abort # Now undo the abort
info=self._storage.undoInfo() info=self._storage.undoInfo()
tid=info[0]['id'] tid=info[0]['id']
...@@ -109,13 +111,13 @@ class TransactionalUndoVersionStorage: ...@@ -109,13 +111,13 @@ class TransactionalUndoVersionStorage:
oids = self._storage.transactionalUndo(tid, t) oids = self._storage.transactionalUndo(tid, t)
self._storage.tpc_vote(t) self._storage.tpc_vote(t)
self._storage.tpc_finish(t) self._storage.tpc_finish(t)
assert len(oids) == 1 eq(len(oids), 1)
assert oids[0] == oid eq(oids[0], oid)
# And the object should be back in versions 'one' and '' # And the object should be back in versions 'one' and ''
data, revid = self._storage.load(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, '') data, revid = self._storage.load(oid, '')
assert zodb_unpickle(data) == MinPO(91) eq(zodb_unpickle(data), MinPO(91))
def checkUndoCommitVersion(self): def checkUndoCommitVersion(self):
def load_value(oid, version=''): 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