Beispiel #1
0
 def test_worker_task_trace_handle_failure(self):
     tid = uuid()
     mytask.request.update({"id": tid})
     try:
         einfo = self.create_exception(ValueError("foo"))
         w = TraceInfo(states.FAILURE, einfo[1], einfo)
         w.handle_failure(mytask, store_errors=False)
         self.assertEqual(mytask.backend.get_status(tid), states.PENDING)
         w.handle_failure(mytask, store_errors=True)
         self.assertEqual(mytask.backend.get_status(tid), states.FAILURE)
     finally:
         mytask.request.clear()
Beispiel #2
0
 def test_worker_task_trace_handle_retry(self):
     from celery.exceptions import RetryTaskError
     tid = uuid()
     mytask.request.update({"id": tid})
     try:
         _, value_, _ = self.create_exception(ValueError("foo"))
         einfo = self.create_exception(RetryTaskError(str(value_),
                                       exc=value_))
         w = TraceInfo(states.RETRY, einfo[1], einfo)
         w.handle_retry(mytask, store_errors=False)
         self.assertEqual(mytask.backend.get_status(tid), states.PENDING)
         w.handle_retry(mytask, store_errors=True)
         self.assertEqual(mytask.backend.get_status(tid), states.RETRY)
     finally:
         mytask.request.clear()
Beispiel #3
0
 def test_worker_task_trace_handle_failure(self):
     tid = uuid()
     mytask.request.update({"id": tid})
     try:
         einfo = self.create_exception(ValueError("foo"))
         w = TraceInfo(states.FAILURE, einfo[1], einfo)
         w.handle_failure(mytask, store_errors=False)
         self.assertEqual(mytask.backend.get_status(tid), states.PENDING)
         w.handle_failure(mytask, store_errors=True)
         self.assertEqual(mytask.backend.get_status(tid), states.FAILURE)
     finally:
         mytask.request.clear()
Beispiel #4
0
 def test_worker_task_trace_handle_retry(self):
     from celery.exceptions import RetryTaskError
     tid = uuid()
     mytask.request.update({"id": tid})
     try:
         _, value_, _ = self.create_exception(ValueError("foo"))
         einfo = self.create_exception(
             RetryTaskError(str(value_), exc=value_))
         w = TraceInfo(states.RETRY, einfo[1], einfo)
         w.handle_retry(mytask, store_errors=False)
         self.assertEqual(mytask.backend.get_status(tid), states.PENDING)
         w.handle_retry(mytask, store_errors=True)
         self.assertEqual(mytask.backend.get_status(tid), states.RETRY)
     finally:
         mytask.request.clear()
 def test_without_exc_info(self):
     x = TraceInfo(states.SUCCESS)
     self.assertIsNone(x.exc_type)
     self.assertIsNone(x.exc_value)
     self.assertIsNone(x.tb)
     self.assertEqual(x.strtb, '')