[Erp5-report] r33946 nicolas - /erp5/trunk/products/ERP5Type/tests/testConstraint.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Mar 22 14:21:43 CET 2010
Author: nicolas
Date: Mon Mar 22 14:21:43 2010
New Revision: 33946
URL: http://svn.erp5.org?rev=33946&view=rev
Log:
Test expected Behaviour of AttributUnicity Constraint
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=33946&r1=33945&r2=33946&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/testConstraint.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/testConstraint.py [utf8] Mon Mar 22 14:21:43 2010
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved.
@@ -1495,6 +1496,71 @@
obj.edit(multi_valuated_property=[1.0, 2.0, 3.0, ])
self.assertEquals([], constraint.checkConsistency(obj))
+ def stepValidateObject(self, sequence=None, sequence_list=None, **kw):
+ """
+ """
+ document = sequence.get('object')
+ document.validate()
+
+ def stepInvalidateObject(self, sequence=None, sequence_list=None, **kw):
+ """
+ """
+ document = sequence.get('object')
+ document.invalidate()
+
+ def stepCreateAttributeUnicityConstraint(self, sequence=None,
+ sequence_list=None, **kw):
+ """
+ Create a default Constraint
+ """
+ constraint = self._createGenericConstraint(sequence,
+ klass_name='AttributeUnicity',
+ id='title_unicity_constraint',
+ description='AttributeUnicity test',
+ title="python: {'portal_type': object.getPortalType(),"\
+ "'validation_state': 'validated', 'title': object.getTitle()}",
+ condition="object/getTitle")
+ sequence.set('constraint', constraint)
+
+ def test_08_AttributeUnicity(self, quiet=quiet, run=run_all_test):
+ """
+ Test attribute unicity
+ """
+ if not run: return
+ sequence_list = SequenceList()
+ # Test Constraint without unicity on title
+ sequence_string = '\
+ CreateObject \
+ ValidateObject \
+ SetObjectTitle \
+ Tic \
+ CreateAttributeUnicityConstraint \
+ CallCheckConsistency \
+ CheckIfConstraintSucceeded \
+ '
+
+ # invalidate object without Tic If zodb and catalog are not synchronized,
+ # The constraint should still working
+ sequence_string += '\
+ InvalidateObject \
+ CallCheckConsistency \
+ CheckIfConstraintSucceeded \
+ Tic \
+ ValidateObject \
+ Tic \
+ '
+
+ # Test Constraint with Two object with same title
+ sequence_string += '\
+ CreateObject \
+ SetObjectTitle \
+ Tic \
+ CallCheckConsistency \
+ CheckIfConstraintFailed \
+ '
+ sequence_list.addSequenceString(sequence_string)
+
+ sequence_list.play(self, quiet=quiet)
def test_suite():
suite = unittest.TestSuite()
More information about the Erp5-report
mailing list