[Zope-Checkins] CVS: Zope3/lib/python/Zope/Configuration/tests - testDirectivesXML.py:1.1.2.8 testMeta.py:1.1.2.11 testXML.py:1.1.2.13

Jim Fulton jim@zope.com
Fri, 7 Jun 2002 10:41:54 -0400


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

Modified Files:
      Tag: Zope-3x-branch
	testDirectivesXML.py testMeta.py testXML.py 
Log Message:
Merging in Zope3InWonderland-branch, which implemented the following
proposals (see
http://dev.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/OldProposals): 
- RenameAllowToRequire

- GroupClassRelatedDirectivesInClassDirective

- ViewInterfaceAndSimplification

- ConsistentUseOfSpacesAsDelimitersInZCMLAttributes

- TwoArgumentViewConstructors

- ImplementsInZCML

- SimpleViewCreationInZCML

- RemoveGetView

- ReplaceProtectWithAllow

- ViewMethodsAsViews

- MergeProtectionAndComponentDefinitions

There were also various security fixes resulting of better integration
of security with components.


=== Zope3/lib/python/Zope/Configuration/tests/testDirectivesXML.py 1.1.2.7 => 1.1.2.8 ===
 from cStringIO import StringIO
 from Zope.Configuration.xmlconfig import xmlconfig, ZopeXMLConfigurationError
+from Zope.Configuration.xmlconfig import testxmlconfig
 from Zope.Configuration.meta import InvalidDirective
 from Zope.Configuration.tests.Directives import protections, done
 from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
@@ -30,7 +31,7 @@
 
 class Test(CleanUp, unittest.TestCase):
         
-    def testDirective(self):
+    def xtestDirective(self):
         xmlconfig(StringIO(
             template % (
             '''<directives  namespace="%s">
@@ -42,7 +43,7 @@
 
         self.assertEqual(done, ['splat'])
         
-    def testSimpleComplexDirective(self):
+    def xtestSimpleComplexDirective(self):
         xmlconfig(StringIO(
             template % (
             '''<directives  namespace="%s">
@@ -70,15 +71,37 @@
                </directives>''' % ns,
             '''<test:protectClass name=".Contact">
                 <test:protect permission="edit" names='update' />
-                <test:protect permission="view" names='name, email' />
+                <test:protect permission="view" names='name email' />
               </test:protectClass>'''
             )))
 
         self.assertEquals(protections, [
             (".Contact", "edit", 'update'),
-            (".Contact", "view", 'name, email'),
+            (".Contact", "view", 'name email'),
+            ])
+      
+    def testHandlerMethod(self):
+        xmlconfig(StringIO(
+            template % (
+            '''<directives  namespace="%s">
+                   <directive name="protectClass"
+                    handler="Zope.Configuration.tests.Directives.protectClass">
+                      <subdirective name="fish"
+                                    handler_method="protect" />
+                   </directive>
+               </directives>''' % ns,
+            '''<test:protectClass name=".Contact">
+                <test:fish permission="edit" names='update' />
+                <test:fish permission="view" names='name email' />
+              </test:protectClass>'''
+            )))
+
+        self.assertEquals(protections, [
+            (".Contact", "edit", 'update'),
+            (".Contact", "view", 'name email'),
             ])
         
+        
     def testBadNoPrefixComplexDirective(self):
 
         self.assertRaises(
@@ -95,14 +118,15 @@
 
             '''<test:protectClass name=".Contact">
               <test:protect permission="edit" names='update' />
-              <protect permission="view" names='name, email' />
+              <protect permission="view" names='name email' />
               </test:protectClass>'''
-            )))
+            )),
+            testing=1)
         
     def testBadPrefixComplexDirective(self):
 
         try:
-            xmlconfig(
+            testxmlconfig(
                 StringIO(
                 template % (
             '''<directives  namespace="%s">


=== Zope3/lib/python/Zope/Configuration/tests/testMeta.py 1.1.2.10 => 1.1.2.11 ===
 
         actions = end(sub(subs, (ns, 'protect'), name,
-                          permission='view', names='name, email'))
+                          permission='view', names='name email'))
         (des, callable, args, kw), = actions
-        self.assertEqual(des, ('.Contact', 'name, email'))
+        self.assertEqual(des, ('.Contact', 'name email'))
         callable(*args)
 
         self.assertEqual(tuple(end(subs)), ())
 
         self.assertEquals(protections, [
             (".Contact", "edit", 'update'),
-            (".Contact", "view", 'name, email'),
+            (".Contact", "view", 'name email'),
             ])
 
 def test_suite():


=== Zope3/lib/python/Zope/Configuration/tests/testXML.py 1.1.2.12 => 1.1.2.13 ===
 from cStringIO import StringIO
 from Zope.Configuration.xmlconfig import xmlconfig, ZopeXMLConfigurationError
+from Zope.Configuration.xmlconfig import testxmlconfig
 from Zope.Configuration.meta import InvalidDirective, BrokenDirective
 from Zope.Configuration.tests.Directives import protections, done
 from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
@@ -66,20 +67,20 @@
                           ''' % (ns, ns),
             '''<test:protectClass name=".Contact">
               <test:protect permission="edit" names='update' />
-              <test:protect permission="view" names='name, email' />
+              <test:protect permission="view" names='name email' />
             </test:protectClass>'''
             )))
 
         self.assertEquals(protections, [
             (".Contact", "edit", 'update'),
-            (".Contact", "view", 'name, email'),
+            (".Contact", "view", 'name email'),
             ])
         
     def testBadNoPrefixComplexDirective(self):
 
         self.assertRaises(
             InvalidDirective,
-            xmlconfig,
+            testxmlconfig,
             StringIO(
             template % (
             '''<directive name="protectClass" namespace="%s"
@@ -90,14 +91,14 @@
 
             '''<test:protectClass name=".Contact">
               <test:protect permission="edit" names='update' />
-              <protect permission="view" names='name, email' />
+              <protect permission="view" names='name email' />
               </test:protectClass>'''
             )))
         
     def testBadPrefixComplexDirective(self):
 
         try:
-            xmlconfig(
+            testxmlconfig(
                 StringIO(
                 template % (
             '''<directive name="protectClass" namespace="%s"