16 # You should have received a copy of the GNU Lesser General Public License along |
16 # You should have received a copy of the GNU Lesser General Public License along |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
18 |
18 |
19 from __future__ import with_statement |
19 from __future__ import with_statement |
20 |
20 |
|
21 from cubicweb import ValidationError |
21 from cubicweb.devtools.testlib import CubicWebTC |
22 from cubicweb.devtools.testlib import CubicWebTC |
22 from cubicweb import ValidationError |
|
23 from cubicweb.server.session import security_enabled |
23 from cubicweb.server.session import security_enabled |
|
24 |
24 |
25 |
25 def add_wf(self, etype, name=None, default=False): |
26 def add_wf(self, etype, name=None, default=False): |
26 if name is None: |
27 if name is None: |
27 name = etype |
28 name = etype |
28 wf = self.execute('INSERT Workflow X: X name %(n)s', {'n': unicode(name)}).get_entity(0, 0) |
29 return self.shell().add_workflow(name, etype, default=default, |
29 self.execute('SET WF workflow_of ET WHERE WF eid %(wf)s, ET name %(et)s', |
30 ensure_workflowable=False) |
30 {'wf': wf.eid, 'et': etype}) |
|
31 if default: |
|
32 self.execute('SET ET default_workflow WF WHERE WF eid %(wf)s, ET name %(et)s', |
|
33 {'wf': wf.eid, 'et': etype}) |
|
34 return wf |
|
35 |
31 |
36 def parse_hist(wfhist): |
32 def parse_hist(wfhist): |
37 return [(ti.previous_state.name, ti.new_state.name, |
33 return [(ti.previous_state.name, ti.new_state.name, |
38 ti.transition and ti.transition.name, ti.comment) |
34 ti.transition and ti.transition.name, ti.comment) |
39 for ti in wfhist] |
35 for ti in wfhist] |