[Zope-CVS] CVS: Products/AdaptableStorage/gateway_sql/tests - testInterfaceImpl.py:1.2 testZope2SQL.py:1.3

Shane Hathaway shane@zope.com
Mon, 23 Dec 2002 23:30:03 -0500


Update of /cvs-repository/Products/AdaptableStorage/gateway_sql/tests
In directory cvs.zope.org:/tmp/cvs-serv30532/gateway_sql/tests

Modified Files:
	testInterfaceImpl.py testZope2SQL.py 
Log Message:
Provided a way to configure ObjectMappers, with the intent of making
AdaptableStorage easier to explain.  Added IConfigurableObjectMapper
and converted all the mapper setup code to use it.  Included a
checkConfiguration() method which validates the entire object mapper
tree.  Then converted the DBTab-based configuration to use a mapper
factory, which can point to any mapper factory function installed
anywhere.  Tangents to this:

- Refactored Zope2FS and Zope2SQL to use the same code for setting up
mappers, leaving "holes" for the gateways.

- Added connect() and close() methods to ITPCConnection (which doesn't
technically exist yet since I need to choose a name for it. ;-) )

- Factored out common parts of the SQL gateways.

- Implemented the newKey() method of IKeyedObjectSystem, which will
help ZEO environments, in theory.



=== Products/AdaptableStorage/gateway_sql/tests/testInterfaceImpl.py 1.1 => 1.2 ===
--- Products/AdaptableStorage/gateway_sql/tests/testInterfaceImpl.py:1.1	Tue Dec 10 17:51:37 2002
+++ Products/AdaptableStorage/gateway_sql/tests/testInterfaceImpl.py	Mon Dec 23 23:29:32 2002
@@ -28,11 +28,7 @@
     def _testObjectImpl(self, c):
         try:
             impl = c.__implements__
-            if isinstance(impl, ListType) or isinstance(impl, TupleType):
-                for iface in impl:
-                    self._verify(iface, c)
-            else:
-                self._verify(impl, c)
+            self._verify(impl, c)
         except:
             print 'Bad implementation of', repr(c)
             raise
@@ -44,9 +40,13 @@
                 self._testObjectImpl(value)
 
     def _verify(self, iface, c):
-        verifyClass(iface, c)
-        for base in iface.getBases():
-            self._verify(base, c)
+        if isinstance(iface, ListType) or isinstance(iface, TupleType):
+            for item in iface:
+                self._verify(item, c)
+        else:
+            verifyClass(iface, c)
+            for base in iface.getBases():
+                self._verify(base, c)
 
     def testSerialPublicImplementations(self):
         from Products.AdaptableStorage.gateway_sql import public


=== Products/AdaptableStorage/gateway_sql/tests/testZope2SQL.py 1.2 => 1.3 ===
--- Products/AdaptableStorage/gateway_sql/tests/testZope2SQL.py:1.2	Tue Dec 10 17:27:00 2002
+++ Products/AdaptableStorage/gateway_sql/tests/testZope2SQL.py	Mon Dec 23 23:29:32 2002
@@ -27,7 +27,7 @@
 from Products.AdaptableStorage.zodb.ASDB import ASDB
 from Products.AdaptableStorage.zodb.ASStorage import ASStorage
 from Products.AdaptableStorage.zodb.StaticResource import StaticResource
-from Products.AdaptableStorage.Zope2SQL import createMapper
+from Products.AdaptableStorage.Zope2SQL import createMapperPlus
 
 
 class TestFolder(Folder):
@@ -49,12 +49,12 @@
 class Zope2SQLTests (unittest.TestCase):
 
     def setUp(self):
-        dm, conn, gws = createMapper('', 'test_temp')
+        dm, conns, gws = createMapperPlus('', 'test_temp')
         self.dm = dm
-        self.conn = conn
+        self.conns = conns
         self.gws = gws
         resource = StaticResource(dm)
-        storage = ASStorage(resource, [conn])
+        storage = ASStorage(resource, conns)
         self.storage = storage
         db = ASDB(storage, resource)
         self.db = db
@@ -63,11 +63,11 @@
         for gw in self.gws:
             if hasattr(gw, 'clear'):
                 gw.clear()
-                self.conn.db.commit()
+        for conn in self.conns:
+            conn.db.commit()
 
     def tearDown(self):
-        if 1:
-            self.clear()
+        self.clear()
         self.db.close()
 
     def testLoad(self):