Beispiel #1
0
 def test_sync_call_raise(self):
     app = MagicMock()
     app.send_task.side_effect = TimeoutError("whatever")
     path, name, timeout = "p_test", "n_test", "t_test"
     expected = "Celery timeout - %s" % name
     with self.assertRaises(IrmaTaskError) as context:
         module.sync_call(app, path, name, timeout)
     self.assertEqual(str(context.exception), expected)
Beispiel #2
0
 def test_sync_call_raise(self):
     app = MagicMock()
     app.send_task.side_effect = TimeoutError("whatever")
     path, name, timeout = "p_test", "n_test", "t_test"
     expected = "Celery timeout - %s" % name
     with self.assertRaises(IrmaTaskError) as context:
         module.sync_call(app, path, name, timeout)
     self.assertEqual(str(context.exception), expected)
Beispiel #3
0
def scan_cancel(scan_id):
    """ send a task to the brain to cancel all remaining subtasks """
    return sync_call(brain_app,
                     BRAIN_SCAN_TASKS,
                     "scan_cancel",
                     timeout,
                     args=[scan_id])
Beispiel #4
0
def scan_progress(scan_id):
    """ send a task to the brain asking for status of subtasks launched """
    return sync_call(brain_app,
                     BRAIN_SCAN_TASKS,
                     "scan_progress",
                     timeout,
                     args=[scan_id])
Beispiel #5
0
def scan_cancel(scan_id):
    """ send a task to the brain to cancel all remaining subtasks """
    return sync_call(brain_app,
                     BRAIN_SCAN_TASKS,
                     "scan_cancel",
                     timeout,
                     args=[scan_id])
Beispiel #6
0
def scan_progress(scan_id):
    """ send a task to the brain asking for status of subtasks launched """
    return sync_call(brain_app,
                     BRAIN_SCAN_TASKS,
                     "scan_progress",
                     timeout,
                     args=[scan_id])
Beispiel #7
0
def probe_list():
    """ send a task to the brain asking for active probe list """
    (retcode, res) = sync_call(brain_app, BRAIN_SCAN_TASKS, "probe_list",
                               timeout)
    if retcode != IrmaReturnCode.success:
        raise IrmaTaskError(res)
    if len(res) == 0:
        raise IrmaCoreError("no probe available")
    return res
Beispiel #8
0
 def test_sync_call_ok(self):
     app = MagicMock()
     path, name, timeout, karg = "p_test", "n_test", "t_test", "k_test"
     expected = ("s_test", "r_test")
     args = (("%s.%s" % (path, name),), {"karg": karg})
     app.send_task().get.return_value = expected
     result = module.sync_call(app, path, name, timeout, karg=karg)
     self.assertEqual(result, expected)
     self.assertEqual(app.send_task.call_args, args)
     self.assertEqual(app.send_task().get.call_args,
                      (tuple(), {"timeout": timeout}))
Beispiel #9
0
def probe_list():
    """ send a task to the brain asking for active probe list """
    (retcode, res) = sync_call(brain_app,
                               BRAIN_SCAN_TASKS,
                               "probe_list",
                               timeout)
    if retcode != IrmaReturnCode.success:
        raise IrmaTaskError(res)
    if len(res) == 0:
        raise IrmaCoreError("no probe available")
    return res
Beispiel #10
0
 def test_sync_call_ok(self):
     app = MagicMock()
     path, name, timeout, karg = "p_test", "n_test", "t_test", "k_test"
     expected = ("s_test", "r_test")
     args = (("%s.%s" % (path, name),), {"karg": karg})
     app.send_task().get.return_value = expected
     result = module.sync_call(app, path, name, timeout, karg=karg)
     self.assertEqual(result, expected)
     self.assertEqual(app.send_task.call_args, args)
     self.assertEqual(app.send_task().get.call_args,
                      (tuple(), {"timeout": timeout}))
Beispiel #11
0
def mimetype_filter_scan_request(scan_request):
    """ send a task to the brain asking for mimetype filtering
        on probe list
    """
    (retcode, res) = sync_call(brain_app,
                               BRAIN_SCAN_TASKS,
                               "mimetype_filter_scan_request",
                               timeout,
                               args=[scan_request])
    if retcode != IrmaReturnCode.success:
        raise IrmaTaskError(res)
    return res
Beispiel #12
0
def mimetype_filter_scan_request(scan_request):
    """ send a task to the brain asking for mimetype filtering
        on probe list
    """
    (retcode, res) = sync_call(brain_app,
                               BRAIN_SCAN_TASKS,
                               "mimetype_filter_scan_request",
                               timeout,
                               args=[scan_request])
    if retcode != IrmaReturnCode.success:
        raise IrmaTaskError(res)
    return res