From 49d320b997d9463ff4ee5032fc49666171bcfe4c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois-Xavier=20Algrain?= <fxalgrain@tiolive.com>
Date: Thu, 17 Feb 2011 14:37:34 +0000
Subject: [PATCH] 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
---
 product/ERP5Type/tests/testConstraint.py | 41 +++++++++++++-----------
 1 file changed, 22 insertions(+), 19 deletions(-)

diff --git a/product/ERP5Type/tests/testConstraint.py b/product/ERP5Type/tests/testConstraint.py
index 2e9cf09e9c..6538a41b9e 100644
--- a/product/ERP5Type/tests/testConstraint.py
+++ b/product/ERP5Type/tests/testConstraint.py
@@ -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]
-- 
2.30.9