[tests] use migration api to create workflow stable
authorJulien Jehannet <julien@smaf.org>
Wed, 19 Jan 2011 21:49:29 +0100
branchstable
changeset 6868 2d40f3c48f31
parent 6867 f691757792f9
child 6869 900cb9b1b687
[tests] use migration api to create workflow Prefer high-level migration api thru admin session instead of raw rql in helper method
entities/test/unittest_wfobjs.py
--- a/entities/test/unittest_wfobjs.py	Fri Jan 21 12:20:59 2011 +0100
+++ b/entities/test/unittest_wfobjs.py	Wed Jan 19 21:49:29 2011 +0100
@@ -18,20 +18,16 @@
 
 from __future__ import with_statement
 
+from cubicweb import ValidationError
 from cubicweb.devtools.testlib import CubicWebTC
-from cubicweb import ValidationError
 from cubicweb.server.session import security_enabled
 
+
 def add_wf(self, etype, name=None, default=False):
     if name is None:
         name = etype
-    wf = self.execute('INSERT Workflow X: X name %(n)s', {'n': unicode(name)}).get_entity(0, 0)
-    self.execute('SET WF workflow_of ET WHERE WF eid %(wf)s, ET name %(et)s',
-                 {'wf': wf.eid, 'et': etype})
-    if default:
-        self.execute('SET ET default_workflow WF WHERE WF eid %(wf)s, ET name %(et)s',
-                     {'wf': wf.eid, 'et': etype})
-    return wf
+    return self.shell().add_workflow(name, etype, default=default,
+                                     ensure_workflowable=False)
 
 def parse_hist(wfhist):
     return [(ti.previous_state.name, ti.new_state.name,