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 bar.set_attributes(name=u'foo') |
|
49 ex = self.assertRaises(ValidationError, self.commit) |
|
50 self.assertEquals(ex.errors, {'name': 'workflow already have a state of that name'}) |
46 |
51 |
47 def test_duplicated_transition(self): |
52 def test_duplicated_transition(self): |
48 wf = add_wf(self, 'Company') |
53 wf = add_wf(self, 'Company') |
49 foo = wf.add_state(u'foo', initial=True) |
54 foo = wf.add_state(u'foo', initial=True) |
50 bar = wf.add_state(u'bar') |
55 bar = wf.add_state(u'bar') |
51 wf.add_transition(u'baz', (foo,), bar, ('managers',)) |
56 wf.add_transition(u'baz', (foo,), bar, ('managers',)) |
52 wf.add_transition(u'baz', (bar,), foo) |
57 wf.add_transition(u'baz', (bar,), foo) |
53 ex = self.assertRaises(ValidationError, self.commit) |
58 ex = self.assertRaises(ValidationError, self.commit) |
54 # XXX enhance message |
59 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'}) |
60 # no pb if not in the same workflow |
|
61 wf2 = add_wf(self, 'Company') |
|
62 foo = wf.add_state(u'foo', initial=True) |
|
63 bar = wf.add_state(u'bar') |
|
64 wf.add_transition(u'baz', (foo,), bar, ('managers',)) |
|
65 self.commit() |
|
66 # gnark gnark |
|
67 biz = wf.add_transition(u'biz', (bar,), foo) |
|
68 self.commit() |
|
69 biz.set_attributes(name=u'baz') |
|
70 ex = self.assertRaises(ValidationError, self.commit) |
|
71 self.assertEquals(ex.errors, {'name': 'workflow already have a transition of that name'}) |
56 |
72 |
57 |
73 |
58 class WorkflowTC(EnvBasedTC): |
74 class WorkflowTC(EnvBasedTC): |
59 |
75 |
60 def setup_database(self): |
76 def setup_database(self): |