Back to index

plone3  3.1.7
Functions
CMFCore.tests.test_zcml Namespace Reference

Functions

def test_registerDirectory
def test_suite

Function Documentation

Use the cmf:registerDirectory directive::

  >>> import Products.CMFCore
  >>> from Products.Five import zcml
  >>> configure_zcml = '''
  ... <configure xmlns:cmf="http://namespaces.zope.org/cmf">
  ...   <cmf:registerDirectory
  ...       name="fake_skin"
  ...       directory="tests/fake_skins/fake_skin"
  ...       recursive="True"
  ...       ignore="foo bar"
  ...       />
  ... </configure>'''
  >>> zcml.load_config('meta.zcml', Products.CMFCore)
  >>> zcml.load_string(configure_zcml)

Make sure the directory is registered correctly::

  >>> from Products.CMFCore.DirectoryView import _dirreg
  >>> reg_keys = ('Products.CMFCore:tests/fake_skins/fake_skin',
  ...             'Products.CMFCore:tests/fake_skins/fake_skin/test_directory')
  >>> reg_keys[0] in _dirreg._directories
  True
  >>> reg_keys[1] in _dirreg._directories
  True
  >>> info = _dirreg._directories[reg_keys[0]]
  >>> info._reg_key == reg_keys[0]
  True
  >>> info.ignore
  ('.', '..', 'foo', 'bar')

Clean up and make sure the cleanup works::

  >>> from zope.testing.cleanup import cleanUp
  >>> cleanUp()
  >>> reg_keys[0] in _dirreg._directories
  False
  >>> reg_keys[1] in _dirreg._directories
  False

Definition at line 23 of file test_zcml.py.

00023 
00024 def test_registerDirectory():
00025     """
00026     Use the cmf:registerDirectory directive::
00027 
00028       >>> import Products.CMFCore
00029       >>> from Products.Five import zcml
00030       >>> configure_zcml = '''
00031       ... <configure xmlns:cmf="http://namespaces.zope.org/cmf">
00032       ...   <cmf:registerDirectory
00033       ...       name="fake_skin"
00034       ...       directory="tests/fake_skins/fake_skin"
00035       ...       recursive="True"
00036       ...       ignore="foo bar"
00037       ...       />
00038       ... </configure>'''
00039       >>> zcml.load_config('meta.zcml', Products.CMFCore)
00040       >>> zcml.load_string(configure_zcml)
00041 
00042     Make sure the directory is registered correctly::
00043 
00044       >>> from Products.CMFCore.DirectoryView import _dirreg
00045       >>> reg_keys = ('Products.CMFCore:tests/fake_skins/fake_skin',
00046       ...             'Products.CMFCore:tests/fake_skins/fake_skin/test_directory')
00047       >>> reg_keys[0] in _dirreg._directories
00048       True
00049       >>> reg_keys[1] in _dirreg._directories
00050       True
00051       >>> info = _dirreg._directories[reg_keys[0]]
00052       >>> info._reg_key == reg_keys[0]
00053       True
00054       >>> info.ignore
00055       ('.', '..', 'foo', 'bar')
00056 
00057     Clean up and make sure the cleanup works::
00058 
00059       >>> from zope.testing.cleanup import cleanUp
00060       >>> cleanUp()
00061       >>> reg_keys[0] in _dirreg._directories
00062       False
00063       >>> reg_keys[1] in _dirreg._directories
00064       False
00065     """
00066 

Definition at line 67 of file test_zcml.py.

00067 
00068 def test_suite():
00069     return unittest.TestSuite((
00070         doctest.DocTestSuite(),
00071         ))