Back to index

plone3  3.1.7
test_zcml.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 zcml module.
00014 
00015 $Id: test_zcml.py 72873 2007-02-27 13:13:44Z yuppie $
00016 """
00017 
00018 import unittest
00019 import Testing
00020 from zope.testing import doctest
00021 
00022 
00023 def test_registerDirectory():
00024     """
00025     Use the cmf:registerDirectory directive::
00026 
00027       >>> import Products.CMFCore
00028       >>> from Products.Five import zcml
00029       >>> configure_zcml = '''
00030       ... <configure xmlns:cmf="http://namespaces.zope.org/cmf">
00031       ...   <cmf:registerDirectory
00032       ...       name="fake_skin"
00033       ...       directory="tests/fake_skins/fake_skin"
00034       ...       recursive="True"
00035       ...       ignore="foo bar"
00036       ...       />
00037       ... </configure>'''
00038       >>> zcml.load_config('meta.zcml', Products.CMFCore)
00039       >>> zcml.load_string(configure_zcml)
00040 
00041     Make sure the directory is registered correctly::
00042 
00043       >>> from Products.CMFCore.DirectoryView import _dirreg
00044       >>> reg_keys = ('Products.CMFCore:tests/fake_skins/fake_skin',
00045       ...             'Products.CMFCore:tests/fake_skins/fake_skin/test_directory')
00046       >>> reg_keys[0] in _dirreg._directories
00047       True
00048       >>> reg_keys[1] in _dirreg._directories
00049       True
00050       >>> info = _dirreg._directories[reg_keys[0]]
00051       >>> info._reg_key == reg_keys[0]
00052       True
00053       >>> info.ignore
00054       ('.', '..', 'foo', 'bar')
00055 
00056     Clean up and make sure the cleanup works::
00057 
00058       >>> from zope.testing.cleanup import cleanUp
00059       >>> cleanUp()
00060       >>> reg_keys[0] in _dirreg._directories
00061       False
00062       >>> reg_keys[1] in _dirreg._directories
00063       False
00064     """
00065 
00066 
00067 def test_suite():
00068     return unittest.TestSuite((
00069         doctest.DocTestSuite(),
00070         ))
00071 
00072 if __name__ == '__main__':
00073     unittest.main(defaultTest='test_suite')