m Ec@swdZdkZdkZedjo$eeiieiddndZdZedjo e ndS(snUnit tests for the registerClass directive. $Id: test_registerclass.py 61072 2005-10-31 17:43:51Z philikon $ Nt__main__is framework.pycCsdS(s Testing registerClass >>> from zope.app.testing.placelesssetup import setUp, tearDown >>> setUp() >>> import Products >>> import Products.Five >>> from Products.Five import zcml >>> from Products.Five.tests.testing.simplecontent import SimpleContent >>> from Products.Five.tests.testing.simplecontent import ISimpleContent >>> from persistent.interfaces import IPersistent Use the five:registerClass directive:: >>> configure_zcml = ''' ... ... ... ... ''' >>> zcml.load_config('meta.zcml', Products.Five) >>> zcml.load_string(configure_zcml) Make sure that the class attributes are set correctly:: >>> SimpleContent.meta_type 'Foo Type' >>> SimpleContent.icon '++resource++foo_icon.png' And the meta_type is registered correctly:: >>> for info in Products.meta_types: ... if info['name'] == 'Foo Type': ... break >>> info['product'] 'Five' >>> info['permission'] 'Add Foo' >>> ISimpleContent in info['interfaces'] True >>> IPersistent in info['interfaces'] True >>> info['visibility'] is None True >>> info['instance'] is SimpleContent True >>> info['action'] '+/addfoo.html' >>> info['container_filter'] is None True Now reset everything and see what happens without optional parameters:: >>> tearDown() >>> setUp() Use the five:registerClass directive again:: >>> configure_zcml = ''' ... ... ... ... ''' >>> zcml.load_config('meta.zcml', Products.Five) >>> zcml.load_string(configure_zcml) Make sure that the class attributes are set correctly:: >>> SimpleContent.meta_type 'Bar Type' >>> SimpleContent.icon '' And the meta_type is registered correctly:: >>> for info in Products.meta_types: ... if info['name'] == 'Bar Type': ... break >>> info['product'] 'Five' >>> info['permission'] 'Add Bar' >>> ISimpleContent in info['interfaces'] True >>> IPersistent in info['interfaces'] True >>> info['visibility'] 'Global' >>> info['instance'] is SimpleContent True >>> info['action'] '' >>> info['container_filter'] is None True Clean up: >>> tearDown() >>> SimpleContent.meta_type 'simple item' >>> SimpleContent.icon '' >>> [info for info in Products.meta_types if info['name'] == 'Bar Type'] [] N((((tE/data/zmath/zope/lib/python/Products/Five/tests/test_registerclass.pyttest_registerClassszcCsdkl}|S(N(sZopeDocTestSuite(tTesting.ZopeTestCasetZopeDocTestSuite(R((Rt test_suites ( t__doc__tostsyst__name__texecfiletpathtjoinRRt framework(RRRR((Rt?s $ |