[Zodb-checkins] CVS: Packages/bsddb3Storage - test_storage_api.py:1.7

barry@digicool.com barry@digicool.com
Mon, 9 Apr 2001 18:30:42 -0400 (EDT)


Update of /cvs-repository/Packages/bsddb3Storage/test
In directory korak:/tmp/cvs-serv19809

Modified Files:
	test_storage_api.py 
Log Message:
_close(): Abort whatever transaction might still be active.  Maybe
this fixes the Windows crashes?

checkSimpleTransactionalUndo(): Modify tests to check zombification
and subsequent re-birth of objects via transactionalUndo().



--- Updated File test_storage_api.py in package Packages/bsddb3Storage --
--- test_storage_api.py	2001/04/06 18:47:12	1.6
+++ test_storage_api.py	2001/04/09 22:30:41	1.7
@@ -31,6 +31,7 @@
         self._transaction = Transaction()
 
     def _close(self):
+        self._transaction.abort()
         self._storage.close()
 
     def checkBasics(self):
@@ -381,12 +382,33 @@
         assert oids[0] == oid
         data, revid = self._storage.load(oid, '')
         assert pickle.loads(data) == 23
-        # Can't undo the first record
+        # Try to undo the first record
         self._storage.tpc_begin(self._transaction)
-        self.assertRaises(POSException.UndoError,
-                          self._storage.transactionalUndo,
-                          revid, self._transaction)
-        self._storage.tpc_abort(self._transaction)
+        oids = self._storage.transactionalUndo(revid, self._transaction)
+        self._storage.tpc_vote(self._transaction)
+        self._storage.tpc_finish(self._transaction)
+        assert len(oids) == 1
+        assert oids[0] == oid
+        # This should fail since we've undone the object's creation
+        self.assertRaises(KeyError,
+                          self._storage.load, oid, '')
+        # But it's really a more specific type of error
+        import Full
+        self.assertRaises(Full.ObjectDoesNotExist,
+                          self._storage.load, oid, '')
+        # And now let's try to redo the object's creation
+        try:
+            self._storage.load(oid, '')
+        except Full.ObjectDoesNotExist, e:
+            revid = e.revid
+        self._storage.tpc_begin(self._transaction)
+        oids = self._storage.transactionalUndo(revid, self._transaction)
+        self._storage.tpc_vote(self._transaction)
+        self._storage.tpc_finish(self._transaction)
+        assert len(oids) == 1
+        assert oids[0] == oid
+        data, revid = self._storage.load(oid, '')
+        assert pickle.loads(data) == 23
 
     def checkTwoObjectUndo(self):
         # Convenience