[Zope3-checkins] CVS: Zope3/src/zodb/storage/tests - basic.py:1.11

Barry Warsaw barry@zope.com
Thu, 10 Jul 2003 13:41:53 -0400


Update of /cvs-repository/Zope3/src/zodb/storage/tests
In directory cvs.zope.org:/tmp/cvs-serv27514

Modified Files:
	basic.py 
Log Message:
Better coverage for lastTransaction() by moving the most common usage
into the BaseStorage class.  Since this method is required by
IStorage, and most implementations do it the same way, it makes
sense.

New tests: testLastTransactionBeforeFirstTransaction() and
testLastTransaction()


=== Zope3/src/zodb/storage/tests/basic.py 1.10 => 1.11 ===
--- Zope3/src/zodb/storage/tests/basic.py:1.10	Thu Jun 19 17:41:09 2003
+++ Zope3/src/zodb/storage/tests/basic.py	Thu Jul 10 13:41:49 2003
@@ -214,3 +214,27 @@
         for k,v in m.items():
             self.assertEqual(v,None)
             self.assert_(callable(getattr(self._storage,k)))
+
+    def testLastTransactionBeforeFirstTransaction(self):
+        self.assertEqual(self._storage.lastTransaction(), ZERO)
+
+    def testLastTransaction(self):
+        eq = self.assertEqual
+        unless = self.failUnless
+        revid = self._dostore()
+        last = self._storage.lastTransaction()
+        eq(revid, last)
+        revid = self._dostore()
+        nextlast = self._storage.lastTransaction()
+        eq(revid, nextlast)
+        unless(nextlast > last)
+        # Start a transaction, abort it, and make sure the last committed
+        # transaction id doesn't change.
+        t = Transaction()
+        oid = self._storage.newObjectId()
+        self._storage.tpcBegin(t)
+        data, refs = zodb_pickle(MinPO(5))
+        self._storage.store(oid, ZERO, data, refs, '', t)
+        # Now abort this transaction
+        self._storage.tpcAbort(t)
+        eq(nextlast, self._storage.lastTransaction())