def fail_scan(scan_id, message): ''' Set scan status to fail and set message to result_message ''' print 'fail scan' scan = Scan.objects.get(pk=int(scan_id)) previous_message = scan.result_message scan.result_message = previous_message + message scan.status = settings.SCAN_STATUS['fail'] scan.finish = datetime.now() scan.save() scan.set_task_status_free() notify_set = scan.scan_task.user.get_profile().notification if settings.NOTIFY_MODULES[notify_set]['id'] != 'None': notify_about_fail(scan.user, scan.scan_task.target, scan.id)
def fail_scan(scan_id, message): ''' Set scan status to fail and set message to result_message ''' print 'fail scan' scan = Scan.objects.get(pk=int(scan_id)) previous_message = scan.result_message scan.result_message = previous_message + message scan.status = settings.SCAN_STATUS['fail'] scan.finish = datetime.now() scan.save() scan.set_task_status_free() notify_set = scan.scan_task.user.get_profile().notification if settings.NOTIFY_MODULES[notify_set]['id'] != 'None': notify_about_fail(scan.user, scan.scan_task.target, scan.id)
def test_notify_about_fail(self): # Empty the test outbox mail.outbox = [] result = send_mail.notify_about_fail(self.user, self.scan.scan_task.target, self.scan.id) self.assertEqual(len(mail.outbox), 1) self.assertTrue(result)
def test_notify_about_fail(self): # Empty the test outbox mail.outbox = [] result = send_mail.notify_about_fail(self.user, self.scan.scan_task.target, self.scan.id) self.assertEqual(len(mail.outbox), 1) self.assertTrue(result)