entities/test/unittest_wfobjs.py
branchstable
changeset 4644 021035b9a7ab
parent 4030 6cfe4faddf8c
child 4835 13b0b96d7982
--- a/entities/test/unittest_wfobjs.py	Fri Feb 19 09:34:14 2010 +0100
+++ b/entities/test/unittest_wfobjs.py	Fri Feb 19 09:36:26 2010 +0100
@@ -98,7 +98,7 @@
         trs = list(user.possible_transitions())
         self.assertEquals(len(trs), 1)
         self.assertEquals(trs[0].name, u'deactivate')
-        self.assertEquals(trs[0].destination().name, u'deactivated')
+        self.assertEquals(trs[0].destination(None).name, u'deactivated')
         # test a std user get no possible transition
         cnx = self.login('member')
         # fetch the entity using the new session
@@ -141,6 +141,27 @@
         trinfo = self._test_manager_deactivate(user)
         self.assertEquals(trinfo.transition.name, 'deactivate')
 
+    def test_goback_transition(self):
+        wf = self.session.user.current_workflow
+        asleep = wf.add_state('asleep')
+        wf.add_transition('rest', (wf.state_by_name('activated'), wf.state_by_name('deactivated')),
+                               asleep)
+        wf.add_transition('wake up', asleep)
+        user = self.create_user('stduser')
+        user.fire_transition('rest')
+        self.commit()
+        user.fire_transition('wake up')
+        self.commit()
+        self.assertEquals(user.state, 'activated')
+        user.fire_transition('deactivate')
+        self.commit()
+        user.fire_transition('rest')
+        self.commit()
+        user.fire_transition('wake up')
+        self.commit()
+        user.clear_all_caches()
+        self.assertEquals(user.state, 'deactivated')
+
     # XXX test managers can change state without matching transition
 
     def _test_stduser_deactivate(self):
@@ -207,7 +228,7 @@
         state3 = mwf.add_state(u'state3')
         swftr1 = mwf.add_wftransition(u'swftr1', swf, state1,
                                       [(swfstate2, state2), (swfstate3, state3)])
-        self.assertEquals(swftr1.destination().eid, swfstate1.eid)
+        self.assertEquals(swftr1.destination(None).eid, swfstate1.eid)
         # workflows built, begin test
         self.group = self.request().create_entity('CWGroup', name=u'grp1')
         self.commit()