[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZMI/tests - testServiceProvideClass.py:1.1.2.9.8.1

Jim Fulton jim@zope.com
Mon, 3 Jun 2002 13:15:59 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/ZMI/tests
In directory cvs.zope.org:/tmp/cvs-serv12372/lib/python/Zope/App/ZMI/tests

Modified Files:
      Tag: Zope3InWonderland-branch
	testServiceProvideClass.py 
Log Message:
- Attribute renaming.

  In directives that define things, renamed thing_id to id. For
  example:

    <permission permission_id='xxx' ...

  became:

    <permission id='xxx' ...

  In directives that used things defined in this way, removed the id
  suffix. For example:

     <view permission_id='xxx' ...

  became:

     <view permission='xxx' ...

- Changed the way that exceptions from configuration files are
  reported. Went back to normal Python tracebacks followed by
  "configuration tracebacks". The configuration tracebacks look
  somewhat similar to Python tracebacks, with file location
  information. The most specific configuration file location is at the
  end of the traceback, followed by the original error type and
  value. 

- Added a testxmlconfig function to the xmlconfig module to support
  unit testing. This function suppresses usual configuration error
  generation so that the original error is raised. This is needed so
  that unit tests can detect that proper low-level errors are raised. 

Note that everyone will need to edit their principals.zcml files to
reflect these changes!



=== Zope3/lib/python/Zope/App/ZMI/tests/testServiceProvideClass.py 1.1.2.9 => 1.1.2.9.8.1 ===
 
 
-import unittest, sys, Interface
+import unittest, sys, Interface, os
 from Zope.App.ZMI import provideClass
 
-
 from StringIO import StringIO
 from Zope.Configuration.xmlconfig import xmlconfig
-from Zope.App.OFS.Services.AddableService.tests.AddableSetup import AddableSetup
+from Zope.App.OFS.Services.AddableService.tests.AddableSetup \
+     import AddableSetup
 from Zope.Configuration.xmlconfig import ZopeXMLConfigurationError
 from Zope.ComponentArchitecture import getService
 
+import Zope.App.ZMI
+defs_path = os.path.join(
+    os.path.split(Zope.App.ZMI.__file__)[0],
+    'zmi-meta.zcml')
 
 
 class MyAddableService:
@@ -34,6 +38,10 @@
 
 class ServiceProvideClassTest(AddableSetup, unittest.TestCase):
 
+    def setUp(self):
+        AddableSetup.setUp(self)
+        xmlconfig(open(defs_path))
+
     def testServiceProvideClassDirective(self):
         serviceName = (
             'Zope.App.ZMI.tests.testServiceProvideClass.MyAddableService')
@@ -41,17 +49,11 @@
         xmlconfig( StringIO('''
         <zopeConfigure
         xmlns="http://namespaces.zope.org/zope"
-        xmlns:service="http://namespaces.zope.org/zmi/service">
-
-        <directives namespace="http://namespaces.zope.org/zmi/service">
-          <directive name="factoryFromClass"
-            attributes="name, permission_id, title, description"
-            handler="Zope.App.ZMI.metaConfigure.ServiceClassDir" />
-        </directives>
+        xmlns:service="http://namespaces.zope.org/service">
 
         <service:factoryFromClass name="%s"
                  class="%s"
-                 permission_id="Zope.AddService"
+                 permission="Zope.AddService"
                  title="Stupid Service"
                  description="This is a sample Service" />