예제 #1
0
 def test005_route_error(self):
     sig = MagicMock()
     m_options = MagicMock()
     sig.app.amqp.router.route.return_value = m_options
     m_options.pop.side_effect = KeyError()
     # should not raise
     module.route(sig)
예제 #2
0
def job_launch(ftpuser, frontend_scanid, filename, probe, job_id, task_id):
    """ send a task to the brain to flush the scan files"""
    hook_success = route(
        results_app.signature("brain.tasks.job_success",
                              [job_id]))
    hook_error = route(
        results_app.signature("brain.tasks.job_error",
                              [job_id]))
    task = async_call(probe_app,
                      "probe.tasks",
                      "probe_scan",
                      args=(ftpuser, frontend_scanid, filename),
                      queue=probe,
                      link=hook_success,
                      link_error=hook_error,
                      uuid=task_id)
    return task.id
예제 #3
0
def scan_result(file, probe, result):
    hook_error = route(frontend_app.signature("frontend_app.scan_result_error",
                       [file, probe, result]))
    async_call(frontend_app,
               "frontend_app",
               "scan_result",
               args=[file, probe, result],
               link_error=hook_error
               )
예제 #4
0
def scan_result(file, probe, result):
    hook_error = route(
        frontend_app.signature("frontend_app.scan_result_error",
                               [file, probe, result]))
    async_call(frontend_app,
               "frontend_app",
               "scan_result",
               args=[file, probe, result],
               link_error=hook_error)
예제 #5
0
 def test_job_launch(self, m_async_call):
     ftpuser = "******"
     filename = "filename"
     probe = "probe"
     task_id = "task_id"
     signature = module.results_app.signature
     hook_success = route(
         signature("brain.results_tasks.job_success", [filename, probe]))
     hook_error = route(
         signature("brain.results_tasks.job_error", [filename, probe]))
     module.job_launch(ftpuser, filename, probe, task_id)
     m_async_call.assert_called_once_with(module.probe_app,
                                          "probe.tasks",
                                          "probe_scan",
                                          args=(ftpuser, filename),
                                          routing_key=probe,
                                          link=hook_success,
                                          link_error=hook_error,
                                          task_id=task_id)
예제 #6
0
def job_launch(ftpuser, frontend_scanid, filename, probe, task_id):
    """ send a task to the brain to flush the scan files"""
    log.debug("scanid %s: ftpuser %s filename %s probe %s" +
              " task_id %s",
              frontend_scanid, ftpuser, filename, probe, task_id)
    hook_success = route(
        results_app.signature("brain.results_tasks.job_success",
                              [frontend_scanid, filename, probe]))
    hook_error = route(
        results_app.signature("brain.results_tasks.job_error",
                              [frontend_scanid, filename, probe]))
    task = async_call(probe_app,
                      "probe.tasks",
                      "probe_scan",
                      args=(ftpuser, frontend_scanid, filename),
                      routing_key=probe,
                      link=hook_success,
                      link_error=hook_error,
                      task_id=task_id)
    return task.id
예제 #7
0
 def test_job_launch(self, m_async_call):
     ftpuser = "******"
     filename = "filename"
     probe = "probe"
     task_id = "task_id"
     signature = module.results_app.signature
     hook_success = route(signature("brain.results_tasks.job_success",
                                    [filename, probe]))
     hook_error = route(signature("brain.results_tasks.job_error",
                                  [filename, probe]))
     exchange = probe + "_exchange"
     module.job_launch(ftpuser, filename, probe, task_id)
     m_async_call.assert_called_once_with(module.probe_app,
                                          "probe.tasks",
                                          "probe_scan",
                                          args=(ftpuser, filename),
                                          routing_key=probe,
                                          exchange=exchange,
                                          link=hook_success,
                                          link_error=hook_error,
                                          task_id=task_id)