[Zope3-checkins] CVS: Zope3/src/zope/configuration/tests - test_multiplexml.py:1.3

Jim Fulton jim@zope.com
Tue, 11 Mar 2003 15:11:22 -0500


Update of /cvs-repository/Zope3/src/zope/configuration/tests
In directory cvs.zope.org:/tmp/cvs-serv15785/src/zope/configuration/tests

Modified Files:
	test_multiplexml.py 
Log Message:
Fixed a bug in overriding directives in zcml.

An including file is supposed to be able to override directives in an
included file. This didn't work (before this fix) is the overriding
directive came after the include.

We still need a way to put overrides in a (different) included file.


=== Zope3/src/zope/configuration/tests/test_multiplexml.py 1.2 => 1.3 ===
--- Zope3/src/zope/configuration/tests/test_multiplexml.py:1.2	Wed Dec 25 09:13:34 2002
+++ Zope3/src/zope/configuration/tests/test_multiplexml.py	Tue Mar 11 15:11:19 2003
@@ -33,7 +33,7 @@
 
 class Test(CleanUp, unittest.TestCase):
 
-    def testNormal(self):
+    def testNormal_because_of_overrides(self):
         f2=tfile(template % ('',
             '''
             <test:protectClass
@@ -56,7 +56,7 @@
 
             '''
             <test:protectClass
-            name=".Contact" permission="splat" names="update"
+            name=".Contact" permission="splat1" names="update"
             />
             <test:increment />
             <test:increment />
@@ -67,7 +67,7 @@
         XMLConfig(str(f1))()
 
         self.assertEquals(protections, [
-            (".Contact", "splat", 'update'),
+            (".Contact", "splat1", 'update'),
             (".Contact", "splat", 'update2'),
             ])
 
@@ -110,6 +110,48 @@
         self.assertRaises(ZopeConfigurationConflictError, x)
 
         self.assertEquals(protections, [])
+
+    def testConflicting_not_due_to_extra_override(self):
+        f2=tfile(template % ('',
+            '''
+            <test:protectClass
+            name=".Contact" permission="splat" names="update"
+            />
+            <test:protectClass
+            name=".Contact" permission="splat" names="update2"
+            />
+            '''), 'f2')
+        f3=tfile(template % ('',
+            '''
+            <test:protectClass
+            name=".Contact" permission="splat" names="update2"
+            />
+            '''), 'f3')
+
+        f1=tfile(template % (
+            '''<directive name="protectClass" namespace="%s"
+            handler="zope.configuration.tests.directives.protectClass">
+            <subdirective name="protect" namespace="%s" />
+            </directive>''' % (ns, ns),
+            '''
+            <test:protectClass
+            name=".Contact" permission="splat1" names="update"
+            />
+            <include file="%s"/>
+            <include file="%s"/>
+            <test:protectClass
+              name=".Contact" permission="splat2" names="update2"
+            />
+            ''' % (f2, f3)), 'f1')
+
+        x=XMLConfig(str(f1))
+
+        x()
+
+        self.assertEquals(protections, [
+            (".Contact", "splat1", 'update'),
+            (".Contact", "splat2", 'update2'),
+            ])
 
 
     def testConflicting_in_same_location(self):