Back to index

plone3  3.1.7
test_stepzcml.py
Go to the documentation of this file.
00001 ##############################################################################
00002 #
00003 # Copyright (c) 2007 Zope Corporation and Contributors. All Rights Reserved.
00004 #
00005 # This software is subject to the provisions of the Zope Public License,
00006 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
00007 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
00008 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00009 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
00010 # FOR A PARTICULAR PURPOSE.
00011 #
00012 ##############################################################################
00013 """Unit tests for import/export step zcml module.
00014 
00015 $Id: test_stepzcml.py 82385 2007-12-21 11:51:03Z yuppie $
00016 """
00017 
00018 import unittest
00019 from zope.testing.cleanup import cleanUp
00020 
00021 import Products.GenericSetup
00022 from Products.GenericSetup.registry import _import_step_registry
00023 from Products.Five import zcml
00024 
00025 EMPTY_ZCML = '''<configure xmlns:genericsetup="http://namespaces.zope.org/genericsetup">
00026 </configure>'''
00027 
00028 ONE_STEP_ZCML = '''<configure xmlns:genericsetup="http://namespaces.zope.org/genericsetup" i18n_domain="genericsetup">
00029 <genericsetup:importStep
00030     name="Products.GenericSetup.teststep"
00031     title="step title"
00032     description="step description"
00033     handler="Products.GenericSetup.initialize"
00034     />
00035 </configure>'''
00036 
00037 class ImportStepTests(unittest.TestCase):
00038 
00039     def setUp(self):
00040         zcml.load_config('meta.zcml', Products.GenericSetup)
00041 
00042     def tearDown(self):
00043         cleanUp()
00044 
00045     def testEmptyImport(self):
00046         zcml.load_string(EMPTY_ZCML)
00047         self.assertEqual(_import_step_registry._registered, {})
00048 
00049     def testOneStepImport(self):
00050         zcml.load_string(ONE_STEP_ZCML)
00051         self.assertEqual(_import_step_registry._registered.keys(),
00052             [ u'Products.GenericSetup.teststep'  ])
00053         info = _import_step_registry._registered[ u'Products.GenericSetup.teststep' ]
00054         self.assertEqual( info['description'],
00055                 u'step description' )
00056         self.assertEqual( info['title'],
00057                 u'step title' )
00058         self.assertEqual( info['handler'],
00059                 'Products.GenericSetup.initialize')
00060         self.assertEqual( info['id'],
00061                 u'Products.GenericSetup.teststep' )
00062 
00063 
00064 def test_suite():
00065     return unittest.TestSuite((
00066         unittest.makeSuite(ImportStepTests),
00067         ))
00068 
00069 if __name__ == '__main__':
00070     from Products.GenericSetup.testing import run
00071     run(test_suite())