示例#1
0
 def test_set_result_fw_not_found(self, m_session_transaction, m_FileExt,
                                  m_log):
     m_session = MagicMock()
     m_session_transaction().__enter__.return_value = m_session
     m_FileExt.load_from_ext_id.side_effect = IrmaDatabaseError
     with self.assertRaises(IrmaDatabaseError):
         module.set_result("filewebid", "probe", "result")
示例#2
0
def scan_result(file_ext_id, probe, result):
    try:
        log.debug("result for file_ext: %s probe: %s", file_ext_id, probe)
        scan_ctrl.handle_output_files(file_ext_id, result)
        scan_ctrl.set_result(file_ext_id, probe, result)
    except IrmaDatabaseError as e:
        log.exception(e)
        raise scan_result.retry(countdown=2, max_retries=3, exc=e)
示例#3
0
 def test_set_result_fw_not_found(self,
                                  m_session_transaction,
                                  m_FileExt,
                                  m_log):
     m_session = MagicMock()
     m_session_transaction().__enter__.return_value = m_session
     m_FileExt.load_from_ext_id.side_effect = IrmaDatabaseError
     with self.assertRaises(IrmaDatabaseError):
         module.set_result("filewebid", "probe", "result")
示例#4
0
def scan_result(self, file_ext_id, probe, result):
    max_retries = 3
    try:
        log.debug("file_ext: %s result from probe %s retry: %d",
                  file_ext_id, probe, self.request.retries)
        scan_ctrl.handle_output_files(file_ext_id, result)
        scan_ctrl.set_result(file_ext_id, probe, result)
    except IrmaDatabaseError as e:
        log.exception(e)
        raise self.retry(countdown=2, max_retries=max_retries, exc=e)
示例#5
0
 def test_set_result(self, m_session_transaction, m_FileExt):
     filewebid = "filewebid"
     probe = "probe"
     m_session = MagicMock()
     m_session_transaction().__enter__.return_value = m_session
     m_file_ext, pr1 = MagicMock(), MagicMock()
     pr1.doc = "ProbeResult"
     file1 = MagicMock()
     m_file_ext.file = file1
     m_file_ext.probe_results = [pr1]
     m_FileExt.load_from_ext_id.return_value = m_file_ext
     result = {'status': 1, 'type': "something"}
     module.set_result(filewebid, probe, result)
     m_file_ext.set_result.assert_called_once_with(probe, result)
     m_FileExt.load_from_ext_id.assert_called_with(filewebid,
                                                   session=m_session)
示例#6
0
 def test_set_result(self, m_session_transaction, m_FileExt):
     filewebid = "filewebid"
     probe = "probe"
     m_session = MagicMock()
     m_session_transaction().__enter__.return_value = m_session
     m_file_ext, pr1 = MagicMock(), MagicMock()
     pr1.doc = "ProbeResult"
     file1 = MagicMock()
     m_file_ext.file = file1
     m_file_ext.probe_results = [pr1]
     m_FileExt.load_from_ext_id.return_value = m_file_ext
     result = {'status': 1, 'type': "something"}
     module.set_result(filewebid, probe, result)
     m_file_ext.set_result.assert_called_once_with(probe, result)
     m_FileExt.load_from_ext_id.assert_called_with(filewebid,
                                                   session=m_session)
示例#7
0
def scan_result_error(self, parent_taskid, file_ext_id, probe, result):
    log.debug("Error result file_ext: %s probe %s", file_ext_id, probe)
    result["error"] = "Error raised during result insert"
    result["status"] = -1
    scan_ctrl.handle_output_files(file_ext_id, result, error_case=True)
    scan_ctrl.set_result(file_ext_id, probe, result)