[Zope-CVS] CVS: Products/Ape/lib/apelib/tests - serialtestbase.py:1.3.6.3 testserialization.py:1.5.2.3 teststorage.py:1.5.2.3 testzope2fs.py:1.4.4.3 zope2testbase.py:1.5.2.1

Shane Hathaway shane at zope.com
Sat Dec 20 23:24:37 EST 2003


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

Modified Files:
      Tag: ape-0_8-branch
	serialtestbase.py testserialization.py teststorage.py 
	testzope2fs.py zope2testbase.py 
Log Message:
Continued cleanup after refactoring the interfaces.  See CHANGES.txt.

All tests now pass except for the SQL tests.



=== Products/Ape/lib/apelib/tests/serialtestbase.py 1.3.6.2 => 1.3.6.3 ===
--- Products/Ape/lib/apelib/tests/serialtestbase.py:1.3.6.2	Sat Dec 20 02:31:07 2003
+++ Products/Ape/lib/apelib/tests/serialtestbase.py	Sat Dec 20 23:24:05 2003
@@ -20,7 +20,7 @@
 from Persistence import PersistentMapping
 from cPickle import dumps, loads
 
-from apelib.core import classifiers, gateways, io
+from apelib.core import classifiers, gateways
 from apelib.core import mapper, oidgen, schemas, serializers
 
 from apelib.zodb3.serializers import StringToPersistentPM, StringToPicklePM
@@ -50,7 +50,7 @@
         schema = schemas.FieldSchema("classification", "classification")
         cfr = classifiers.SimpleClassifier(gateways.RAMGateway(schema))
         oid_gen = oidgen.SerialOIDGenerator()
-        self.conf = io.MapperConfiguration({}, cfr, oid_gen)
+        self.conf = mapper.MapperConfiguration({}, cfr, oid_gen)
 
         m = addMapper(self.conf, PersistentMapping, "pm")
         m.serializer.add("items", StringToPersistentPM())


=== Products/Ape/lib/apelib/tests/testserialization.py 1.5.2.2 => 1.5.2.3 ===
--- Products/Ape/lib/apelib/tests/testserialization.py:1.5.2.2	Sat Dec 20 02:31:07 2003
+++ Products/Ape/lib/apelib/tests/testserialization.py	Sat Dec 20 23:24:05 2003
@@ -34,6 +34,13 @@
         self.data = data
 
 
+class MockObjectDatabase:
+    """Implements only enough to satisfy testCatchExtraAttribute
+    """
+    def identify(self, obj):
+        return None
+
+
 class SerializationTests(SerialTestBase, unittest.TestCase):
     """Tests of basic events, serializers, and gateways.
 
@@ -75,11 +82,13 @@
         self.assertEqual(ob.data, ob2.data)
 
     def testCatchExtraAttribute(self):
+        # The mapper for PersistentMappings doesn't allow an
+        # extra attribute.
         ob = PersistentMapping()
         ob.extra = '678'
         ob['a'] = 'b'
         ob['c'] = 'd'
-        obj_db = None
+        obj_db = MockObjectDatabase()
         m = self.conf.mappers["pm"]
         event = SerializationEvent(self.conf, m, '', obj_db, ob)
         self.assertRaises(SerializationError, m.serializer.serialize, event)


=== Products/Ape/lib/apelib/tests/teststorage.py 1.5.2.2 => 1.5.2.3 ===
--- Products/Ape/lib/apelib/tests/teststorage.py:1.5.2.2	Sat Dec 20 02:31:07 2003
+++ Products/Ape/lib/apelib/tests/teststorage.py	Sat Dec 20 23:24:05 2003
@@ -237,7 +237,8 @@
             ob1 = self._writeBasicObject(conn1)
             ob1.strdata = 'def'
             conn1.setSerial(ob1, '\0' * 8)  # Pretend that it's new
-            self.assertRaises(StoreError, get_transaction().commit)
+            self.assertRaises(ZODB.POSException.ConflictError,
+                              get_transaction().commit)
         finally:
             conn1.close()
 
@@ -361,7 +362,8 @@
 
 
     def testGetPollSources(self):
-        sources = self.storage.getPollSources('\0' * 8)
+        root_oid = self.conf.oid_gen.root_oid
+        sources = self.storage.getPollSources(root_oid)
         self.assert_(not sources)
         # The test passed, but check for a false positive.
         oid = 'nonexistent-oid'


=== Products/Ape/lib/apelib/tests/testzope2fs.py 1.4.4.2 => 1.4.4.3 ===
--- Products/Ape/lib/apelib/tests/testzope2fs.py:1.4.4.2	Sat Dec 20 02:31:07 2003
+++ Products/Ape/lib/apelib/tests/testzope2fs.py	Sat Dec 20 23:24:05 2003
@@ -24,6 +24,7 @@
 from cStringIO import StringIO
 
 from ZODB.POSException import ConflictError
+from OFS.Application import Application
 from OFS.Image import File, manage_addImage, manage_addFile
 from Products.PythonScripts.PythonScript import PythonScript
 from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
@@ -70,6 +71,7 @@
         db = ApeDB(storage, resource)
         self.db = db
         get_transaction().begin()
+        self.conn._clearCache()
 
     def tearDown(self):
         get_transaction().abort()
@@ -599,6 +601,32 @@
         finally:
             conn.close()
 
+
+    def testWriteToRoot(self):
+        # Verify it's possible to write to the _root object as well as
+        # the Application object without either one stomping on each
+        # other's data.  This is a functional test of
+        # apelib.fs.structure.RootDirectoryItems.
+        conn = self.db.open()
+        conn2 = None
+        try:
+            root = conn.root()
+            app = root['Application']
+            root['foo'] = Folder()
+            root['foo'].id = 'foo'
+            app.bar = Folder('bar')
+            app.bar.id = 'bar'
+            get_transaction().commit()
+
+            conn2 = self.db.open()
+            root = conn2.root()
+            app = root['Application']
+            self.assert_(root.has_key('foo'))
+            self.assert_(hasattr(app, 'bar'))
+        finally:
+            conn.close()
+            if conn2 is not None:
+                conn2.close()
 
 
 class Zope2FSUnderscoreTests (Zope2FSTests):


=== Products/Ape/lib/apelib/tests/zope2testbase.py 1.5 => 1.5.2.1 ===
--- Products/Ape/lib/apelib/tests/zope2testbase.py:1.5	Thu Aug 14 16:21:39 2003
+++ Products/Ape/lib/apelib/tests/zope2testbase.py	Sat Dec 20 23:24:05 2003
@@ -11,7 +11,7 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""Test of storing folders on the filesystem via ZODB
+"""Test of storing various kinds of objects
 
 $Id$
 """




More information about the Zope-CVS mailing list