def test001_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)
 def test001_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)
Example #3
0
def scan_cancel(scanid):
    """ send a task to the brain to cancel all remaining subtasks """
    return sync_call(brain_app,
                     BRAIN_SCAN_TASKS,
                     "scan_cancel",
                     timeout,
                     args=[scanid])
Example #4
0
def scan_progress(scanid):
    """ send a task to the brain asking for status of subtasks launched """
    return sync_call(brain_app,
                     BRAIN_SCAN_TASKS,
                     "scan_progress",
                     timeout,
                     args=[scanid])
Example #5
0
def scan_cancel(scanid):
    """ send a task to the brain to cancel all remaining subtasks """
    return sync_call(brain_app,
                     "brain.tasks",
                     "scan_cancel",
                     timeout,
                     args=[scanid])
Example #6
0
def scan_progress(scanid):
    """ send a task to the brain asking for status of subtasks launched """
    return sync_call(brain_app,
                     "brain.tasks",
                     "scan_progress",
                     timeout,
                     args=[scanid])
Example #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
 def test002_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}))
Example #9
0
def probe_list():
    """ send a task to the brain asking for active probe list """
    (retcode, res) = sync_call(brain_app,
                               "brain.tasks",
                               "probe_list",
                               timeout)
    if retcode != IrmaReturnCode.success:
        raise IrmaTaskError(res)
    if len(res) == 0:
        raise IrmaCoreError("no probe available")
    return res
Example #10
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
 def test002_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
     }))