[Zodb-checkins] CVS: Zope3/src/zodb/storage/tests - basic.py:1.5.4.1 iterator.py:1.3.4.1 readonly.py:1.3.4.1 synchronization.py:1.3.4.1 test_file.py:1.5.4.1 test_storage_api.py:1.5.4.1 version.py:1.2.8.1

Jeremy Hylton jeremy@zope.com
Tue, 4 Feb 2003 17:54:50 -0500


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

Modified Files:
      Tag: storage-interface-branch
	basic.py iterator.py readonly.py synchronization.py 
	test_file.py test_storage_api.py version.py 
Log Message:
Refactor storage interfaces.

Move a bunch of exceptions related to storages from zodb.interfaces to
zodb.storages.interfaces.

Add __implements__ statements in all the concrete storage classes.

Add a simple (good?) mechanism to propagate __implements__ values from
a ZEO storage to its clients.

Remove all use of supportsXXX() methods in favor of
ISomeInterface.isImplementedBy().


=== Zope3/src/zodb/storage/tests/basic.py 1.5 => 1.5.4.1 ===
--- Zope3/src/zodb/storage/tests/basic.py:1.5	Mon Jan 27 11:08:23 2003
+++ Zope3/src/zodb/storage/tests/basic.py	Tue Feb  4 17:54:13 2003
@@ -23,16 +23,19 @@
 """
 
 from zodb import interfaces
+from zodb.storage.interfaces import StorageTransactionError, IStorage
 from zodb.ztransaction import Transaction
 
 from zodb.storage.base import ZERO
 from zodb.storage.tests.minpo import MinPO
-from zodb.storage.tests.base \
-     import zodb_unpickle, zodb_pickle, handle_serials
-
+from zodb.storage.tests.base import zodb_unpickle, zodb_pickle, handle_serials
 
 
 class BasicStorage:
+
+    def checkIStorage(self):
+        self.assert_(IStorage.isImplementedBy(self._storage))
+    
     def checkDatabaseVersion(self):
         version = "abcd"
         self._storage.setVersion(version)
@@ -55,31 +58,25 @@
         # Test a few expected exceptions when we're doing operations giving a
         # different Transaction object than the one we've begun on.
         self._storage.tpc_begin(t)
-        self.assertRaises(
-            interfaces.StorageTransactionError,
-            self._storage.store,
-            0, 0, 0, 0, Transaction())
+        self.assertRaises(StorageTransactionError, self._storage.store,
+                          0, 0, 0, 0, Transaction())
 
         try:
             self._storage.abortVersion('dummy', Transaction())
-        except (interfaces.StorageTransactionError,
-                interfaces.VersionCommitError):
+        except (StorageTransactionError, interfaces.VersionCommitError):
             pass # test passed ;)
         else:
             assert 0, "Should have failed, invalid transaction."
 
         try:
             self._storage.commitVersion('dummy', 'dummer', Transaction())
-        except (interfaces.StorageTransactionError,
-                interfaces.VersionCommitError):
+        except (StorageTransactionError, interfaces.VersionCommitError):
             pass # test passed ;)
         else:
             assert 0, "Should have failed, invalid transaction."
 
-        self.assertRaises(
-            interfaces.StorageTransactionError,
-            self._storage.store,
-            0, 1, 2, 3, Transaction())
+        self.assertRaises(StorageTransactionError, self._storage.store,
+                          0, 1, 2, 3, Transaction())
         self._storage.tpc_abort(t)
 
     def checkSerialIsNoneForInitialRevision(self):


=== Zope3/src/zodb/storage/tests/iterator.py 1.3 => 1.3.4.1 ===
--- Zope3/src/zodb/storage/tests/iterator.py:1.3	Wed Jan 22 15:10:04 2003
+++ Zope3/src/zodb/storage/tests/iterator.py	Tue Feb  4 17:54:13 2003
@@ -21,7 +21,7 @@
 from zodb.ztransaction import Transaction
 from zodb.storage.tests.minpo import MinPO
 from zodb.storage.tests.base import zodb_unpickle
-
+from zodb.storage.interfaces import IUndoStorage
 
 
 class IteratorCompare:
@@ -59,7 +59,7 @@
         self.assertRaises(IOError, txniter.__getitem__, 0)
 
     def checkVersionIterator(self):
-        if not self._storage.supportsVersions():
+        if not IUndoStorage.isImplementedBy(self._storage):
             return
         self._dostore()
         self._dostore(version='abort')
@@ -86,9 +86,7 @@
                 pass
 
     def checkUndoZombieNonVersion(self):
-        if not hasattr(self._storage, 'supportsTransactionalUndo'):
-            return
-        if not self._storage.supportsTransactionalUndo():
+        if not IUndoStorage.isImplementedBy(self._storage):
             return
 
         oid = self._storage.new_oid()


=== Zope3/src/zodb/storage/tests/readonly.py 1.3 => 1.3.4.1 ===
--- Zope3/src/zodb/storage/tests/readonly.py:1.3	Wed Jan 22 15:25:51 2003
+++ Zope3/src/zodb/storage/tests/readonly.py	Tue Feb  4 17:54:13 2003
@@ -13,7 +13,7 @@
 ##############################################################################
 
 from zodb.storage.base import ZERO
-from zodb.interfaces import ReadOnlyError
+from zodb.storage.interfaces import ReadOnlyError, IUndoStorage
 from zodb.ztransaction import Transaction
 
 class ReadOnlyStorage:
@@ -53,6 +53,6 @@
         self.assertRaises(ReadOnlyError, self._storage.store,
                           ZERO, None, '', '', t)
 
-        if self._storage.supportsTransactionalUndo():
+        if IUndoStorage.isImplementedBy(self._storage):
             self.assertRaises(ReadOnlyError, self._storage.transactionalUndo,
                               ZERO, t)


=== Zope3/src/zodb/storage/tests/synchronization.py 1.3 => 1.3.4.1 ===
--- Zope3/src/zodb/storage/tests/synchronization.py:1.3	Wed Jan 22 15:38:25 2003
+++ Zope3/src/zodb/storage/tests/synchronization.py	Tue Feb  4 17:54:13 2003
@@ -62,7 +62,7 @@
 
 from zodb.storage.base import ZERO
 from zodb.ztransaction import Transaction
-from zodb.interfaces import StorageTransactionError
+from zodb.storage.interfaces import StorageTransactionError
 
 VERSION = "testversion"
 OID = ZERO


=== Zope3/src/zodb/storage/tests/test_file.py 1.5 => 1.5.4.1 ===
--- Zope3/src/zodb/storage/tests/test_file.py:1.5	Mon Feb  3 18:00:44 2003
+++ Zope3/src/zodb/storage/tests/test_file.py	Tue Feb  4 17:54:13 2003
@@ -15,7 +15,7 @@
 import sys, os, unittest
 import errno
 from zodb.ztransaction import Transaction
-from zodb import interfaces
+from zodb.storage.interfaces import *
 
 from zodb.storage.tests import base, basic, conflict, corruption, history, \
      iterator, mt, packable, persistent, readonly, recovery, revision, \
@@ -75,13 +75,13 @@
         s = "X" * 75000
         try:
             self._dostore(user=s)
-        except interfaces.StorageError:
+        except StorageError:
             pass
         else:
             self.fail("expect long user field to raise error")
         try:
             self._dostore(description=s)
-        except interfaces.StorageError:
+        except StorageError:
             pass
         else:
             self.fail("expect long user field to raise error")


=== Zope3/src/zodb/storage/tests/test_storage_api.py 1.5 => 1.5.4.1 ===
--- Zope3/src/zodb/storage/tests/test_storage_api.py:1.5	Mon Feb  3 18:00:44 2003
+++ Zope3/src/zodb/storage/tests/test_storage_api.py	Tue Feb  4 17:54:13 2003
@@ -37,7 +37,7 @@
     def checkVersionedStoreAndLoad(self):
         # This storage doesn't support versions, so we should get an exception
         oid = self._storage.new_oid()
-        self.assertRaises(interfaces.Unsupported,
+        self.assertRaises(NotImplementedError,
                           self._dostore,
                           oid, data=11, version='a version')
 


=== Zope3/src/zodb/storage/tests/version.py 1.2 => 1.2.8.1 ===
--- Zope3/src/zodb/storage/tests/version.py:1.2	Wed Dec 25 09:12:20 2002
+++ Zope3/src/zodb/storage/tests/version.py	Tue Feb  4 17:54:13 2003
@@ -20,9 +20,14 @@
 from zodb.ztransaction import Transaction
 from zodb.storage.tests.minpo import MinPO
 from zodb.storage.tests.base import zodb_unpickle
+from zodb.storage.interfaces import IUndoStorage, IVersionStorage
 
 
 class VersionStorage:
+
+    def checkIVersionStorage(self):
+        self.assert_(IVersionStorage.isImplementedBy(self._storage))
+    
     def checkVersionedStoreAndLoad(self):
         eq = self.assertEqual
         # Store a couple of non-version revisions of the object
@@ -163,9 +168,7 @@
         self._storage.tpc_begin(t)
 
         # And try to abort the empty version
-        if (hasattr(self._storage, 'supportsTransactionalUndo')
-            and self._storage.supportsTransactionalUndo()):
-            # XXX FileStorage used to be broken on this one
+        if IUndoStorage.isImplementedBy(self._storage):
             self.assertRaises(interfaces.VersionError,
                               self._storage.abortVersion,
                               '', t)