[Zope3-checkins] CVS: Zope3/lib/python/Zope/StartUp/tests - testRegisterRequestFactory.py:1.3 testRegisterServerType.py:1.3

R. David Murray bitz@bitdance.com
Fri, 8 Nov 2002 13:55:37 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/StartUp/tests
In directory cvs.zope.org:/tmp/cvs-serv1726/lib/python/Zope/StartUp/tests

Modified Files:
	testRegisterRequestFactory.py testRegisterServerType.py 
Log Message:
Refactor to eliminate use of top level directive directive and
simplify by using utility function from Zope.Configuration.tests.
Along the way, reformat test zcml to match style guide.


=== Zope3/lib/python/Zope/StartUp/tests/testRegisterRequestFactory.py 1.2 => 1.3 ===
--- Zope3/lib/python/Zope/StartUp/tests/testRegisterRequestFactory.py:1.2	Mon Jun 10 19:29:43 2002
+++ Zope3/lib/python/Zope/StartUp/tests/testRegisterRequestFactory.py	Fri Nov  8 13:55:37 2002
@@ -17,37 +17,29 @@
 """
 
 import unittest
-from Zope.StartUp.RequestFactoryRegistry import getRequestFactory
-
-from Zope.Configuration.xmlconfig import xmlconfig
 from cStringIO import StringIO
-
-
-template = """<zopeConfigure
-   xmlns='http://namespaces.zope.org/zope'
-   xmlns:startup='http://namespaces.zope.org/startup'>
-   %s
-   </zopeConfigure>"""
+from Zope.Configuration.xmlconfig import xmlconfig
+from Zope.Configuration.tests.BaseTestDirectivesXML import makeconfig
+from Zope.StartUp.RequestFactoryRegistry import getRequestFactory
 
 
 class Test( unittest.TestCase ):
 
-
     def testRegisterRequestFactory(self):
 
-        xmlconfig(StringIO(template % (
-            '''
-            <directive name="registerRequestFactory"
-               attributes="name publication request"
-               handler="Zope.StartUp.metaConfigure.registerRequestFactory"
-               namespace="http://namespaces.zope.org/startup" />
-
-            <startup:registerRequestFactory name="BrowserRequestFactory"
-              publication = 
-              "Zope.App.ZopePublication.Browser.Publication.BrowserPublication"
-              request = "Zope.Publisher.Browser.BrowserRequest." />
+        xmlconfig(makeconfig(
+            '''<directive
+                   name="registerRequestFactory"
+                   attributes="name publication request"
+                   handler=
+                     "Zope.StartUp.metaConfigure.registerRequestFactory" />''',
+            '''<test:registerRequestFactory
+                   name="BrowserRequestFactory"
+                   publication= 
+                   "Zope.App.ZopePublication.Browser.Publication.BrowserPublication"
+                   request = "Zope.Publisher.Browser.BrowserRequest." />
             '''
-            )))
+            ))
 
         from Zope.App.ZopePublication.Browser.Publication import \
              BrowserPublication


=== Zope3/lib/python/Zope/StartUp/tests/testRegisterServerType.py 1.2 => 1.3 ===
--- Zope3/lib/python/Zope/StartUp/tests/testRegisterServerType.py:1.2	Mon Jun 10 19:29:43 2002
+++ Zope3/lib/python/Zope/StartUp/tests/testRegisterServerType.py	Fri Nov  8 13:55:37 2002
@@ -15,39 +15,28 @@
 """
 
 import unittest
-from Zope.StartUp.ServerTypeRegistry import getServerType
-
-from Zope.Configuration.xmlconfig import xmlconfig
 from cStringIO import StringIO
-
-
-template = """<zopeConfigure
-   xmlns='http://namespaces.zope.org/zope'
-   xmlns:startup='http://namespaces.zope.org/startup'>
-   %s
-   </zopeConfigure>"""
+from Zope.Configuration.xmlconfig import xmlconfig
+from Zope.Configuration.tests.BaseTestDirectivesXML import makeconfig
+from Zope.StartUp.ServerTypeRegistry import getServerType
 
 
 class Test( unittest.TestCase ):
 
-
     def testRegisterServerType(self):
-
-        xmlconfig(StringIO(template % (
-            '''<directive name="registerServerType"
-                 attributes="name publication request"
-                 handler="Zope.StartUp.metaConfigure.registerServerType"
-                 namespace="http://namespaces.zope.org/startup" />
-
-               <startup:registerServerType 
+        xmlconfig(makeconfig(
+            '''<directive
+                   name="registerServerType"
+                   attributes="name publication request"
+                   handler="Zope.StartUp.metaConfigure.registerServerType" />''',
+            '''<test:registerServerType 
                  name = "Browser"
                  factory = "Zope.Server.HTTP.PublisherHTTPServer."
                  requestFactory="BrowserRequestFactory"
                  logFactory = "Zope.Server.HTTP.CommonHitLogger."
                  defaultPort="8080"
-                 defaultVerbose="true" />
-            '''
-            )))
+                 defaultVerbose="true" />'''
+            ))
 
         from Zope.Server.HTTP.PublisherHTTPServer import PublisherHTTPServer
         from Zope.Server.HTTP.CommonHitLogger import CommonHitLogger