[hooks] force status to failed if status not updated by checker
authorPaul Tonelli <paul.tonelli@logilab.fr>
Mon, 07 Apr 2014 18:59:37 +0200
changeset 1485 b772de6bc982
parent 1484 05ddb62b92b4
child 1486 882e316ee83b
[hooks] force status to failed if status not updated by checker normally, the testexecution status is updated by the narvalbot. However, if the recipe code fails the transition to fail is fired, but the testexecution is not changed. In case of a 'publish recipe', this is an issue as only a single testexecution must be in the 'waiting execution' state. This patch adds a test showing the issue and the associated hook modification.
hooks.py
test/unittest_hooks.py
--- a/hooks.py	Mon Apr 07 14:11:29 2014 +0200
+++ b/hooks.py	Mon Apr 07 18:59:37 2014 +0200
@@ -306,6 +306,9 @@
     def __call__(self):
         trinfo = self.entity
         te = trinfo.for_entity
+        if te.status == u'waiting execution':
+            # this should only happen if error in recipe script
+            te.set_attributes(status=u'error')
         if te.status_changes():
             view = self._cw.vreg['views'].select(
                 'apycot.notif.exstchange', self._cw, rset=te.as_rset(),
--- a/test/unittest_hooks.py	Mon Apr 07 14:11:29 2014 +0200
+++ b/test/unittest_hooks.py	Mon Apr 07 18:59:37 2014 +0200
@@ -343,6 +343,18 @@
         self.assertEqual(len(rset_after_lgc3), len(rset_before_lgc3))
         self.assertEqual(len(rset_after_lgc), 1 + len(rset_before_lgc))
 
+    def test_error_in_recipe(self):
+        """this testcase should check what happens when a recipe does not have
+        the correct code and crashes before sending any status, the status should be"""
+        te = self.lgc.start(self.lgce, branch=u'default')
+        self.commit()
+        te.cw_adapt_to('IWorkflowable').fire_transition('start')
+        self.commit()
+        te.cw_adapt_to('IWorkflowable').fire_transition('fail')
+        self.commit()
+        #the status should not be waiting execution !
+        self.assertNotEqual(u'waiting execution', te.status)
+
 
 class ComputedStartModeTC(ApycotBaseTC):