[hooks/integrity & tests/entities] fix test to check for sibling error (set_operations yields a different order for constraints) stable
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Fri, 30 Apr 2010 19:07:06 +0200
branchstable
changeset 5450 269dcd14b92c
parent 5449 a7e1b316af03
child 5451 7b2e9f774028
[hooks/integrity & tests/entities] fix test to check for sibling error (set_operations yields a different order for constraints)
entities/test/unittest_wfobjs.py
hooks/integrity.py
--- a/entities/test/unittest_wfobjs.py	Fri Apr 30 18:24:29 2010 +0200
+++ b/entities/test/unittest_wfobjs.py	Fri Apr 30 19:07:06 2010 +0200
@@ -432,7 +432,7 @@
         self.execute('SET X custom_workflow WF WHERE X eid %(x)s, WF eid %(wf)s',
                      {'wf': wf.eid, 'x': self.member.eid})
         ex = self.assertRaises(ValidationError, self.commit)
-        self.assertEquals(ex.errors, {'custom_workflow-subject': 'workflow isn\'t a workflow for this type'})
+        self.assertEquals(ex.errors, {'in_state-subject': u"state doesn't apply to this entity's type"})
 
     def test_del_custom_wf(self):
         """member in some state shared by the new workflow, nothing has to be
--- a/hooks/integrity.py	Fri Apr 30 18:24:29 2010 +0200
+++ b/hooks/integrity.py	Fri Apr 30 19:07:06 2010 +0200
@@ -160,19 +160,18 @@
 
 
 class _CheckConstraintsOp(hook.LateOperation):
-    """check a new relation satisfy its constraints
-    """
+    """ check a new relation satisfy its constraints """
+
     def precommit_event(self):
         session = self.session
         for values in session.transaction_data.pop('check_constraints_op'):
-            eidfrom, rtype, eidto = values[:3]
+            eidfrom, rtype, eidto, constraints = values
             # first check related entities have not been deleted in the same
             # transaction
             if session.deleted_in_transaction(eidfrom):
                 return
             if session.deleted_in_transaction(eidto):
                 return
-            constraints = values[3:]
             for constraint in constraints:
                 # XXX
                 # * lock RQLConstraint as well?
@@ -205,7 +204,7 @@
                                                 'constraints')
         if constraints:
             hook.set_operation(self._cw, 'check_constraints_op',
-                               (self.eidfrom, self.rtype, self.eidto) + tuple(constraints),
+                               (self.eidfrom, self.rtype, self.eidto, tuple(constraints)),
                                _CheckConstraintsOp)
 
 
@@ -226,7 +225,7 @@
                                if isinstance(c, (RQLUniqueConstraint, RQLConstraint))]
                 if constraints:
                     hook.set_operation(self._cw, 'check_constraints_op',
-                                       (self.entity.eid, attr, None) + tuple(constraints),
+                                       (self.entity.eid, attr, None, tuple(constraints)),
                                        _CheckConstraintsOp)