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

Kapil k_vertigo@yahoo.com
Sat, 9 Feb 2002 13:55:34 -0500


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

Modified Files:
      Tag: Zope-3x-branch
	testTabsDirective.py 
Log Message:
test for config files registering zmi TALES filters



=== Zope3/lib/python/Zope/App/ZMI/tests/testTabsDirective.py 1.1.2.2 => 1.1.2.3 ===
 import unittest, sys
 
-##############################################################################
-#
-# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-# 
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE
-# 
-##############################################################################
-"""
-
-Revision information: $Id$
-"""
-
+# Revision information: $Id$
 
 from StringIO import StringIO
 
 from Zope.App.ZMI.ZMIViewService import ZMIViews
+from Zope.ComponentArchitecture import provideAdapter, _clear
 from Zope.Configuration.xmlconfig import xmlconfig
 from Zope.Configuration.meta import _clear as metaclear
 from Zope.Configuration.xmlconfig import ZopeXMLConfigurationError
 
-
 from Interface import Interface
 
-from Zope.App.ZMI.tests.sampleInterfaces import O1, O2
+from Zope.App.ZMI.tests.sampleInterfaces import *
 
 
 class Test(unittest.TestCase):
     #XXX we should have a test for multiple inheritance interface
     # hierarchies.
 
+    def tearDown(self):
+        _clear()
+        ZMIViews._clear()        
 
     def tearDown(self):
         metaclear()
@@ -61,7 +48,7 @@
       <directive name="tabs" attributes="for" 
       namespace="http://namespaces.zope.org/zmi"
       handler="Zope.App.ZMI.TabsDirective.">
-        <subdirective name="tab" attributes="label,action" />
+        <subdirective name="tab" attributes="label,action,filter" />
       </directive>
       <zmi:tabs for="Zope.App.ZMI.tests.sampleInterfaces.I1">
         <zmi:tab label="Edit" action="edit" />
@@ -74,6 +61,8 @@
       
       </zopeConfigure>        
         """))
+
+        provideAdapter(I1, ITraverser, FakeTraverser)
         
         self.assertEqual(list(ZMIViews.getViews(O2())),
                          [
@@ -81,6 +70,41 @@
                           ('Organize', 'organize_magic'),
                           ('Edit', 'edit'),
                           ('History', 'history')
+                          ]
+                         )
+
+
+
+    def testZMITabDirectiveWithFilters(self):
+        
+        xmlconfig( StringIO("""
+        <zopeConfigure
+      xmlns='http://namespaces.zope.org/zope'
+      xmlns:zmi='http://namespaces.zope.org/zmi'>
+      <directive name="tabs" attributes="for" 
+      namespace="http://namespaces.zope.org/zmi"
+      handler="Zope.App.ZMI.TabsDirective.">
+        <subdirective name="tab" attributes="label,action,filter" />
+      </directive>
+      <zmi:tabs for="Zope.App.ZMI.tests.sampleInterfaces.I1">
+        <zmi:tab label="Edit" action="edit" />
+        <zmi:tab label="History" action="history" filter="python: 1==2" />
+      </zmi:tabs>
+      <zmi:tabs for="Zope.App.ZMI.tests.sampleInterfaces.I2">
+        <zmi:tab label="Update" action="update_magic" />
+        <zmi:tab label="Organize" action="organize_magic" />
+      </zmi:tabs>
+      
+      </zopeConfigure>        
+        """))
+
+        provideAdapter(I1, ITraverser, FakeTraverser)
+
+        self.assertEqual(list(ZMIViews.getViews(O2())),
+                         [
+                          ('Update', 'update_magic'),
+                          ('Organize', 'organize_magic'),
+                          ('Edit', 'edit'),
                           ]
                          )