Commit d19e7d6f authored by Jim Fulton's avatar Jim Fulton

Work with storages that don't support versions.

Renamed getSerial to getTid.

Removed silly getExtensionMethods test. getExtensionMethods is not
part of the storage API.
parent 291a61ef
...@@ -28,8 +28,6 @@ import transaction ...@@ -28,8 +28,6 @@ import transaction
ZERO = '\0'*8 ZERO = '\0'*8
class BasicStorage: class BasicStorage:
def checkBasics(self): def checkBasics(self):
t = transaction.Transaction() t = transaction.Transaction()
...@@ -46,8 +44,10 @@ class BasicStorage: ...@@ -46,8 +44,10 @@ class BasicStorage:
self._storage.store, self._storage.store,
0, 0, 0, 0, transaction.Transaction()) 0, 0, 0, 0, transaction.Transaction())
if self.__supportsVersions():
try: try:
self._storage.abortVersion('dummy', transaction.Transaction()) self._storage.abortVersion(
'dummy', transaction.Transaction())
except (POSException.StorageTransactionError, except (POSException.StorageTransactionError,
POSException.VersionCommitError): POSException.VersionCommitError):
pass # test passed ;) pass # test passed ;)
...@@ -69,6 +69,15 @@ class BasicStorage: ...@@ -69,6 +69,15 @@ class BasicStorage:
0, 1, 2, 3, transaction.Transaction()) 0, 1, 2, 3, transaction.Transaction())
self._storage.tpc_abort(t) self._storage.tpc_abort(t)
def __supportsVersions(self):
storage = self._storage
try:
supportsVersions = storage.supportsVersions
except AttributeError:
return False
else:
return supportsVersions()
def checkSerialIsNoneForInitialRevision(self): def checkSerialIsNoneForInitialRevision(self):
eq = self.assertEqual eq = self.assertEqual
oid = self._storage.new_oid() oid = self._storage.new_oid()
...@@ -107,6 +116,7 @@ class BasicStorage: ...@@ -107,6 +116,7 @@ class BasicStorage:
eq(zodb_unpickle(data), MinPO(21)) eq(zodb_unpickle(data), MinPO(21))
def checkNonVersionModifiedInVersion(self): def checkNonVersionModifiedInVersion(self):
if self.__supportsVersions():
oid = self._storage.new_oid() oid = self._storage.new_oid()
self._dostore(oid=oid) self._dostore(oid=oid)
self.assertEqual(self._storage.modifiedInVersion(oid), '') self.assertEqual(self._storage.modifiedInVersion(oid), '')
...@@ -161,19 +171,19 @@ class BasicStorage: ...@@ -161,19 +171,19 @@ class BasicStorage:
revid4 = self._dostore(oid2, revid=revid2, data=p52) revid4 = self._dostore(oid2, revid=revid2, data=p52)
noteq(revid3, revid4) noteq(revid3, revid4)
def checkGetSerial(self): def checkGetTid(self):
if not hasattr(self._storage, 'getSerial'): if not hasattr(self._storage, 'getTid'):
return return
eq = self.assertEqual eq = self.assertEqual
p41, p42 = map(MinPO, (41, 42)) p41, p42 = map(MinPO, (41, 42))
oid = self._storage.new_oid() oid = self._storage.new_oid()
self.assertRaises(KeyError, self._storage.getSerial, oid) self.assertRaises(KeyError, self._storage.getTid, oid)
# Now store a revision # Now store a revision
revid1 = self._dostore(oid, data=p41) revid1 = self._dostore(oid, data=p41)
eq(revid1, self._storage.getSerial(oid)) eq(revid1, self._storage.getTid(oid))
# And another one # And another one
revid2 = self._dostore(oid, revid=revid1, data=p42) revid2 = self._dostore(oid, revid=revid1, data=p42)
eq(revid2, self._storage.getSerial(oid)) eq(revid2, self._storage.getTid(oid))
def checkTwoArgBegin(self): def checkTwoArgBegin(self):
# Unsure: how standard is three-argument tpc_begin()? # Unsure: how standard is three-argument tpc_begin()?
...@@ -212,10 +222,3 @@ class BasicStorage: ...@@ -212,10 +222,3 @@ class BasicStorage:
self._storage.store(oid, ZERO, zodb_pickle(MinPO(5)), '', t) self._storage.store(oid, ZERO, zodb_pickle(MinPO(5)), '', t)
self._storage.tpc_vote(t) self._storage.tpc_vote(t)
self._storage.tpc_finish(t) self._storage.tpc_finish(t)
def checkGetExtensionMethods(self):
m = self._storage.getExtensionMethods()
self.assertEqual(type(m),type({}))
for k,v in m.items():
self.assertEqual(v,None)
self.assert_(callable(getattr(self._storage,k)))
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