35 wf = add_wf(self, 'Company') |
35 wf = add_wf(self, 'Company') |
36 wf.add_state(u'foo', initial=True) |
36 wf.add_state(u'foo', initial=True) |
37 self.commit() |
37 self.commit() |
38 wf.add_state(u'foo') |
38 wf.add_state(u'foo') |
39 ex = self.assertRaises(ValidationError, self.commit) |
39 ex = self.assertRaises(ValidationError, self.commit) |
40 # XXX enhance message |
40 self.assertEquals(ex.errors, {'name': 'workflow already have a state of that name'}) |
41 self.assertEquals(ex.errors, {'state_of': 'unique constraint S name N, Y state_of O, Y name N failed'}) |
|
42 # no pb if not in the same workflow |
41 # no pb if not in the same workflow |
43 wf2 = add_wf(self, 'Company') |
42 wf2 = add_wf(self, 'Company') |
44 foo = wf2.add_state(u'foo', initial=True) |
43 foo = wf2.add_state(u'foo', initial=True) |
45 self.commit() |
44 self.commit() |
|
45 # gnark gnark |
|
46 bar = wf.add_state(u'bar') |
|
47 self.commit() |
|
48 print '*'*80 |
|
49 bar.set_attributes(name=u'foo') |
|
50 ex = self.assertRaises(ValidationError, self.commit) |
|
51 self.assertEquals(ex.errors, {'name': 'workflow already have a state of that name'}) |
46 |
52 |
47 def test_duplicated_transition(self): |
53 def test_duplicated_transition(self): |
48 wf = add_wf(self, 'Company') |
54 wf = add_wf(self, 'Company') |
49 foo = wf.add_state(u'foo', initial=True) |
55 foo = wf.add_state(u'foo', initial=True) |
50 bar = wf.add_state(u'bar') |
56 bar = wf.add_state(u'bar') |
51 wf.add_transition(u'baz', (foo,), bar, ('managers',)) |
57 wf.add_transition(u'baz', (foo,), bar, ('managers',)) |
52 wf.add_transition(u'baz', (bar,), foo) |
58 wf.add_transition(u'baz', (bar,), foo) |
53 ex = self.assertRaises(ValidationError, self.commit) |
59 ex = self.assertRaises(ValidationError, self.commit) |
54 # XXX enhance message |
60 self.assertEquals(ex.errors, {'name': 'workflow already have a transition of that name'}) |
55 self.assertEquals(ex.errors, {'transition_of': 'unique constraint S name N, Y transition_of O, Y name N failed'}) |
61 # no pb if not in the same workflow |
|
62 wf2 = add_wf(self, 'Company') |
|
63 foo = wf.add_state(u'foo', initial=True) |
|
64 bar = wf.add_state(u'bar') |
|
65 wf.add_transition(u'baz', (foo,), bar, ('managers',)) |
|
66 self.commit() |
|
67 # gnark gnark |
|
68 biz = wf.add_transition(u'biz', (bar,), foo) |
|
69 self.commit() |
|
70 biz.set_attributes(name=u'baz') |
|
71 ex = self.assertRaises(ValidationError, self.commit) |
|
72 self.assertEquals(ex.errors, {'name': 'workflow already have a transition of that name'}) |
56 |
73 |
57 |
74 |
58 class WorkflowTC(CubicWebTC): |
75 class WorkflowTC(CubicWebTC): |
59 |
76 |
60 def setup_database(self): |
77 def setup_database(self): |
373 wf = add_wf(self, 'Company') |
390 wf = add_wf(self, 'Company') |
374 wf.add_state('asleep', initial=True) |
391 wf.add_state('asleep', initial=True) |
375 self.execute('SET X custom_workflow WF WHERE X eid %(x)s, WF eid %(wf)s', |
392 self.execute('SET X custom_workflow WF WHERE X eid %(x)s, WF eid %(wf)s', |
376 {'wf': wf.eid, 'x': self.member.eid}) |
393 {'wf': wf.eid, 'x': self.member.eid}) |
377 ex = self.assertRaises(ValidationError, self.commit) |
394 ex = self.assertRaises(ValidationError, self.commit) |
378 self.assertEquals(ex.errors, {'custom_workflow': 'constraint S is ET, O workflow_of ET failed'}) |
395 self.assertEquals(ex.errors, {'custom_workflow': 'workflow isn\'t a workflow for this type'}) |
379 |
396 |
380 def test_del_custom_wf(self): |
397 def test_del_custom_wf(self): |
381 """member in some state shared by the new workflow, nothing has to be |
398 """member in some state shared by the new workflow, nothing has to be |
382 done |
399 done |
383 """ |
400 """ |