def test039_handle_output_files_resubmit(self, m_session_transaction, m_Scan, m_File, m_append_new_files_to_scan, m_filter_children): m_scan, m_session = MagicMock(), MagicMock() m_session_transaction().__enter__.return_value = m_session m_scan.resubmit_files = True m_Scan.load_from_ext_id.return_value = m_scan uploaded_files = {'filename': 'filehash'} result = {'uploaded_files': uploaded_files} fw1 = MagicMock() m_append_new_files_to_scan.return_value = [fw1] m_parentfile = MagicMock() m_parentfile.children = [] m_filter_children.return_value = uploaded_files m_File.load_from_sha256.return_value = m_parentfile module.handle_output_files("scanid", "parent_file_hash", "probe", result) m_Scan.load_from_ext_id.assert_called_once_with("scanid", session=m_session) m_append_new_files_to_scan.assert_called_once_with(m_scan, uploaded_files, m_session) self.assertItemsEqual(m_parentfile.children, [fw1])
def scan_result(scanid, file_hash, probe, result): try: log.debug("scanid: %s file_hash: %s probe: %s", scanid, file_hash, probe) scan_ctrl.handle_output_files(scanid, file_hash, probe, result) scan_ctrl.set_result(scanid, file_hash, probe, result) except IrmaDatabaseError as e: log.exception(e) raise scan_result.retry(countdown=2, max_retries=3, exc=e)
def scan_result(scanid, file_hash, probe, result): try: log.debug("scanid: %s file_hash: %s probe: %s", scanid, file_hash, probe) scan_ctrl.handle_output_files(scanid, file_hash, probe, result) scan_ctrl.set_result(scanid, file_hash, probe, result) scan_ctrl.set_probe_tag(file_hash, probe, result) except IrmaDatabaseError as e: log.exception(e) raise scan_result.retry(countdown=2, max_retries=3, exc=e)
def test038_handle_output_files_resubmit_False(self, m_session_transaction, m_Scan, m_File): m_scan, m_session = MagicMock(), MagicMock() m_session_transaction().__enter__.return_value = m_session m_scan.resubmit_files = False m_Scan.load_from_ext_id.return_value = m_scan result = {'uploaded_files': []} module.handle_output_files("scanid", "parent_file_hash", "probe", result) m_Scan.load_from_ext_id.assert_called_once_with("scanid", session=m_session)
def test039_handle_output_files_resubmit(self, m_session_transaction, m_Scan, m_File, m_append_new_files_to_scan): m_scan, m_session = MagicMock(), MagicMock() m_session_transaction().__enter__.return_value = m_session m_scan.resubmit_files = True m_Scan.load_from_ext_id.return_value = m_scan uploaded_files = {} result = {'uploaded_files': uploaded_files} fw1 = MagicMock() m_append_new_files_to_scan.return_value = [fw1] m_parentfile = MagicMock() m_parentfile.children = [] m_File.load_from_sha256.return_value = m_parentfile module.handle_output_files("scanid", "parent_file_hash", "probe", result) m_Scan.load_from_ext_id.assert_called_once_with("scanid", session=m_session) m_append_new_files_to_scan.assert_called_once_with(m_scan, uploaded_files, m_session) self.assertItemsEqual(m_parentfile.children, [fw1])