137 self.execute('INSERT RQLExpression X: X exprtype "ERQLExpression", ' |
137 self.execute('INSERT RQLExpression X: X exprtype "ERQLExpression", ' |
138 'X expression "U has_update_permission X", T condition X ' |
138 'X expression "U has_update_permission X", T condition X ' |
139 'WHERE T name "deactivate"') |
139 'WHERE T name "deactivate"') |
140 self._test_stduser_deactivate() |
140 self._test_stduser_deactivate() |
141 |
141 |
142 def _init_wf_with_shared_state_or_tr(self): |
|
143 req = self.request() |
|
144 etypes = dict(self.execute('Any N, ET WHERE ET is CWEType, ET name N' |
|
145 ', ET name IN ("CWGroup", "Bookmark")')) |
|
146 self.grpwf = req.create_entity('Workflow', ('workflow_of', 'ET'), |
|
147 ET=etypes['CWGroup'], name=u'group workflow') |
|
148 self.bmkwf = req.execute('Any X WHERE X is Workflow, X workflow_of ET, ET name "Bookmark"').get_entity(0, 0) |
|
149 self.state1 = self.grpwf.add_state(u'state1', initial=True) |
|
150 self.execute('SET S state_of WF WHERE S eid %(s)s, WF eid %(wf)s', |
|
151 {'s': self.state1.eid, 'wf': self.bmkwf.eid}) |
|
152 self.execute('SET WF initial_state S WHERE S eid %(s)s, WF eid %(wf)s', |
|
153 {'s': self.state1.eid, 'wf': self.bmkwf.eid}) |
|
154 self.state2 = self.grpwf.add_state(u'state2') |
|
155 self.group = self.add_entity('CWGroup', name=u't1') |
|
156 self.bookmark = self.add_entity('Bookmark', title=u'111', path=u'/view') |
|
157 # commit to link to the initial state |
|
158 self.commit() |
|
159 |
|
160 def test_transitions_selection(self): |
|
161 """ |
|
162 ------------------------ tr1 ----------------- |
|
163 | state1 (CWGroup, Bookmark) | ------> | state2 (CWGroup) | |
|
164 ------------------------ ----------------- |
|
165 | tr2 ------------------ |
|
166 `------> | state3 (Bookmark) | |
|
167 ------------------ |
|
168 """ |
|
169 self._init_wf_with_shared_state_or_tr() |
|
170 state3 = self.bmkwf.add_state(u'state3') |
|
171 tr1 = self.grpwf.add_transition(u'tr1', (self.state1,), self.state2) |
|
172 tr2 = self.bmkwf.add_transition(u'tr2', (self.state1,), state3) |
|
173 transitions = list(self.group.possible_transitions()) |
|
174 self.assertEquals(len(transitions), 1) |
|
175 self.assertEquals(transitions[0].name, 'tr1') |
|
176 transitions = list(self.bookmark.possible_transitions()) |
|
177 self.assertEquals(len(transitions), 1) |
|
178 self.assertEquals(transitions[0].name, 'tr2') |
|
179 |
|
180 |
|
181 def test_transitions_selection2(self): |
|
182 """ |
|
183 ------------------------ tr1 (Bookmark) ----------------------- |
|
184 | state1 (CWGroup, Bookmark) | -------------> | state2 (CWGroup,Bookmark) | |
|
185 ------------------------ ----------------------- |
|
186 | tr2 (CWGroup) | |
|
187 `---------------------------------/ |
|
188 """ |
|
189 self._init_wf_with_shared_state_or_tr() |
|
190 self.execute('SET S state_of WF WHERE S eid %(s)s, WF eid %(wf)s', |
|
191 {'s': self.state2.eid, 'wf': self.bmkwf.eid}) |
|
192 tr1 = self.bmkwf.add_transition(u'tr1', (self.state1,), self.state2) |
|
193 tr2 = self.grpwf.add_transition(u'tr2', (self.state1,), self.state2) |
|
194 transitions = list(self.group.possible_transitions()) |
|
195 self.assertEquals(len(transitions), 1) |
|
196 self.assertEquals(transitions[0].name, 'tr2') |
|
197 transitions = list(self.bookmark.possible_transitions()) |
|
198 self.assertEquals(len(transitions), 1) |
|
199 self.assertEquals(transitions[0].name, 'tr1') |
|
200 |
142 |
201 |
143 |
202 class CustomWorkflowTC(EnvBasedTC): |
144 class CustomWorkflowTC(EnvBasedTC): |
203 |
145 |
204 def setup_database(self): |
146 def setup_database(self): |