'Verify that failure to enqueue a task doesn\'t halt execution.'

@mock.patch((COMMAND_MODULE + '.logger.exception'))
def test_handle_enqueue_failure(self, mock_log, mock_task, mock_get_programs):

    def side_effect(username):
        'Simulate    failure    to    enqueue    a    task.'
        if (username == self.alice.username):
            raise Exception
    mock_task.side_effect = side_effect
    data = [ProgramFactory(courses=[CourseFactory(course_runs=[CourseRunFactory(key=self.course_run_key)])])]
    mock_get_programs.return_value = data
    GeneratedCertificateFactory(user=self.alice, course_id=self.course_run_key, mode=MODES.verified, status=CertificateStatuses.downloadable)
    GeneratedCertificateFactory(user=self.bob, course_id=self.course_run_key, mode=MODES.verified, status=CertificateStatuses.downloadable)
    call_command('backpopulate_program_credentials', commit=True)
    self.assertTrue(mock_log.called)
    calls = [mock.call(self.alice.username), mock.call(self.bob.username)]
    mock_task.assert_has_calls(calls, any_order=True)
