Commit b18aa690 authored by Hervé Poulain's avatar Hervé Poulain

Add unit test for check the multivalued properties with the

PropertyTypeValidity.

Remove some useles white spaces.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@31639 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c41819aa
...@@ -79,8 +79,8 @@ class TestConstraint(PropertySheetTestCase): ...@@ -79,8 +79,8 @@ class TestConstraint(PropertySheetTestCase):
self.tic() self.tic()
def createCategories(self): def createCategories(self):
""" """
Light install create only base categories, so we create Light install create only base categories, so we create
some categories for testing them some categories for testing them
""" """
category_list = ['testGroup1', 'testGroup2'] category_list = ['testGroup1', 'testGroup2']
...@@ -90,7 +90,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -90,7 +90,7 @@ class TestConstraint(PropertySheetTestCase):
o = group.newContent(portal_type='Category', o = group.newContent(portal_type='Category',
id=category_id) id=category_id)
def stepDeleteObjectModuleContent(self, sequence=None, def stepDeleteObjectModuleContent(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Delete all objects in the module. Delete all objects in the module.
...@@ -121,7 +121,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -121,7 +121,7 @@ class TestConstraint(PropertySheetTestCase):
group=group1, group=group1,
) )
def stepSetObjectGroup(self, sequence=None, def stepSetObjectGroup(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Set a group to object Set a group to object
...@@ -133,7 +133,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -133,7 +133,7 @@ class TestConstraint(PropertySheetTestCase):
self.assertNotEquals( self.assertNotEquals(
object.getGroup(portal_type=()), object.getGroup(portal_type=()),
None ) None )
def stepSetObjectGroupOrganisation(self, sequence=None, def stepSetObjectGroupOrganisation(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
...@@ -145,7 +145,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -145,7 +145,7 @@ class TestConstraint(PropertySheetTestCase):
self.assertNotEquals( self.assertNotEquals(
object.getGroup(portal_type='Organisation'), object.getGroup(portal_type='Organisation'),
None ) None )
def stepSetObjectGroupList(self, sequence=None, def stepSetObjectGroupList(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
...@@ -157,7 +157,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -157,7 +157,7 @@ class TestConstraint(PropertySheetTestCase):
# object.edit(group_value_list=[group1, group2]) # object.edit(group_value_list=[group1, group2])
object.edit(group_list=['testGroup1', 'testGroup2']) object.edit(group_list=['testGroup1', 'testGroup2'])
def stepSetObjectTitle(self, sequence=None, def stepSetObjectTitle(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Set a different title value Set a different title value
...@@ -166,7 +166,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -166,7 +166,7 @@ class TestConstraint(PropertySheetTestCase):
object_title = self.object_title object_title = self.object_title
object.setTitle(object_title) object.setTitle(object_title)
def stepSetObjectNoneTitle(self, sequence=None, def stepSetObjectNoneTitle(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Set a different title value Set a different title value
...@@ -194,7 +194,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -194,7 +194,7 @@ class TestConstraint(PropertySheetTestCase):
object = sequence.get('object') object = sequence.get('object')
object_title = self.object_title object_title = self.object_title
object.edit(title=12345) object.edit(title=12345)
def stepSetObjectBadTypedProperty(self, sequence=None, def stepSetObjectBadTypedProperty(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
...@@ -206,7 +206,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -206,7 +206,7 @@ class TestConstraint(PropertySheetTestCase):
self.failUnless(not object.hasProperty(property_name)) self.failUnless(not object.hasProperty(property_name))
self.failUnless(object.getPropertyType(property_name) != 'int') self.failUnless(object.getPropertyType(property_name) != 'int')
object.setProperty(property_name, 12) object.setProperty(property_name, 12)
def stepSetObjectIntLocalProperty(self, sequence=None, def stepSetObjectIntLocalProperty(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
...@@ -232,7 +232,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -232,7 +232,7 @@ class TestConstraint(PropertySheetTestCase):
sequence.edit(constraint=constraint,) sequence.edit(constraint=constraint,)
return constraint return constraint
def stepCallCheckConsistency(self, sequence=None, def stepCallCheckConsistency(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Call checkConsistency of a Constraint. Call checkConsistency of a Constraint.
...@@ -244,7 +244,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -244,7 +244,7 @@ class TestConstraint(PropertySheetTestCase):
sequence.edit( sequence.edit(
error_list=error_list error_list=error_list
) )
def stepCallFixConsistency(self, sequence=None, def stepCallFixConsistency(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
...@@ -258,7 +258,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -258,7 +258,7 @@ class TestConstraint(PropertySheetTestCase):
error_list=error_list error_list=error_list
) )
def stepCallRelatedCheckConsistency(self, sequence=None, def stepCallRelatedCheckConsistency(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Call checkConsistency of a Constraint. Call checkConsistency of a Constraint.
...@@ -270,8 +270,8 @@ class TestConstraint(PropertySheetTestCase): ...@@ -270,8 +270,8 @@ class TestConstraint(PropertySheetTestCase):
sequence.edit( sequence.edit(
error_list=error_list error_list=error_list
) )
def stepCheckIfConstraintSucceeded(self, sequence=None, def stepCheckIfConstraintSucceeded(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Check that checkConsistency returns an empty list Check that checkConsistency returns an empty list
...@@ -280,7 +280,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -280,7 +280,7 @@ class TestConstraint(PropertySheetTestCase):
self.failIfDifferentSet(error_list, [], self.failIfDifferentSet(error_list, [],
"error_list : %s" % [x.message for x in error_list]) "error_list : %s" % [x.message for x in error_list])
def stepCheckIfConstraintFailed(self, sequence=None, def stepCheckIfConstraintFailed(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Check that checkConsistency does not return an empty list Check that checkConsistency does not return an empty list
...@@ -292,14 +292,14 @@ class TestConstraint(PropertySheetTestCase): ...@@ -292,14 +292,14 @@ class TestConstraint(PropertySheetTestCase):
for error in error_list: for error in error_list:
self.assertNotEquals('', self.assertNotEquals('',
error.getTranslatedMessage()) error.getTranslatedMessage())
def stepCreateConstraint(self, sequence=None,
def stepCreateConstraint(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Create a default Constraint Create a default Constraint
""" """
self._createGenericConstraint(sequence, self._createGenericConstraint(sequence,
klass_name='Constraint', klass_name='Constraint',
id='default_constraint', id='default_constraint',
description='constraint test') description='constraint test')
...@@ -320,33 +320,33 @@ class TestConstraint(PropertySheetTestCase): ...@@ -320,33 +320,33 @@ class TestConstraint(PropertySheetTestCase):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet) sequence_list.play(self, quiet=quiet)
def stepCreatePropertyExistence0(self, sequence=None, def stepCreatePropertyExistence0(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Create a PropertyExistence Constraint Create a PropertyExistence Constraint
""" """
self._createGenericConstraint(sequence, self._createGenericConstraint(sequence,
klass_name='PropertyExistence', klass_name='PropertyExistence',
id='property_existence', id='property_existence',
description='propertyExistence test') description='propertyExistence test')
def stepCreatePropertyExistence1(self, sequence=None, def stepCreatePropertyExistence1(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Create a PropertyExistence Constraint Create a PropertyExistence Constraint
""" """
self._createGenericConstraint(sequence, self._createGenericConstraint(sequence,
klass_name='PropertyExistence', klass_name='PropertyExistence',
id='property_existence', id='property_existence',
description='propertyExistence test', description='propertyExistence test',
not_defined_property=None) not_defined_property=None)
def stepCreatePropertyExistence1TrueCondition(self, sequence=None, def stepCreatePropertyExistence1TrueCondition(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Create a PropertyExistence Constraint with a true condition Create a PropertyExistence Constraint with a true condition
""" """
self._createGenericConstraint(sequence, self._createGenericConstraint(sequence,
klass_name='PropertyExistence', klass_name='PropertyExistence',
id='property_existence', id='property_existence',
description='propertyExistence test', description='propertyExistence test',
...@@ -354,12 +354,12 @@ class TestConstraint(PropertySheetTestCase): ...@@ -354,12 +354,12 @@ class TestConstraint(PropertySheetTestCase):
condition='python: object.getPortalType()' \ condition='python: object.getPortalType()' \
+ ' == "%s"' % self.object_portal_type) + ' == "%s"' % self.object_portal_type)
def stepCreatePropertyExistence1FalseCondition(self, sequence=None, def stepCreatePropertyExistence1FalseCondition(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Create a PropertyExistence Constraint with a false condition Create a PropertyExistence Constraint with a false condition
""" """
self._createGenericConstraint(sequence, self._createGenericConstraint(sequence,
klass_name='PropertyExistence', klass_name='PropertyExistence',
id='property_existence', id='property_existence',
description='propertyExistence test', description='propertyExistence test',
...@@ -367,12 +367,12 @@ class TestConstraint(PropertySheetTestCase): ...@@ -367,12 +367,12 @@ class TestConstraint(PropertySheetTestCase):
condition='python: object.getPortalType()' \ condition='python: object.getPortalType()' \
+ ' == "False_PortalTypeXXX123"') + ' == "False_PortalTypeXXX123"')
def stepCreatePropertyExistence2(self, sequence=None, def stepCreatePropertyExistence2(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Create a PropertyExistence Constraint Create a PropertyExistence Constraint
""" """
self._createGenericConstraint(sequence, self._createGenericConstraint(sequence,
klass_name='PropertyExistence', klass_name='PropertyExistence',
id='property_existence', id='property_existence',
description='propertyExistence test', description='propertyExistence test',
...@@ -461,12 +461,12 @@ class TestConstraint(PropertySheetTestCase): ...@@ -461,12 +461,12 @@ class TestConstraint(PropertySheetTestCase):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet) sequence_list.play(self, quiet=quiet)
def stepCreatePropertyTypeValidity(self, sequence=None, def stepCreatePropertyTypeValidity(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Create a PropertyExistence Constraint Create a PropertyExistence Constraint
""" """
self._createGenericConstraint(sequence, self._createGenericConstraint(sequence,
klass_name='PropertyTypeValidity', klass_name='PropertyTypeValidity',
id='property_type_validity', id='property_type_validity',
description='propertyTypeValidity test') description='propertyTypeValidity test')
...@@ -562,22 +562,22 @@ class TestConstraint(PropertySheetTestCase): ...@@ -562,22 +562,22 @@ class TestConstraint(PropertySheetTestCase):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet) sequence_list.play(self, quiet=quiet)
def stepCreateAttributeEquality0(self, sequence=None, def stepCreateAttributeEquality0(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Create a AttributeEquality Constraint Create a AttributeEquality Constraint
""" """
self._createGenericConstraint(sequence, self._createGenericConstraint(sequence,
klass_name='AttributeEquality', klass_name='AttributeEquality',
id='attribute_equality', id='attribute_equality',
description='AttributeEquality test') description='AttributeEquality test')
def stepCreateAttributeEquality1(self, sequence=None, def stepCreateAttributeEquality1(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Create a AttributeEquality Constraint Create a AttributeEquality Constraint
""" """
self._createGenericConstraint(sequence, self._createGenericConstraint(sequence,
klass_name='AttributeEquality', klass_name='AttributeEquality',
id='attribute_equality', id='attribute_equality',
description='AttributeEquality test', description='AttributeEquality test',
...@@ -628,44 +628,44 @@ class TestConstraint(PropertySheetTestCase): ...@@ -628,44 +628,44 @@ class TestConstraint(PropertySheetTestCase):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet) sequence_list.play(self, quiet=quiet)
def stepCreateCategoryExistence0(self, sequence=None, def stepCreateCategoryExistence0(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Create a PropertyExistence Constraint Create a PropertyExistence Constraint
""" """
self._createGenericConstraint(sequence, self._createGenericConstraint(sequence,
klass_name='CategoryExistence', klass_name='CategoryExistence',
id='category_existence', id='category_existence',
description='CategoryExistence test') description='CategoryExistence test')
def stepCreateCategoryExistence1(self, sequence=None, def stepCreateCategoryExistence1(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Create a PropertyExistence Constraint Create a PropertyExistence Constraint
""" """
self._createGenericConstraint(sequence, self._createGenericConstraint(sequence,
klass_name='CategoryExistence', klass_name='CategoryExistence',
id='category_existence', id='category_existence',
description='CategoryExistence test', description='CategoryExistence test',
unknown_base_category=None) unknown_base_category=None)
def stepCreateCategoryExistence2(self, sequence=None, def stepCreateCategoryExistence2(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Create a PropertyExistence Constraint Create a PropertyExistence Constraint
""" """
self._createGenericConstraint(sequence, self._createGenericConstraint(sequence,
klass_name='CategoryExistence', klass_name='CategoryExistence',
id='category_existence', id='category_existence',
description='CategoryExistence test', description='CategoryExistence test',
group=None) group=None)
def stepCreateCategoryExistence3(self, sequence=None, def stepCreateCategoryExistence3(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Create a PropertyExistence Constraint with portal_type Create a PropertyExistence Constraint with portal_type
""" """
self._createGenericConstraint(sequence, self._createGenericConstraint(sequence,
klass_name='CategoryExistence', klass_name='CategoryExistence',
id='category_existence', id='category_existence',
description='CategoryExistence test', description='CategoryExistence test',
...@@ -744,12 +744,12 @@ class TestConstraint(PropertySheetTestCase): ...@@ -744,12 +744,12 @@ class TestConstraint(PropertySheetTestCase):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet) sequence_list.play(self, quiet=quiet)
def stepCreateCategoryMembershipArity0(self, sequence=None, def stepCreateCategoryMembershipArity0(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Create a CategoryMembershipArity Constraint Create a CategoryMembershipArity Constraint
""" """
self._createGenericConstraint(sequence, self._createGenericConstraint(sequence,
klass_name='CategoryMembershipArity', klass_name='CategoryMembershipArity',
id='CategoryMembershipArity', id='CategoryMembershipArity',
description='CategoryMembershipArity test', description='CategoryMembershipArity test',
...@@ -758,12 +758,12 @@ class TestConstraint(PropertySheetTestCase): ...@@ -758,12 +758,12 @@ class TestConstraint(PropertySheetTestCase):
portal_type=('Category', ), portal_type=('Category', ),
base_category=('group', )) base_category=('group', ))
def stepCreateCategoryMembershipArity1(self, sequence=None, def stepCreateCategoryMembershipArity1(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Create a CategoryMembershipArity Constraint Create a CategoryMembershipArity Constraint
""" """
self._createGenericConstraint(sequence, self._createGenericConstraint(sequence,
klass_name='CategoryMembershipArity', klass_name='CategoryMembershipArity',
id='CategoryMembershipArity', id='CategoryMembershipArity',
description='CategoryMembershipArity test', description='CategoryMembershipArity test',
...@@ -772,12 +772,12 @@ class TestConstraint(PropertySheetTestCase): ...@@ -772,12 +772,12 @@ class TestConstraint(PropertySheetTestCase):
portal_type=('Category', ), portal_type=('Category', ),
base_category=('group', )) base_category=('group', ))
def stepCreateCategoryMembershipArity2(self, sequence=None, def stepCreateCategoryMembershipArity2(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Create a CategoryMembershipArity Constraint Create a CategoryMembershipArity Constraint
""" """
self._createGenericConstraint(sequence, self._createGenericConstraint(sequence,
klass_name='CategoryMembershipArity', klass_name='CategoryMembershipArity',
id='CategoryMembershipArity', id='CategoryMembershipArity',
description='CategoryMembershipArity test', description='CategoryMembershipArity test',
...@@ -786,12 +786,12 @@ class TestConstraint(PropertySheetTestCase): ...@@ -786,12 +786,12 @@ class TestConstraint(PropertySheetTestCase):
portal_type=('Category', ), portal_type=('Category', ),
base_category=('group', )) base_category=('group', ))
def stepCreateCategoryMembershipArity3(self, sequence=None, def stepCreateCategoryMembershipArity3(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Create a CategoryMembershipArity Constraint Create a CategoryMembershipArity Constraint
""" """
self._createGenericConstraint(sequence, self._createGenericConstraint(sequence,
klass_name='CategoryMembershipArity', klass_name='CategoryMembershipArity',
id='CategoryMembershipArity', id='CategoryMembershipArity',
description='CategoryMembershipArity test', description='CategoryMembershipArity test',
...@@ -800,12 +800,12 @@ class TestConstraint(PropertySheetTestCase): ...@@ -800,12 +800,12 @@ class TestConstraint(PropertySheetTestCase):
portal_type=('Category', ), portal_type=('Category', ),
base_category=('group', )) base_category=('group', ))
def stepCreateCategoryMembershipArity4(self, sequence=None, def stepCreateCategoryMembershipArity4(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Create a CategoryMembershipArity Constraint Create a CategoryMembershipArity Constraint
""" """
self._createGenericConstraint(sequence, self._createGenericConstraint(sequence,
klass_name='CategoryMembershipArity', klass_name='CategoryMembershipArity',
id='CategoryMembershipArity', id='CategoryMembershipArity',
description='CategoryMembershipArity test', description='CategoryMembershipArity test',
...@@ -980,7 +980,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -980,7 +980,7 @@ class TestConstraint(PropertySheetTestCase):
self.assertNotEquals('', message_list[0].getTranslatedMessage()) self.assertNotEquals('', message_list[0].getTranslatedMessage())
obj.setGroup('testGroup1') obj.setGroup('testGroup1')
self.assertEquals(0, len(constraint.checkConsistency(obj))) self.assertEquals(0, len(constraint.checkConsistency(obj)))
def test_CategoryAcquiredMembershipArityNoMax(self): def test_CategoryAcquiredMembershipArityNoMax(self):
obj = self._makeOne() obj = self._makeOne()
constraint = self._createGenericConstraint( constraint = self._createGenericConstraint(
...@@ -994,15 +994,14 @@ class TestConstraint(PropertySheetTestCase): ...@@ -994,15 +994,14 @@ class TestConstraint(PropertySheetTestCase):
self.assertNotEquals('', message_list[0].getTranslatedMessage()) self.assertNotEquals('', message_list[0].getTranslatedMessage())
obj.setGroup('testGroup1') obj.setGroup('testGroup1')
self.assertEquals(0, len(constraint.checkConsistency(obj))) self.assertEquals(0, len(constraint.checkConsistency(obj)))
def stepCreateCategoryRelatedMembershipArity0(self, sequence=None,
def stepCreateCategoryRelatedMembershipArity0(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Create a CategoryMembershipArity Constraint Create a CategoryMembershipArity Constraint
""" """
self._createGenericConstraint( self._createGenericConstraint(
sequence, sequence,
klass_name='CategoryRelatedMembershipArity', klass_name='CategoryRelatedMembershipArity',
id='CategoryRelatedMembershipArity', id='CategoryRelatedMembershipArity',
description='CategoryRelatedMembershipArity test', description='CategoryRelatedMembershipArity test',
...@@ -1011,13 +1010,13 @@ class TestConstraint(PropertySheetTestCase): ...@@ -1011,13 +1010,13 @@ class TestConstraint(PropertySheetTestCase):
portal_type=('Organisation', ), portal_type=('Organisation', ),
base_category=('group', )) base_category=('group', ))
def stepCreateCategoryRelatedMembershipArity1(self, sequence=None, def stepCreateCategoryRelatedMembershipArity1(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Create a CategoryMembershipArity Constraint Create a CategoryMembershipArity Constraint
""" """
self._createGenericConstraint( self._createGenericConstraint(
sequence, sequence,
klass_name='CategoryRelatedMembershipArity', klass_name='CategoryRelatedMembershipArity',
id='CategoryRelatedMembershipArity', id='CategoryRelatedMembershipArity',
description='CategoryRelatedMembershipArity test', description='CategoryRelatedMembershipArity test',
...@@ -1026,13 +1025,13 @@ class TestConstraint(PropertySheetTestCase): ...@@ -1026,13 +1025,13 @@ class TestConstraint(PropertySheetTestCase):
portal_type=('Organisation', ), portal_type=('Organisation', ),
base_category=('group', )) base_category=('group', ))
def stepCreateCategoryRelatedMembershipArity2(self, sequence=None, def stepCreateCategoryRelatedMembershipArity2(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
Create a CategoryMembershipArity Constraint Create a CategoryMembershipArity Constraint
""" """
self._createGenericConstraint( self._createGenericConstraint(
sequence, sequence,
klass_name='CategoryRelatedMembershipArity', klass_name='CategoryRelatedMembershipArity',
id='CategoryRelatedMembershipArity', id='CategoryRelatedMembershipArity',
description='CategoryRelatedMembershipArity test', description='CategoryRelatedMembershipArity test',
...@@ -1135,7 +1134,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -1135,7 +1134,7 @@ class TestConstraint(PropertySheetTestCase):
obj = self._makeOne() obj = self._makeOne()
obj.manage_addProperty('dummy_boolean_property', True, type='boolean') obj.manage_addProperty('dummy_boolean_property', True, type='boolean')
self.assertEquals([], obj.checkConsistency()) self.assertEquals([], obj.checkConsistency())
def test_BooleanPropertiesPropertyTypeValidityFix(self): def test_BooleanPropertiesPropertyTypeValidityFix(self):
"""Tests PropertyTypeValidity can fix boolean values. """Tests PropertyTypeValidity can fix boolean values.
""" """
...@@ -1147,7 +1146,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -1147,7 +1146,7 @@ class TestConstraint(PropertySheetTestCase):
# should be fixed now # should be fixed now
self.assertEquals([], obj.checkConsistency()) self.assertEquals([], obj.checkConsistency())
self.failUnless(obj.getPropertyType(prop_name)) self.failUnless(obj.getPropertyType(prop_name))
def test_TALESConstraint(self): def test_TALESConstraint(self):
"""Tests TALESConstraint """Tests TALESConstraint
""" """
...@@ -1161,7 +1160,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -1161,7 +1160,7 @@ class TestConstraint(PropertySheetTestCase):
message_list = constraint.checkConsistency(obj) message_list = constraint.checkConsistency(obj)
self.assertEquals(1, len(message_list)) self.assertEquals(1, len(message_list))
self.assertNotEquals('', message_list[0].getTranslatedMessage()) self.assertNotEquals('', message_list[0].getTranslatedMessage())
def test_TALESConstraintInvalidExpression(self): def test_TALESConstraintInvalidExpression(self):
"""Tests TALESConstraint with an invalid expression """Tests TALESConstraint with an invalid expression
""" """
...@@ -1189,7 +1188,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -1189,7 +1188,7 @@ class TestConstraint(PropertySheetTestCase):
id='tales_constraint', id='tales_constraint',
expression='error: " ') expression='error: " ')
self.assertRaises(CompilerError, constraint.checkConsistency, obj) self.assertRaises(CompilerError, constraint.checkConsistency, obj)
def test_PropertyTypeValidityFixLocalPropertiesString(self): def test_PropertyTypeValidityFixLocalPropertiesString(self):
"""Tests PropertyTypeValidity can repairs local property when this property """Tests PropertyTypeValidity can repairs local property when this property
is added on the class later, and this property is already in the good type. is added on the class later, and this property is already in the good type.
...@@ -1209,7 +1208,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -1209,7 +1208,7 @@ class TestConstraint(PropertySheetTestCase):
self.assertEquals('1', obj.getLocalProperty()) self.assertEquals('1', obj.getLocalProperty())
obj.edit(local_property='something else') obj.edit(local_property='something else')
self.assertEquals('something else', obj.getLocalProperty()) self.assertEquals('something else', obj.getLocalProperty())
def test_PropertyTypeValidityFixLocalPropertiesFloat(self): def test_PropertyTypeValidityFixLocalPropertiesFloat(self):
"""Tests PropertyTypeValidity can repairs local property when this property """Tests PropertyTypeValidity can repairs local property when this property
is added on the class later, and this property type changed. is added on the class later, and this property type changed.
...@@ -1229,7 +1228,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -1229,7 +1228,7 @@ class TestConstraint(PropertySheetTestCase):
self.assertEquals(1.234, obj.getLocalProperty()) self.assertEquals(1.234, obj.getLocalProperty())
obj.edit(local_property=3) obj.edit(local_property=3)
self.assertEquals(3., obj.getLocalProperty()) self.assertEquals(3., obj.getLocalProperty())
def test_PropertyTypeValidityFixLocalPropertiesContent(self): def test_PropertyTypeValidityFixLocalPropertiesContent(self):
"""Tests PropertyTypeValidity can repairs local property of type content """Tests PropertyTypeValidity can repairs local property of type content
when this property is added on the class later. when this property is added on the class later.
...@@ -1344,7 +1343,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -1344,7 +1343,7 @@ class TestConstraint(PropertySheetTestCase):
def stepSetObjectTitle0(self, sequence=None, sequence_list=None, **kw): def stepSetObjectTitle0(self, sequence=None, sequence_list=None, **kw):
""" """
Set valid Title to Object Set valid Title to Object
""" """
object = sequence.get('object') object = sequence.get('object')
object.setTitle(self.object_title) object.setTitle(self.object_title)
...@@ -1385,7 +1384,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -1385,7 +1384,7 @@ class TestConstraint(PropertySheetTestCase):
CheckIfConstraintSucceeded \ CheckIfConstraintSucceeded \
' '
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
# Test Constraint with invalid Title # Test Constraint with invalid Title
# Not match with regex # Not match with regex
sequence_string = '\ sequence_string = '\
CreateObject \ CreateObject \
...@@ -1418,7 +1417,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -1418,7 +1417,7 @@ class TestConstraint(PropertySheetTestCase):
self.assertEquals(message.class_name, 'StringAttributeMatch') self.assertEquals(message.class_name, 'StringAttributeMatch')
obj.setTitle('a') obj.setTitle('a')
self.assertEquals(obj.checkConsistency(), []) self.assertEquals(obj.checkConsistency(), [])
def test_OverrideMessage(self): def test_OverrideMessage(self):
# messages can be overriden in property sheet # messages can be overriden in property sheet
obj = self._makeOne() obj = self._makeOne()
...@@ -1428,7 +1427,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -1428,7 +1427,7 @@ class TestConstraint(PropertySheetTestCase):
'''class TestPropertySheet: '''class TestPropertySheet:
_constraints = ( _constraints = (
{ 'id': 'testing_constraint', { 'id': 'testing_constraint',
'message_attribute_does_not_match': 'message_attribute_does_not_match':
'Attribute ${attribute_name} does not match', 'Attribute ${attribute_name} does not match',
'type': 'StringAttributeMatch', 'type': 'StringAttributeMatch',
'title': 'a.*', },) 'title': 'a.*', },)
...@@ -1479,6 +1478,24 @@ class TestConstraint(PropertySheetTestCase): ...@@ -1479,6 +1478,24 @@ class TestConstraint(PropertySheetTestCase):
self.assertNotEquals("Attribute source_title should be of type string but is of type <type 'int'>", self.assertNotEquals("Attribute source_title should be of type string but is of type <type 'int'>",
str(error_list[0].getMessage())) str(error_list[0].getMessage()))
def test_PropertyTypeValidityForMultivaluedProperty(self):
"""
This test allows to check that a multivalued property which defines a
type is composed of a list of elements of this type.
"""
constraint = self._createGenericConstraint(
klass_name='PropertyTypeValidity',
id='multi_valuated_property', )
obj = self._makeOne()
self._addProperty(obj.getPortalType(),
'''{'id': 'multi_valuated_property',
'type': 'float',
'multivalued': 1,
'mode': 'w', }''')
obj.edit(multi_valuated_property=[1.0, 2.0, 3.0, ])
self.assertEquals([], constraint.checkConsistency(obj))
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestConstraint)) suite.addTest(unittest.makeSuite(TestConstraint))
......
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