Commit a06bfc03 authored by Jim Fulton's avatar Jim Fulton

Added loadEx helper function, since loadEx isn't part of the storage API.

Renamed getSerial to getTid.

Removed support for non-transactional-undo-supporting storages.
parent d343c794
...@@ -27,6 +27,16 @@ from ZODB.tests.MinPO import MinPO ...@@ -27,6 +27,16 @@ from ZODB.tests.MinPO import MinPO
from ZODB.tests.StorageTestBase import zodb_unpickle, snooze from ZODB.tests.StorageTestBase import zodb_unpickle, snooze
from ZODB import DB from ZODB import DB
def loadEx(storage, oid, version):
v = storage.modifiedInVersion(oid)
if v == version:
data, serial = storage.load(oid, version)
return data, serial, version
else:
data, serial = storage.load(oid, '')
return data, serial, ''
class VersionStorage: class VersionStorage:
def checkCommitVersionSerialno(self): def checkCommitVersionSerialno(self):
...@@ -46,7 +56,7 @@ class VersionStorage: ...@@ -46,7 +56,7 @@ class VersionStorage:
revid1 = self._dostore(oid, data=MinPO(12)) revid1 = self._dostore(oid, data=MinPO(12))
revid2 = self._dostore(oid, revid=revid1, data=MinPO(13), revid2 = self._dostore(oid, revid=revid1, data=MinPO(13),
version="version") version="version")
data, tid, ver = self._storage.loadEx(oid, "version") data, tid, ver = loadEx(self._storage, oid, "version")
self.assertEqual(revid2, tid) self.assertEqual(revid2, tid)
self.assertEqual(zodb_unpickle(data), MinPO(13)) self.assertEqual(zodb_unpickle(data), MinPO(13))
oids = self._abortVersion("version") oids = self._abortVersion("version")
...@@ -55,7 +65,7 @@ class VersionStorage: ...@@ -55,7 +65,7 @@ class VersionStorage:
# use repr() to avoid getting binary data in a traceback on error # use repr() to avoid getting binary data in a traceback on error
self.assertNotEqual(revid1, revid3) self.assertNotEqual(revid1, revid3)
self.assertNotEqual(revid2, revid3) self.assertNotEqual(revid2, revid3)
data, tid, ver = self._storage.loadEx(oid, "") data, tid = self._storage.load(oid, "")
self.assertEqual(revid3, tid) self.assertEqual(revid3, tid)
self.assertEqual(zodb_unpickle(data), MinPO(12)) self.assertEqual(zodb_unpickle(data), MinPO(12))
self.assertEqual(tid, self._storage.lastTransaction()) self.assertEqual(tid, self._storage.lastTransaction())
...@@ -80,13 +90,13 @@ class VersionStorage: ...@@ -80,13 +90,13 @@ class VersionStorage:
eq(zodb_unpickle(data), MinPO(12)) eq(zodb_unpickle(data), MinPO(12))
data, vrevid = self._storage.load(oid, version) data, vrevid = self._storage.load(oid, version)
eq(zodb_unpickle(data), MinPO(15)) eq(zodb_unpickle(data), MinPO(15))
if hasattr(self._storage, 'getSerial'): if hasattr(self._storage, 'getTid'):
s = self._storage.getSerial(oid) s = self._storage.getTid(oid)
eq(s, max(revid, vrevid)) eq(s, max(revid, vrevid))
data, tid, ver = self._storage.loadEx(oid, version) data, tid, ver = loadEx(self._storage, oid, version)
eq(zodb_unpickle(data), MinPO(15)) eq(zodb_unpickle(data), MinPO(15))
eq(tid, revid2) eq(tid, revid2)
data, tid, ver = self._storage.loadEx(oid, "other version") data, tid, ver = loadEx(self._storage, oid, "other version")
eq(zodb_unpickle(data), MinPO(12)) eq(zodb_unpickle(data), MinPO(12))
eq(tid, revid2) eq(tid, revid2)
# loadSerial returns non-version data # loadSerial returns non-version data
...@@ -186,7 +196,7 @@ class VersionStorage: ...@@ -186,7 +196,7 @@ class VersionStorage:
eq = self.assertEqual eq = self.assertEqual
oid, version = self._setup_version() oid, version = self._setup_version()
# Not sure I can write a test for getSerial() in the # Not sure I can write a test for getTid() in the
# presence of aborted versions, because FileStorage and # presence of aborted versions, because FileStorage and
# Berkeley storage give a different answer. I think Berkeley # Berkeley storage give a different answer. I think Berkeley
# is right and FS is wrong. # is right and FS is wrong.
...@@ -202,7 +212,7 @@ class VersionStorage: ...@@ -202,7 +212,7 @@ class VersionStorage:
# after a version is aborted. # after a version is aborted.
oid, version = self._setup_version() oid, version = self._setup_version()
self._abortVersion(version) self._abortVersion(version)
data, tid, ver = self._storage.loadEx(oid, "") data, tid, ver = loadEx(self._storage, oid, "")
# write a new revision of oid so that the aborted-version txn # write a new revision of oid so that the aborted-version txn
# is not current # is not current
self._dostore(oid, revid=tid, data=MinPO(17)) self._dostore(oid, revid=tid, data=MinPO(17))
...@@ -219,8 +229,6 @@ class VersionStorage: ...@@ -219,8 +229,6 @@ class VersionStorage:
self._storage.tpc_begin(t) self._storage.tpc_begin(t)
# And try to abort the empty version # And try to abort the empty version
if (hasattr(self._storage, 'supportsTransactionalUndo') and
self._storage.supportsTransactionalUndo()):
self.assertRaises(POSException.VersionError, self.assertRaises(POSException.VersionError,
self._storage.abortVersion, self._storage.abortVersion,
'', t) '', t)
...@@ -235,9 +243,6 @@ class VersionStorage: ...@@ -235,9 +243,6 @@ class VersionStorage:
eq(zodb_unpickle(data), MinPO(51)) eq(zodb_unpickle(data), MinPO(51))
def checkCommitVersionErrors(self): def checkCommitVersionErrors(self):
if not (hasattr(self._storage, 'supportsTransactionalUndo') and
self._storage.supportsTransactionalUndo()):
return
eq = self.assertEqual eq = self.assertEqual
oid1, version1 = self._setup_version('one') oid1, version1 = self._setup_version('one')
data, revid1 = self._storage.load(oid1, version1) data, revid1 = self._storage.load(oid1, version1)
......
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