예제 #1
0
 def test003_async_call_raise(self):
     app = MagicMock()
     app.send_task.side_effect = TimeoutError("whatever")
     path, name = "p_test", "n_test"
     expected = "Celery error - %s" % name
     with self.assertRaises(IrmaTaskError) as context:
         module.async_call(app, path, name)
     self.assertEqual(str(context.exception), expected)
예제 #2
0
 def test004_async_call_ok(self):
     app = MagicMock()
     path, name, karg = "p_test", "n_test", "k_test"
     expected = ("s_test", "r_test")
     args = (("%s.%s" % (path, name),), {"karg": karg})
     app.send_task.return_value = expected
     result = module.async_call(app, path, name, karg=karg)
     self.assertEqual(result, expected)
     self.assertEqual(app.send_task.call_args, args)
예제 #3
0
def scan_launch(scanid):
    """ send a task to launch the scan """
    async_call(frontend_app,
               "frontend.tasks",
               "scan_launch",
               args=(scanid,))
예제 #4
0
def scan_flush(scanid):
    """ send a task to the brain to flush the scan files"""
    return async_call(brain_app, BRAIN_SCAN_TASKS, "scan_flush", args=[scanid])
예제 #5
0
def scan_launch(scanid, scan_request):
    """ send a task to the brain to start the scan """
    return async_call(brain_app,
                      BRAIN_SCAN_TASKS,
                      "scan",
                      args=[scanid, scan_request])
예제 #6
0
def scan_flush(scanid):
    """ send a task to the brain to flush the scan files"""
    return async_call(brain_app,
                      "brain.tasks",
                      "scan_flush",
                      args=[scanid])
예제 #7
0
def scan_launch(scanid, scan_request):
    """ send a task to the brain to start the scan """
    return async_call(brain_app,
                      "brain.tasks",
                      "scan",
                      args=[scanid, scan_request])