'Verify that correct programs are returned in the correct order when the
user is enrolled in course runs appearing in programs.'

def test_mutiple_program_engagement(self, mock_get_programs):

    (newer_course_run_key, older_course_run_key) = (generate_course_run_key() for __ in range(2))
    data = [ProgramFactory(courses=[CourseFactory(course_runs=[CourseRunFactory(key=newer_course_run_key)])]), ProgramFactory(courses=[CourseFactory(course_runs=[CourseRunFactory(key=older_course_run_key)])]), ProgramFactory()]
    mock_get_programs.return_value = data
    self._create_enrollments(older_course_run_key, newer_course_run_key)
    meter = ProgramProgressMeter(self.site, self.user)
    self._attach_detail_url(data)
    programs = data[:2]
    self.assertEqual(meter.engaged_programs, programs)
    self._assert_progress(meter, *(ProgressFactory(uuid=program['uuid'], in_progress=1) for program in programs))
    self.assertEqual(meter.completed_programs, [])
