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

Kapil k_vertigo@yahoo.com
Thu, 31 Jan 2002 17:32:24 -0500


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

Added Files:
      Tag: Zope-3x-branch
	testZMIViewService.py 
Log Message:
(sprint) Added ZMI View Service/Registry 


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

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    


class Test(unittest.TestCase):
    #XXX we should have a test for multiple inheritance interface
    # hierarchies.
    
    def testAddView(self):
        service = ZMIViewService()
        
        service.registerView(I1, 'Edit', 'edit')
        service.registerView(I1, 'History', 'history')
        service.registerView(I2, 'Update', 'update_magic')
        service.registerView(I2, 'Organize', 'organize_magic')

        self.assertEqual(list(service.getViews(O1())),
                         [('Edit', 'edit'), ('History', 'history')])
        
        self.assertEqual(list(service.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())