diff --git a/test/test_secscan.py b/test/test_secscan.py index f5be0797f..72d8df891 100644 --- a/test/test_secscan.py +++ b/test/test_secscan.py @@ -506,7 +506,7 @@ class TestSecurityScanner(unittest.TestCase): # Test with an unknown notification. with HTTMock(get_notification, unknown_notification): worker = SecurityNotificationWorker(None) - self.assertFalse(worker.process_queue_item({ + self.assertFalse(worker.perform_notification_work({ 'Name': 'unknownnotification' })) @@ -517,7 +517,7 @@ class TestSecurityScanner(unittest.TestCase): with HTTMock(get_notification, delete_notification, unknown_notification): worker = SecurityNotificationWorker(None) - self.assertTrue(worker.process_queue_item(data)) + self.assertTrue(worker.perform_notification_work(data)) self.assertEquals(['GET-1', 'GET-2', 'DELETE'], pages_called) diff --git a/workers/queueworker.py b/workers/queueworker.py index 7cc223a22..cdd96d9e7 100644 --- a/workers/queueworker.py +++ b/workers/queueworker.py @@ -44,7 +44,11 @@ class QueueWorker(Worker): self.add_operation(self.run_watchdog, self._watchdog_period_seconds) def process_queue_item(self, job_details): - """ Return True if complete, False if it should be retried. """ + """ Processes the work for the given job. If the job fails and should be retried, + this method should raise a WorkerUnhealthyException. If the job should be marked + as permanently failed, it should raise a JobException. Otherwise, a successful return + of this method will remove the job from the queue as completed. + """ raise NotImplementedError('Workers must implement run.') def watchdog(self): diff --git a/workers/security_notification_worker.py b/workers/security_notification_worker.py index 03ac5da9a..554bb03a1 100644 --- a/workers/security_notification_worker.py +++ b/workers/security_notification_worker.py @@ -15,6 +15,14 @@ _LAYER_LIMIT = 100 # The number of layers to request on each page. class SecurityNotificationWorker(QueueWorker): def process_queue_item(self, data): + self.perform_notification_work(data) + + def perform_notification_work(self, data): + """ Performs the work for handling a security notification as referenced by the given data + object. Returns True on successful handling, False on non-retryable failure and raises + a JobException on retryable failure. + """ + notification_name = data['Name'] current_page = data.get('page', None)