'Verify course and program certificates are found when present. Only one
course run certificate should be returned for each course when the user
has earned certificates in multiple runs of the same course.'

def test_get_certificates(self, mock_get_credentials):

    expected = []
    for course in self.program['courses']:
        for (index, course_run) in enumerate(course['course_runs']):
            course_run['certificate_url'] = self.course_certificate_url
            if (index == 0):
                expected.append({'type': 'course', 'title': course_run['title'], 'url': self.course_certificate_url})
    expected.append({'type': 'program', 'title': self.program['title'], 'url': self.program_certificate_url})
    mock_get_credentials.return_value = [{'certificate_url': self.program_certificate_url}]
    certificates = get_certificates(self.user, self.program)
    self.assertEqual(certificates, expected)
