Use new property sheet. Change the constraint type to test registration and...

Use new property sheet. Change the constraint type to test registration and override of message because 
the old is not migrated yet


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43424 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9180b754
......@@ -1393,20 +1393,22 @@ class TestConstraint(PropertySheetTestCase):
# constraint are registred in property sheets
obj = self._makeOne()
obj.setTitle('b')
self._addPropertySheet(obj.getPortalType(),
property_sheet_code=\
'''class TestPropertySheet:
_constraints = (
{ 'id': 'testing_constraint',
'type': 'StringAttributeMatch',
'title': 'a.*', },)
''')
property_sheet = self._addProperty(
obj.getPortalType(),
"TestRegisterWithPropertySheet",
commit=True,
property_id="title_constraint",
portal_type='Attribute Equality Constraint',
constraint_attribute_name = 'title',
constraint_attribute_value = 'string:a',
)
consistency_message_list = obj.checkConsistency()
self.assertEquals(1, len(consistency_message_list))
message = consistency_message_list[0]
from Products.ERP5Type.ConsistencyMessage import ConsistencyMessage
self.assertTrue(isinstance(message, ConsistencyMessage))
self.assertEquals(message.class_name, 'StringAttributeMatch')
self.assertEquals(message.class_name, 'Temporary Attribute Equality Constraint')
obj.setTitle('a')
self.assertEquals(obj.checkConsistency(), [])
......@@ -1414,16 +1416,17 @@ class TestConstraint(PropertySheetTestCase):
# messages can be overriden in property sheet
obj = self._makeOne()
obj.setTitle('b')
self._addPropertySheet(obj.getPortalType(),
property_sheet_code=\
'''class TestPropertySheet:
_constraints = (
{ 'id': 'testing_constraint',
'message_attribute_does_not_match':
'Attribute ${attribute_name} does not match',
'type': 'StringAttributeMatch',
'title': 'a.*', },)
''')
property_sheet = self._addProperty(
obj.getPortalType(),
"TestOverrideMessage",
commit=True,
property_id="title_constraint",
portal_type='Attribute Equality Constraint',
constraint_attribute_name = 'title',
constraint_attribute_value = 'string:a',
message_invalid_attribute_value='Attribute ${attribute_name} does not match',
)
consistency_message_list = obj.checkConsistency()
self.assertEquals(1, len(consistency_message_list))
message = consistency_message_list[0]
......
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