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

Scott Robertson srobertson@codeit.com
Sat, 9 Feb 2002 13:41:46 -0500


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

Modified Files:
      Tag: Zope-3x-branch
	testServiceProvideClass.py 
Log Message:
Updated the test to check the directive using the xmlconfig function instead
of calling the provideClass method directly.




=== Zope3/lib/python/Zope/App/ZMI/tests/testServiceProvideClass.py 1.1.2.1 => 1.1.2.2 ===
 from Zope.App.ZMI import provideClass
 
+
+from StringIO import StringIO
+from Zope.Configuration.xmlconfig import xmlconfig
+from Zope.Configuration.meta import _clear as metaclear
+from Zope.Configuration.xmlconfig import ZopeXMLConfigurationError
+
+
+
 class MyAddableService:
     pass
 
@@ -25,23 +33,32 @@
         from Zope.ComponentArchitecture import _clear
         _clear()
 
-    def testProvideClass(self):
-        from Zope.ComponentArchitecture.hooks import createObject
-        
-
-        provideClass(ServiceAddables, 'My.Test.Addable', MyAddableService, None, 'Testing')
-
-        object = createObject(None,'My.Test.Addable')
-        self.assert_(isinstance(object, MyAddableService))
 
+    def testServiceProvideClassDirective(self):
+        serviceName = 'Zope.App.ZMI.tests.testServiceProvideClass.MyAddableService'
         
+        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="provideClass"
+            attributes="name, permission_id, title, description"
+            handler="Zope.App.ZMI.provideClass.ServiceClassDir" />
+        </directives>
+
+        <service:provideClass name="%s"
+                 permission_id="Zope.AddService"
+                 title="Stupid Service"
+                 description="This is a sample Service" />
+      
+        </zopeConfigure>        
+        """ % serviceName))
 
-    def testGetAddables(self):
-        provideClass(ServiceAddables, 'My.Test.Addable', MyAddableService, None, 'Testing')
-        
         addables = ServiceAddables.getAddables(None)
-        self.assertEqual(addables[0].id,'My.Test.Addable')
-                
+        self.assertEqual(addables[0].id, serviceName)
+