Back to index

plone3  3.1.7
testPropertiesTool.py
Go to the documentation of this file.
00001 #
00002 # Exportimport adapter tests
00003 #
00004 
00005 import os, sys
00006 if __name__ == '__main__':
00007     execfile(os.path.join(sys.path[0], 'framework.py'))
00008 
00009 from Products.CMFPlone.tests import PloneTestCase
00010 from Products.CMFPlone.exportimport.tests.base import BodyAdapterTestCase
00011 
00012 from Products.CMFPlone.PropertiesTool import SimpleItemWithProperties
00013 from Products.CMFPlone.PropertiesTool import PropertiesTool
00014 
00015 _PROPERTYSHEET_XML = """\
00016 <?xml version="1.0"?>
00017 <object name="site_properties" meta_type="Plone Property Sheet">
00018  <property name="title">Site wide properties</property>
00019  <property name="allowAnonymousViewAbout" type="boolean">True</property>
00020 </object>
00021 """
00022 
00023 _PROPERTIESTOOL_XML = """\
00024 <?xml version="1.0"?>
00025 <object name="portal_properties" meta_type="Plone Properties Tool">
00026  <object name="site_properties" meta_type="Plone Property Sheet">
00027   <property name="title">Site wide properties</property>
00028   <property name="allowAnonymousViewAbout" type="boolean">True</property>
00029  </object>
00030 </object>
00031 """
00032 
00033 
00034 class PropertySheetXMLAdapterTests(BodyAdapterTestCase):
00035 
00036     def _getTargetClass(self):
00037         from Products.CMFPlone.exportimport.propertiestool \
00038                     import SimpleItemWithPropertiesXMLAdapter
00039         return SimpleItemWithPropertiesXMLAdapter
00040 
00041     def _populate(self, obj):
00042         obj.manage_changeProperties(title='Site wide properties')
00043         obj.manage_addProperty('allowAnonymousViewAbout', True, 'boolean')
00044 
00045     def setUp(self):
00046         self._obj = SimpleItemWithProperties('site_properties')
00047         self._BODY = _PROPERTYSHEET_XML
00048 
00049 
00050 class PropertiesToolXMLAdapterTests(BodyAdapterTestCase):
00051 
00052     def _getTargetClass(self):
00053         from Products.CMFPlone.exportimport.propertiestool \
00054                     import PlonePropertiesToolXMLAdapter
00055         return PlonePropertiesToolXMLAdapter
00056 
00057     def _populate(self, obj):
00058         obj._setObject('site_properties', SimpleItemWithProperties('site_properties'))
00059         obj.site_properties.manage_changeProperties(title='Site wide properties')
00060         obj.site_properties.manage_addProperty('allowAnonymousViewAbout', True, 'boolean')
00061 
00062     def setUp(self):
00063         self._obj = PropertiesTool()
00064         self._BODY = _PROPERTIESTOOL_XML
00065 
00066 
00067 def test_suite():
00068     from unittest import TestSuite, makeSuite
00069     suite = TestSuite()
00070     suite.addTest(makeSuite(PropertySheetXMLAdapterTests))
00071     suite.addTest(makeSuite(PropertiesToolXMLAdapterTests))
00072     return suite
00073 
00074 if __name__ == '__main__':
00075     framework()
00076