Commit b694e729 authored by Nicolas Dumazet's avatar Nicolas Dumazet

convert most of this test to ZODB property sheets


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42896 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 20085384
......@@ -1191,8 +1191,10 @@ class TestConstraint(PropertySheetTestCase):
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(PropertySheetTestCase):
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(PropertySheetTestCase):
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(PropertySheetTestCase):
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(PropertySheetTestCase):
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(PropertySheetTestCase):
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))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment