Exemple #1
0
 def test_execute_success_no_kwargs(self):
     tid = gen_unique_id()
     tw = TaskRequest(mytask_no_kwargs.name, tid, [4], {})
     self.assertEqual(tw.execute(), 256)
     meta = default_backend.get_task_meta(tid)
     self.assertEqual(meta["result"], 256)
     self.assertEqual(meta["status"], states.SUCCESS)
Exemple #2
0
 def test_execute_fail(self):
     tid = gen_unique_id()
     tw = TaskRequest(mytask_raising.name, tid, [4], {"f": "x"})
     self.assertIsInstance(tw.execute(), ExceptionInfo)
     meta = default_backend.get_task_meta(tid)
     self.assertEqual(meta["status"], states.FAILURE)
     self.assertIsInstance(meta["result"], KeyError)
Exemple #3
0
 def test_execute_fail(self):
     tid = gen_unique_id()
     tw = TaskRequest(mytask_raising.name, tid, [4], {"f": "x"})
     self.assertIsInstance(tw.execute(), ExceptionInfo)
     meta = default_backend.get_task_meta(tid)
     self.assertEqual(meta["status"], states.FAILURE)
     self.assertIsInstance(meta["result"], KeyError)
Exemple #4
0
 def test_execute_success_no_kwargs(self):
     tid = gen_unique_id()
     tw = TaskRequest(mytask_no_kwargs.name, tid, [4], {})
     self.assertEqual(tw.execute(), 256)
     meta = default_backend.get_task_meta(tid)
     self.assertEqual(meta["result"], 256)
     self.assertEqual(meta["status"], states.SUCCESS)
Exemple #5
0
 def test_execute_ack(self):
     tid = gen_unique_id()
     tw = TaskRequest(mytask.name, tid, [4], {"f": "x"}, on_ack=on_ack)
     self.assertEqual(tw.execute(), 256)
     meta = default_backend.get_task_meta(tid)
     self.assertTrue(scratch["ACK"])
     self.assertEqual(meta["result"], 256)
     self.assertEqual(meta["status"], states.SUCCESS)
Exemple #6
0
 def test_execute_success_some_kwargs(self):
     tid = gen_unique_id()
     tw = TaskRequest(mytask_some_kwargs.name, tid, [4], {})
     self.assertEqual(tw.execute(logfile="foobaz.log"), 256)
     meta = default_backend.get_task_meta(tid)
     self.assertEqual(some_kwargs_scratchpad.get("logfile"), "foobaz.log")
     self.assertEqual(meta["result"], 256)
     self.assertEqual(meta["status"], states.SUCCESS)
Exemple #7
0
 def test_execute_success_some_kwargs(self):
     tid = gen_unique_id()
     tw = TaskRequest(mytask_some_kwargs.name, tid, [4], {})
     self.assertEqual(tw.execute(logfile="foobaz.log"), 256)
     meta = default_backend.get_task_meta(tid)
     self.assertEqual(some_kwargs_scratchpad.get("logfile"), "foobaz.log")
     self.assertEqual(meta["result"], 256)
     self.assertEqual(meta["status"], states.SUCCESS)
Exemple #8
0
 def test_execute_ack(self):
     tid = gen_unique_id()
     tw = TaskRequest(mytask.name, tid, [4], {"f": "x"}, on_ack=on_ack)
     self.assertEqual(tw.execute(), 256)
     meta = default_backend.get_task_meta(tid)
     self.assertTrue(scratch["ACK"])
     self.assertEqual(meta["result"], 256)
     self.assertEqual(meta["status"], states.SUCCESS)
def _does_taskmeta_include_date_done():
    """
    Create a celery task, run it and wait for the result, and then indicate
    whether a query for taskmeta includes a "date_done" attribute.
    """
    r = tasks_for_testing.task_a.delay()
    r.wait()  # ignore result
    from celery.backends import default_backend
    taskmeta = default_backend.get_task_meta(r.task_id)
    return "date_done" in taskmeta