[Zodb-checkins] CVS: ZODB3/ZODB/tests - VersionStorage.py:1.15
Jim Fulton
jim@zope.com
Wed, 28 Aug 2002 09:28:18 -0400
Update of /cvs-repository/ZODB3/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv24587/ZODB/tests
Modified Files:
VersionStorage.py
Log Message:
Added a test to check that abortVersion and commitVersion assign new
serials. Modified FileStorage and DemoStorage to pass this test.
=== ZODB3/ZODB/tests/VersionStorage.py 1.14 => 1.15 ===
--- ZODB3/ZODB/tests/VersionStorage.py:1.14 Wed Aug 14 18:07:09 2002
+++ ZODB3/ZODB/tests/VersionStorage.py Wed Aug 28 09:28:17 2002
@@ -206,6 +206,71 @@
finally:
self._storage.tpc_abort(t)
+
+ def checkNewSerialOnAbortVersion(self):
+ eq = self.assertEqual
+ oid, version = self._setup_version()
+ data, vserial = self._storage.load(oid, version)
+ data, nserial = self._storage.load(oid, '')
+
+ # 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)
+
+ # Now check the new serial
+ data, serial = self._storage.load(oid, version)
+
+ self.failUnless(serial != vserial and serial != nserial,
+ "New serial, %r, should be different from the old "
+ "version, %r, and non-version, %r, serials."
+ % (serial, vserial, nserial))
+
+ def checkNewSerialOnCommitVersion(self):
+ eq = self.assertEqual
+ oid, version = self._setup_version()
+ data, vserial = self._storage.load(oid, version)
+ data, nserial = self._storage.load(oid, '')
+
+ # 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)
+
+ # Now check the new serial
+ data, serial = self._storage.load(oid, '')
+
+ self.failUnless(serial != vserial and serial != nserial,
+ "New serial, %r, should be different from the old "
+ "version, %r, and non-version, %r, serials."
+ % (serial, vserial, nserial))
+
+ def checkNewSerialOnCommitVersionToVersion(self):
+ eq = self.assertEqual
+ oid, version = self._setup_version()
+ data, vserial = self._storage.load(oid, version)
+ data, nserial = self._storage.load(oid, '')
+
+ # Now commit the version
+ t = Transaction()
+ self._storage.tpc_begin(t)
+ version2 = 'test version 2'
+ oids = self._storage.commitVersion(version, version2, t)
+ self._storage.tpc_vote(t)
+ self._storage.tpc_finish(t)
+
+ # Now check the new serial
+ data, serial = self._storage.load(oid, version2)
+
+ self.failUnless(serial != vserial and serial != nserial,
+ "New serial, %r, should be different from the old "
+ "version, %r, and non-version, %r, serials."
+ % (serial, vserial, nserial))
+
def checkModifyAfterAbortVersion(self):
eq = self.assertEqual
oid, version = self._setup_version()