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

Nick Garcia ngarcia@codeit.com
Sat, 9 Feb 2002 11:34:31 -0500


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

Added Files:
      Tag: Zope-3x-branch
	testServiceManagerContents.py 
Log Message:
Created Contents view for Service Manager.
Create test for Contents view for Service Manager.
Create Page Template for Contents view for Service Manager.



=== Added File Zope3/lib/python/Zope/App/Service/tests/testServiceManagerContents.py ===
# Copyright (c) 2001 Zope Corporation and Contributors.  All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 1.1 (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

from Interface import Interface

class IDummy(Interface):
    pass

class Dummy:
    __implements__ = IDummy
    
class Test( unittest.TestCase ):

    def testExtractContents( self ):
        """ Does _extractContents return the correct information? """

        from Zope.App.Service.ServiceManagerContents import ServiceManagerContents

        smc = ServiceManagerContents( None )
        info = smc._extractContentInfo( ('dummy', Dummy(),) )

        self.assert_( 'IDummy' in info['interfaces'] )

    def testInfo( self ):
        """ Do we get the correct information back from ServiceManagerContents? """

        from Zope.App.Service.ServiceManagerContents import ServiceManagerContents
        from Zope.App.Service.ServiceManager import ServiceManager

        sm = ServiceManager()
        dummy = Dummy()
        sm.setObject( 'dummy', dummy )

        smc = ServiceManagerContents( sm )
        info_list = smc.listContentInfo()

        self.assertEquals( len( info_list ), 1 )

        interfaces = [ x['interfaces'] for x in info_list ]
        self.assert_( 'IDummy' in interfaces[0] )

def test_suite():
    loader = unittest.TestLoader()
    return loader.loadTestsFromTestCase( Test )

if __name__=='__main__':
    unittest.main()