[Erp5-report] r10002 - in /erp5/trunk/products/ERP5Type: ERP5Type.py tests/testERP5Type.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Sep 15 16:05:43 CEST 2006
Author: seb
Date: Fri Sep 15 16:05:40 2006
New Revision: 10002
URL: http://svn.erp5.org?rev=10002&view=rev
Log:
write a test in order to see if we raise ConstraintNotFound if a bad constraint is defined into PropertySheet
Modified:
erp5/trunk/products/ERP5Type/ERP5Type.py
erp5/trunk/products/ERP5Type/tests/testERP5Type.py
Modified: erp5/trunk/products/ERP5Type/ERP5Type.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/ERP5Type.py?rev=10002&r1=10001&r2=10002&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/ERP5Type.py (original)
+++ erp5/trunk/products/ERP5Type/ERP5Type.py Fri Sep 15 16:05:40 2006
@@ -210,12 +210,21 @@
def getPropertySheetList( self ):
"""
Return list of content types.
+ XXX I (seb) think the name is bad
"""
from Products.ERP5Type import PropertySheet
result = PropertySheet.__dict__.keys()
result = filter(lambda k: not k.startswith('__'), result)
result.sort()
return result
+
+ security.declareProtected(Permissions.ModifyPortalContent,
+ 'setPropertySheetList')
+ def setPropertySheetList( self, property_sheet_list):
+ """
+ Set the list of property_sheet for this portal type
+ """
+ self.property_sheet_list = property_sheet_list
security.declareProtected(Permissions.AccessContentsInformation,
'getHiddenContentTypeList')
Modified: erp5/trunk/products/ERP5Type/tests/testERP5Type.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/testERP5Type.py?rev=10002&r1=10001&r2=10002&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/testERP5Type.py (original)
+++ erp5/trunk/products/ERP5Type/tests/testERP5Type.py Fri Sep 15 16:05:40 2006
@@ -15,6 +15,8 @@
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from zLOG import LOG, INFO
from Products.CMFCore.tests.base.testcase import LogInterceptor
+from Products.ERP5Type.Cache import CachingMethod, clearCache
+from Products.ERP5Type.Base import _aq_reset
class TestERP5Type(ERP5TypeTestCase, LogInterceptor):
@@ -244,7 +246,7 @@
clearCache()
self.assertEquals(cache2(), cached_var2)
- def test_afterCloneScript(self):
+ def test_07_afterCloneScript(self):
"""manage_afterClone can call a type based script."""
# setup the script for Person portal type
custom_skin = self.getPortal().portal_skins.custom
@@ -289,7 +291,7 @@
new_orga = folder[new_id]
self.assertEquals(new_orga.getTitle(), 'something')
- def test_AccessorGeneration(self):
+ def test_09_AccessorGeneration(self):
"""Tests accessor generation doesn't generate error messages.
"""
from Products.ERP5Type.Base import _aq_reset
@@ -301,7 +303,7 @@
orga.getId()
self._ignore_log_errors()
- def test_RenameObjects(self):
+ def test_10_RenameObjects(self):
"""Test object renaming.
As we overloaded some parts of OFS, it's better to test again some basic
features.
@@ -326,6 +328,52 @@
new_id = '%s_new' % id_
self.assertEquals(folder._getOb(new_id).getId(), new_id)
+ def test_11_ConstraintNotFound(self):
+ """
+ When a Constraint is not found while importing a PropertySheet, AttributeError
+ was raised, and generated a infinite loop.
+ This is a test to make sure this will not happens any more
+ """
+ # We will first define a new propertysheet
+ class_tool = self.getClassTool()
+
+ class_tool.newPropertySheet('TestPropertySheet')
+ text = """
+class TestPropertySheet:
+ \"\"\"
+ TestPropertySheet for this unit test
+ \"\"\"
+
+ _properties = (
+ { 'id' : 'strange_property',
+ 'description' : 'A local property description',
+ 'type' : 'string',
+ 'mode' : '' },
+ )
+
+ _constraints = (
+ { 'id' : 'toto',
+ 'description' : 'define a bad constraint',
+ 'type' : 'TestConstraintNotFoundClass',
+ },
+ )
+
+"""
+ class_tool.editPropertySheet('TestPropertySheet',text)
+ class_tool.importPropertySheet('TestPropertySheet')
+ # We set the property sheet on the portal type Organisation
+ type_tool = self.getTypeTool()
+ organisation_portal_type = type_tool['Organisation']
+ organisation_portal_type.setPropertySheetList(['TestPropertySheet'])
+ folder = self.getOrganisationModule()
+ _aq_reset()
+ # We check that we raise exception when we create new object
+ from Products.ERP5Type.Utils import ConstraintNotFound
+ organisation = self.assertRaises(ConstraintNotFound,folder.newContent,
+ portal_type='Organisation')
+
+
+
if __name__ == '__main__':
framework()
else:
More information about the Erp5-report
mailing list