[Zodb-checkins] CVS: Zope2/lib/python/ZODB - BasicStorage.py:1.2

barry@digicool.com barry@digicool.com
Wed, 11 Apr 2001 18:02:16 -0400 (EDT)


Update of /cvs-repository/Zope2/lib/python/ZODB/tests
In directory korak:/tmp/cvs-serv2726

Modified Files:
	BasicStorage.py 
Log Message:
More factorizing for better mixin usage.

_dostore(), setUp(), _close(), tearDown(): Moved out of this class and
into StorageTestBase.



--- Updated File BasicStorage.py in package Zope2/lib/python/ZODB --
--- BasicStorage.py	2001/04/10 20:45:58	1.1
+++ BasicStorage.py	2001/04/11 22:02:15	1.2
@@ -1,21 +1,18 @@
+# Run the basic tests for a storage as described in the official storage API:
+#
+# http://www.zope.org/Documentation/Developer/Models/ZODB/ZODB_Architecture_Storage_Interface_Info.html
+#
+# All storages should be able to pass these tests
+
 from ZODB.Transaction import Transaction
-ZERO = '\0'*8
-import pickle
 from ZODB import POSException
-
-class BasicStorage:
 
-    def setUp(self):
-        # You need to override this with a setUp that creates self._storage
-        self._transaction = Transaction()
-
-    def _close(self):
-        self._transaction.abort()
-        self._storage.close()
+ZERO = '\0'*8
+import pickle
 
-    def tearDown(self):
-        self._close()
 
+
+class BasicStorage:
     def checkBasics(self):
         self._storage.tpc_begin(self._transaction)
         # This should simply return
@@ -43,28 +40,6 @@
             0, 1, 2, 3, Transaction())
         self._storage.tpc_abort(self._transaction)
 
-    def _dostore(self, oid=None, revid=None, data=None, version=None):
-        # Defaults
-        if oid is None:
-            oid = self._storage.new_oid()
-        if revid is None:
-            revid = ZERO
-        if data is None:
-            data = pickle.dumps(7)
-        else:
-            data = pickle.dumps(data)
-        if version is None:
-            version = ''
-        # Begin the transaction
-        self._storage.tpc_begin(self._transaction)
-        # Store an object
-        newrevid = self._storage.store(oid, revid, data, version,
-                                       self._transaction)
-        # Finish the transaction
-        self._storage.tpc_vote(self._transaction)
-        self._storage.tpc_finish(self._transaction)
-        return newrevid
-        
     def checkNonVersionStore(self, oid=None, revid=None, version=None):
         revid = ZERO
         newrevid = self._dostore(revid=revid)