'Verify that only one task is enqueued for a user with multiple eligible
course run certificates.'

def test_handle_username_dedup(self, mock_task, mock_get_programs):

    data = [ProgramFactory(courses=[CourseFactory(course_runs=[CourseRunFactory(key=self.course_run_key), CourseRunFactory(key=self.alternate_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.alice, course_id=self.alternate_course_run_key, mode=MODES.verified, status=CertificateStatuses.downloadable)
    call_command('backpopulate_program_credentials', commit=True)
    mock_task.assert_called_once_with(self.alice.username)
