entities/test/unittest_wfobjs.py
changeset 10092 f0363da0b5a0
parent 9752 5df3ac51a91a
child 10280 2cdab5e33542
--- a/entities/test/unittest_wfobjs.py	Thu Apr 03 14:17:16 2014 +0200
+++ b/entities/test/unittest_wfobjs.py	Thu Apr 17 12:34:51 2014 +0200
@@ -50,11 +50,13 @@
             wf = add_wf(shell, 'Company')
             wf.add_state(u'foo', initial=True)
             shell.commit()
-            wf.add_state(u'foo')
             with self.assertRaises(ValidationError) as cm:
-                shell.commit()
-            self.assertEqual({'name-subject': 'workflow already has a state of that name'},
+                wf.add_state(u'foo')
+            self.assertEqual({'name': u'name is part of violated unicity constraint',
+                              'state_of': u'state_of is part of violated unicity constraint',
+                              'unicity constraint': u'some relations violate a unicity constraint'},
                              cm.exception.errors)
+            shell.rollback()
             # no pb if not in the same workflow
             wf2 = add_wf(shell, 'Company')
             foo = wf2.add_state(u'foo', initial=True)
@@ -62,10 +64,12 @@
             # gnark gnark
             bar = wf.add_state(u'bar')
             shell.commit()
-            bar.cw_set(name=u'foo')
             with self.assertRaises(ValidationError) as cm:
-                shell.commit()
-            self.assertEqual({'name-subject': 'workflow already has a state of that name'},
+                bar.cw_set(name=u'foo')
+            shell.rollback()
+            self.assertEqual({'name': u'name is part of violated unicity constraint',
+                              'state_of': u'state_of is part of violated unicity constraint',
+                              'unicity constraint': u'some relations violate a unicity constraint'},
                              cm.exception.errors)
 
     def test_duplicated_transition(self):
@@ -74,10 +78,13 @@
             foo = wf.add_state(u'foo', initial=True)
             bar = wf.add_state(u'bar')
             wf.add_transition(u'baz', (foo,), bar, ('managers',))
-            wf.add_transition(u'baz', (bar,), foo)
             with self.assertRaises(ValidationError) as cm:
-                shell.commit()
-            self.assertEqual(cm.exception.errors, {'name-subject': 'workflow already has a transition of that name'})
+                wf.add_transition(u'baz', (bar,), foo)
+            self.assertEqual({'name': u'name is part of violated unicity constraint',
+                              'transition_of': u'transition_of is part of violated unicity constraint',
+                              'unicity constraint': u'some relations violate a unicity constraint'},
+                             cm.exception.errors)
+            shell.rollback()
             # no pb if not in the same workflow
             wf2 = add_wf(shell, 'Company')
             foo = wf.add_state(u'foo', initial=True)
@@ -87,10 +94,13 @@
             # gnark gnark
             biz = wf.add_transition(u'biz', (bar,), foo)
             shell.commit()
-            biz.cw_set(name=u'baz')
             with self.assertRaises(ValidationError) as cm:
-                shell.commit()
-            self.assertEqual(cm.exception.errors, {'name-subject': 'workflow already has a transition of that name'})
+                biz.cw_set(name=u'baz')
+            shell.rollback()
+            self.assertEqual({'name': u'name is part of violated unicity constraint',
+                              'transition_of': u'transition_of is part of violated unicity constraint',
+                              'unicity constraint': u'some relations violate a unicity constraint'},
+                             cm.exception.errors)
 
 
 class WorkflowTC(CubicWebTC):