[Zope3-checkins] CVS: Zope3/src/zope/app/fssync/tests - fssync.zcml:1.1 fssync_duplicate.zcml:1.1 test_fsdirective.py:1.3

Stephan Richter srichter@cosmos.phy.tufts.edu
Fri, 1 Aug 2003 19:31:55 -0400


Update of /cvs-repository/Zope3/src/zope/app/fssync/tests
In directory cvs.zope.org:/tmp/cvs-serv23391/tests

Modified Files:
	test_fsdirective.py 
Added Files:
	fssync.zcml fssync_duplicate.zcml 
Log Message:
Converted 'fssync' namespace to new style ZCML Meta Config.


=== Added File Zope3/src/zope/app/fssync/tests/fssync.zcml ===
<configure xmlns="http://namespaces.zope.org/zope"
           xmlns:fssync="http://namespaces.zope.org/fssync">

  <include package="zope.app.fssync" file="meta.zcml"/>

  <fssync:adapter
      factory = "zope.app.fssync.tests.sampleclass.CDefaultAdapter"/>

  <fssync:adapter
      class=".sampleclass.C2"
      factory=".sampleclass.CDirAdapter"/>

</configure>


=== Added File Zope3/src/zope/app/fssync/tests/fssync_duplicate.zcml ===
<configure xmlns="http://namespaces.zope.org/zope"
           xmlns:fssync="http://namespaces.zope.org/fssync">

  <include package="zope.app.fssync" file="meta.zcml"/>

  <fssync:adapter
      class="zope.app.fssync.tests.sampleclass.C1"
      factory="zope.app.fssync.tests.sampleclass.CDirAdapter" />
        
  <fssync:adapter
      class="zope.app.fssync.tests.sampleclass.C1"
      factory="zope.app.fssync.tests.sampleclass.CFileAdapter" />

</configure>


=== Zope3/src/zope/app/fssync/tests/test_fsdirective.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/fssync/tests/test_fsdirective.py:1.2	Mon Jul 28 18:21:36 2003
+++ Zope3/src/zope/app/fssync/tests/test_fsdirective.py	Fri Aug  1 19:31:50 2003
@@ -15,92 +15,39 @@
 
 $Id$
 """
+import unittest
 
-from cStringIO import StringIO
-from unittest import TestCase, TestSuite, main, makeSuite
-
-from zope.configuration.xmlconfig import testxmlconfig as xmlconfig, XMLConfig
-from zope.testing.cleanup import CleanUp # Base class w registry cleanup
 from zope.app.fssync.fsregistry import getSynchronizer
-from zope.app.interfaces.fssync \
-     import IGlobalFSSyncService, IObjectFile, IObjectDirectory
-from zope.interface.verify import verifyObject
-from zope.exceptions import DuplicationError, NotFoundError
-from zope.configuration.exceptions import ConfigurationError
+from zope.app.fssync.tests.sampleclass import \
+     C1, C2, CDirAdapter, CDefaultAdapter
 from zope.app.tests.placelesssetup import PlacelessSetup
-from zope.component.service import UndefinedService
-from zope.app.fssync.tests.sampleclass \
-     import C1, C2, CDirAdapter, CFileAdapter, CDefaultAdapter
-
-import zope.app.fssync
-
-template = """
-   <zopeConfigure xmlns="http://namespaces.zope.org/zope"
-   xmlns:fssync="http://namespaces.zope.org/fssync">
-   %s
-   </zopeConfigure>"""
-
-class Test(PlacelessSetup, TestCase):
-    """
-    """    
-    def setUp(self):
-        PlacelessSetup.setUp(self)
-        XMLConfig('meta.zcml', zope.app.fssync)()
+from zope.configuration import xmlconfig
+from zope.configuration.config import ConfigurationConflictError
+from zope.exceptions import NotFoundError
+import zope.app.fssync.tests
+
+
+class DirectivesTest(PlacelessSetup, unittest.TestCase):
 
     def testFSDirective(self):
-        """Test for Synchrozier not found and Registering the
-        adapter for a class.
-        """
-        from zope.app.fssync.tests.sampleclass import C1
-    
         # Register the adapter for the class
         self.assertRaises(NotFoundError, getSynchronizer, C2())
-
-        xmlconfig(StringIO(template % (
-             """
-             <fssync:adapter
-             class="zope.app.fssync.tests.sampleclass.C2"
-             factory="zope.app.fssync.tests.sampleclass.CDirAdapter"
-             />
-             """
-             )))
+        self.context = xmlconfig.file("fssync.zcml", zope.app.fssync.tests)
         self.assertEqual(getSynchronizer(C2()).__class__, CDirAdapter)
 
     def testFSDirectiveDefaultAdapter(self):
-        """Test for getting default adapter for not registered Classes"""
-        xmlconfig(StringIO(template % (
-              """
-              <fssync:adapter
-              factory = "zope.app.fssync.tests.sampleclass.CDefaultAdapter"
-              />
-              """
-              )))
-        self.assertEqual(getSynchronizer(C2()).__class__, CDefaultAdapter)
+        self.context = xmlconfig.file("fssync.zcml", zope.app.fssync.tests)
+        self.assertEqual(getSynchronizer(C1()).__class__, CDefaultAdapter)
         
     def testFSDirectiveDuplicate(self):
-        """Duplication test"""
-        xmlconfig(StringIO(template % (
-             """
-             <fssync:adapter
-             class="zope.app.fssync.tests.sampleclass.C1"
-             factory="zope.app.fssync.tests.sampleclass.CDirAdapter"
-             />
-             """
-             )))
-        
-        self.assertRaises(DuplicationError, xmlconfig, StringIO(template % (
-             """
-             <fssync:adapter
-             class="zope.app.fssync.tests.sampleclass.C1"
-             factory="zope.app.fssync.tests.sampleclass.CFileAdapter"
-             />
-             """
-             )))
+        self.assertRaises(ConfigurationConflictError, xmlconfig.file,
+                          "fssync_duplicate.zcml", zope.app.fssync.tests)
+
 
 def test_suite():
-    return TestSuite((
-        makeSuite(Test),
+    return unittest.TestSuite((
+        unittest.makeSuite(DirectivesTest),
         ))
 
-if __name__=='__main__':
-    main(defaultTest='test_suite')
+if __name__ == '__main__':
+    unittest.main()