[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZMI/tests - sampleInterfaces.py:1.1.2.1 testTabsDirective.py:1.1.2.1 testZMIViewService.py:1.1.2.2

Kapil k_vertigo@yahoo.com
Thu, 31 Jan 2002 18:47:15 -0500


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

Modified Files:
      Tag: Zope-3x-branch
	testZMIViewService.py 
Added Files:
      Tag: Zope-3x-branch
	sampleInterfaces.py testTabsDirective.py 
Log Message:
(sprint) added zope configuration directives for zmi tabs


=== Added File Zope3/lib/python/Zope/App/ZMI/tests/sampleInterfaces.py ===
##############################################################################
#
# 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: sampleInterfaces.py,v 1.1.2.1 2002/01/31 23:47:14 k_vertigo Exp $
"""

from Interface import Interface

class I1(Interface): pass
class I2(I1): pass

class O1:
    __implements__ = I1
    
class O2:
    __implements__ = I2    


=== Added File Zope3/lib/python/Zope/App/ZMI/tests/testTabsDirective.py ===
#############################################################################
#
# 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
# 
##############################################################################

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: testTabsDirective.py,v 1.1.2.1 2002/01/31 23:47:14 k_vertigo Exp $
"""


from StringIO import StringIO

from Zope.App.ZMI.ZMIViewService import ZMIViews
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


class Test(unittest.TestCase):
    #XXX we should have a test for multiple inheritance interface
    # hierarchies.


    def testZMITabDirective(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" />
      </directive>
      <zmi:tabs for="Zope.App.ZMI.tests.sampleInterfaces.I1">
        <zmi:tab label="Edit" action="edit" />
        <zmi:tab label="History" action="history" />
      </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>        
        """))
        
        self.assertEqual(list(ZMIViews.getViews(O2())),
                         [
                          ('Update', 'update_magic'),
                          ('Organize', 'organize_magic'),
                          ('Edit', 'edit'),
                          ('History', 'history')
                          ]
                         )
        
def test_suite():
    loader=unittest.TestLoader()
    return loader.loadTestsFromTestCase(Test)

if __name__=='__main__':
    unittest.TextTestRunner().run(test_suite())



=== Zope3/lib/python/Zope/App/ZMI/tests/testZMIViewService.py 1.1.2.1 => 1.1.2.2 ===
 
 import unittest, sys
-
-from Zope.App.ZMI.ZMIViewService import ZMIViewService
 from Interface import Interface
 
-class I1(Interface): pass
-class I2(I1): pass
-
-class O1:
-    __implements__ = I1
-    
-class O2:
-    __implements__ = I2    
+from Zope.App.ZMI.ZMIViewService import ZMIViewService
+from Zope.App.ZMI.tests.sampleInterfaces import O1, O2, I1, I2
 
 
 class Test(unittest.TestCase):