예제 #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)
예제 #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)
예제 #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])
예제 #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])
예제 #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])
예제 #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])
예제 #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
예제 #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}))
예제 #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
예제 #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}))
예제 #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
예제 #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