[Zope-CVS] CVS: Products/Ape/lib/apelib/tests - serialtestbase.py:1.3

Shane Hathaway shane@zope.com
Mon, 26 May 2003 14:16:03 -0400


Update of /cvs-repository/Products/Ape/lib/apelib/tests
In directory cvs.zope.org:/tmp/cvs-serv3065

Modified Files:
	serialtestbase.py 
Log Message:
Oops!  The simplified unit test mapper was not fully configured and
nothing ever called checkConfiguration().  The configuration is now
complete and verified.  Also simplified the imports.



=== Products/Ape/lib/apelib/tests/serialtestbase.py 1.2 => 1.3 ===
--- Products/Ape/lib/apelib/tests/serialtestbase.py:1.2	Tue Apr 29 18:11:51 2003
+++ Products/Ape/lib/apelib/tests/serialtestbase.py	Mon May 26 14:16:02 2003
@@ -20,12 +20,10 @@
 from Persistence import PersistentMapping
 from cPickle import dumps, loads
 
-from apelib.core.classifiers import FixedClassifier
+from apelib.core \
+     import classifiers, gateways, keygen, mapper, schemas, serializers
 from apelib.core.interfaces import ISerializer
-from apelib.core.gateways import CompositeGateway, MappingGateway
-from apelib.core.mapper import Mapper
-from apelib.core.schemas import RowSequenceSchema
-from apelib.core.serializers import CompositeSerializer, StringDataAttribute
+
 from apelib.zodb3.serializers \
      import FixedPersistentMapping, RollCall, RemainingState
 
@@ -34,7 +32,7 @@
 
     __implements__ = ISerializer
 
-    schema = RowSequenceSchema()
+    schema = schemas.RowSequenceSchema()
     schema.addField('name')
     schema.addField('pickle')
 
@@ -65,57 +63,67 @@
     def setUp(self):
         self.conns = {}
 
-        classifier = FixedClassifier()
-        classifier.register('test', 'test_mapper')
-        classifier.register('test2', 'test_mapper_2')
+        cfr = classifiers.FixedClassifier()
+        cfr.register('test', 'test_mapper')
+        cfr.register('test2', 'test_mapper_2')
 
-        ser2 = CompositeSerializer('Persistence', 'PersistentMapping')
+        ser2 = serializers.CompositeSerializer(
+            'Persistence', 'PersistentMapping')
         fixed_items_serializer = FixedPersistentMapping()
         fixed_items_serializer.add('TestRoot', ('test',), ('test_mapper',))
         fixed_items_serializer.add('TestRoot2', ('test2',), ('test_mapper_2',))
         ser2.addSerializer('fixed_items', fixed_items_serializer)
         ser2.addSerializer('roll_call', RollCall())
 
-        root_mapper = Mapper(None, ser2, CompositeGateway(), classifier)
+        root_mapper = mapper.Mapper(
+            None, ser2, gateways.CompositeGateway(), cfr)
         self.root_mapper = root_mapper
+        # Since all of the keychains used by this mapper are fixed, we
+        # don't want any keychains to be generated.
+        root_mapper.setKeychainGenerator(keygen.NullKeychainGenerator())
 
         # Create "test_mapper", which allows a "strdata" attribute.
 
-        ser1 = CompositeSerializer('Persistence', 'PersistentMapping')
+        ser1 = serializers.CompositeSerializer(
+            'Persistence', 'PersistentMapping')
         items_serializer = SimpleItemsSerializer()
         ser1.addSerializer('items', items_serializer)
-        props_serializer = StringDataAttribute('strdata')
+        props_serializer = serializers.StringDataAttribute('strdata')
         ser1.addSerializer('properties', props_serializer)
         ser1.addSerializer('roll_call', RollCall())
 
-        gw1 = CompositeGateway()
-        items_gw = MappingGateway(items_serializer.getSchema())
+        gw1 = gateways.CompositeGateway()
+        items_gw = gateways.MappingGateway(items_serializer.getSchema())
         self.items_gw = items_gw
         gw1.addGateway('items', items_gw)
-        props_gw = MappingGateway(props_serializer.getSchema())
+        props_gw = gateways.MappingGateway(props_serializer.getSchema())
         self.props_gw = props_gw
         gw1.addGateway('properties', props_gw)
 
-        om1 = Mapper(root_mapper, ser1, gw1)
+        om1 = mapper.Mapper(root_mapper, ser1, gw1)
         self.om1 = om1
         root_mapper.addSubMapper('test_mapper', om1)
 
         # Create "test_mapper_2", which stores a remainder.
 
-        ser = CompositeSerializer('Persistence', 'PersistentMapping')
+        ser = serializers.CompositeSerializer(
+            'Persistence', 'PersistentMapping')
         items_serializer = SimpleItemsSerializer()
         ser.addSerializer('items', items_serializer)
         remainder_serializer = RemainingState()
         ser.addSerializer('remainder', remainder_serializer)
 
-        gw = CompositeGateway()
-        items_gw = MappingGateway(items_serializer.getSchema())
+        gw = gateways.CompositeGateway()
+        items_gw = gateways.MappingGateway(items_serializer.getSchema())
         gw.addGateway('items', items_gw)
-        remainder_gw = MappingGateway(remainder_serializer.getSchema())
+        remainder_gw = gateways.MappingGateway(
+            remainder_serializer.getSchema())
         gw.addGateway('remainder', remainder_gw)
 
-        om = Mapper(root_mapper, ser, gw)
+        om = mapper.Mapper(root_mapper, ser, gw)
         root_mapper.addSubMapper('test_mapper_2', om)
+
+        root_mapper.checkConfiguration()
 
 
     def tearDown(self):