def start_failures(self): """ Mock Start method of bulk processor where all records fail """ logging.getLogger('default').info('processed') response: List[crew.MessageProcessorResult] = [ crew.MessageProcessorResult(self.messages[0], self.failed_statuses[0]), crew.MessageProcessorResult(self.messages[1], self.failed_statuses[1]) ] return response
def start_partial_failures(self): """ Mock Start method of bulk processor where there are parital failures """ logging.getLogger('default').info('processed') response: List[crew.MessageProcessorResult] = [ crew.MessageProcessorResult(self.messages[0], self.partial_statuses[0]), crew.MessageProcessorResult(self.messages[1], self.partial_statuses[1]) ] return response
def start(self): """ Mock Start method of bulk processor for successful records """ logging.getLogger('default').info('processed') response: List[crew.MessageProcessorResult] = [ crew.MessageProcessorResult(self.messages[0], self.success_statuses[0]), crew.MessageProcessorResult(self.messages[1], self.success_statuses[1]) ] return response
def test_bulk_poll_queue_success(self): """ Assert output from BulkMsgprocessor and TestWorker for all successful records """ results: List[crew.MessageProcessorResult] = BulkMsgProcessor.start( self) expected_msg1: crew.Message = deepcopy(self.messages[0]) assert results[0] == crew.MessageProcessorResult( expected_msg1, crew.ResultStatus.SUCCESS) expected_msg2: crew.Message = deepcopy(self.messages[1]) assert results[1] == crew.MessageProcessorResult( expected_msg2, crew.ResultStatus.SUCCESS) # Assert entries are deleted delete_entries = TestWorker.bulk_poll_queue(results) assert delete_entries == True
def test_bulk_poll_queue_failures(self): """ Assert output from BulkMsgprocessor and TestWorker for failed records """ results: List[ crew.MessageProcessorResult] = BulkMsgProcessor.start_failures( self) expected_msg1: crew.Message = deepcopy(self.messages[0]) assert results[0] == crew.MessageProcessorResult( expected_msg1, crew.ResultStatus.ERROR) expected_msg2: crew.Message = deepcopy(self.messages[1]) assert results[1] == crew.MessageProcessorResult( expected_msg2, crew.ResultStatus.ERROR) delete_entries = TestWorker.bulk_poll_queue(results) # Assert entries are not deleted since all records have failed assert delete_entries == False