[Erp5-report] r42896 nicolas.dumazet - /erp5/trunk/products/ERP5Type/tests/testConstraint.py

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Feb 1 16:31:53 CET 2011


Author: nicolas.dumazet
Date: Tue Feb  1 16:31:53 2011
New Revision: 42896

URL: http://svn.erp5.org?rev=42896&view=rev
Log:
convert most of this test to ZODB property sheets

Modified:
    erp5/trunk/products/ERP5Type/tests/testConstraint.py

Modified: erp5/trunk/products/ERP5Type/tests/testConstraint.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/testConstraint.py?rev=42896&r1=42895&r2=42896&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/testConstraint.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/testConstraint.py [utf8] Tue Feb  1 16:31:53 2011
@@ -1191,8 +1191,10 @@ class TestConstraint(PropertySheetTestCa
     self.assertEquals(1, len(obj._local_properties))
     self.assertEquals([], constraint.checkConsistency(obj))
     # now add a 'local_property' property defined on a property sheet
-    self._addProperty(obj.getPortalType(),
-                      "{'id': 'local_property', 'type': 'string'}")
+    self._addProperty(obj.getPortalType(), "FixLocalPropertiesString",
+                      portal_type="Standard Property",
+                      property_id="local_property",
+                      elementary_type="string")
     constraint.fixConsistency(obj)
     self.assertEquals((), obj._local_properties)
     self.assertEquals('1', obj.getLocalProperty())
@@ -1211,8 +1213,10 @@ class TestConstraint(PropertySheetTestCa
     self.assertEquals(1, len(obj._local_properties))
     #self.assertEquals([], constraint.checkConsistency(obj))
     # now add a 'local_property' property defined on a property sheet
-    self._addProperty(obj.getPortalType(),
-                      "{'id': 'local_property', 'type': 'float'}")
+    self._addProperty(obj.getPortalType(), "FixLocalPropertiesFloat",
+                      portal_type="Standard Property",
+                      property_id="local_property",
+                      elementary_type="float")
     constraint.fixConsistency(obj)
     self.assertEquals((), obj._local_properties)
     self.assertEquals(1.234, obj.getLocalProperty())
@@ -1230,18 +1234,20 @@ class TestConstraint(PropertySheetTestCa
     obj.edit(default_organisation_title='foo')
     self.assertEquals([], constraint.checkConsistency(obj))
     # now add a 'local_property' property defined on a property sheet
-    self._addProperty(obj.getPortalType(),
-                 ''' { 'id':         'organisation',
-                        'storage_id': 'default_organisation',
-                        'type':       'content',
-                        'portal_type': ('Organisation', ),
-                        'acquired_property_id': ('title', ),
-                        'mode':       'w', }''')
+    self._addProperty(obj.getPortalType(), "FixLocalPropertiesContent",
+                      portal_type="Acquired Property",
+                      commit=False,
+                      property_id="organisation",
+                      storage_id="default_organisation",
+                      elementary_type="content",
+                      content_portal_type="python: ('Organisation', )",
+                      content_acquired_property_id= ('title',))
     # this property suppose that we can add some Organisation inside
     # Organisation, so we temporary patch the type information.
     ti = self.getTypesTool().getTypeInfo(obj)
     allowed_types = ti.getTypeAllowedContentTypeList()
     ti._setTypeAllowedContentTypeList(allowed_types + ['Organisation'])
+    transaction.commit()
     try:
       constraint.fixConsistency(obj)
       self.assertEquals('foo', obj.getDefaultOrganisationTitle())
@@ -1263,9 +1269,9 @@ class TestConstraint(PropertySheetTestCa
     obj.edit(testing_category=obj.getRelativeUrl())
     self.assertEquals([], constraint.checkConsistency(obj))
     # now add a 'local_property' property defined on a property sheet
-    self._addPropertySheet(obj.getPortalType(),
-      property_sheet_code=\
-       '''class TestPropertySheet: _categories=('testing_category',)''')
+    self._addProperty(obj.getPortalType(), "FixForCategories",
+                      portal_type="Category Property",
+                      property_id="testing_category")
     # fix consistency
     constraint.fixConsistency(obj)
     # now we can use testing_category as any category accessor
@@ -1429,23 +1435,17 @@ class TestConstraint(PropertySheetTestCa
     person = self.portal.person_module.newContent(portal_type='Person')
     assignment = person.newContent(portal_type='Assignment')
     # add a source_title property on Assignment.
-    self._addPropertySheet('Assignment',
-      property_sheet_code=\
-      '''class TestPropertySheet:
-          _properties = (
-           {'id':'source_title',
-            'description':'The title of the source of this movement',
-            'type':'string',
-            'acquisition_base_category':('source',),
-            'acquisition_portal_type':('Category'),
-            'acquisition_accessor_id':'getTitle',
-            'mode':''},)
-          _constraints = (
-            { 'type': 'PropertyTypeValidity',
-              'id': 'type_check',
-              'description': "Type Validity Check Error",
-            }, )
-      ''')
+    self._addProperty('Assignment', "UnauthorizedCategory",
+                      commit=False,
+                      portal_type="Acquired Property",
+                      property_id="source_title",
+                      elementary_type="string",
+                      acquisition_base_category=('source',),
+                      acquisition_portal_type="python: ('Category',)",
+                      acquisition_accessor_id="getTitle")
+    self._addProperty('Assignment', "UnauthorizedCategory",
+                      portal_type="Property Type Validity Constraint",
+                      property_id="type_check")
     self.assertEquals([], person.checkConsistency())
     group3 = self.category_tool.restrictedTraverse(
       'group/testGroup3', self.category_tool.group.newContent(
@@ -1479,11 +1479,11 @@ class TestConstraint(PropertySheetTestCa
                    klass_name='PropertyTypeValidity',
                    id='multi_valuated_property', )
     obj = self._makeOne()
-    self._addProperty(obj.getPortalType(),
-                      '''{'id': 'multi_valuated_property',
-                          'type': 'float',
-                          'multivalued': 1,
-                          'mode':       'w', }''')
+    self._addProperty(obj.getPortalType(), "ForMultivalued",
+                      property_id="multi_valuated_property",
+                      portal_type="Standard Property",
+                      elementary_type="float",
+                      multivalued=1)
     obj.edit(multi_valuated_property=[1.0, 2.0, 3.0, ])
     self.assertEquals([], constraint.checkConsistency(obj))
 



More information about the Erp5-report mailing list