'Verify that correct programs are returned when the user is enrolled in a
single course run appearing in multiple programs.'

def test_shared_enrollment_engagement(self, mock_get_programs):

    (shared_course_run_key, solo_course_run_key) = (generate_course_run_key() for __ in range(2))
    batch = [ProgramFactory(courses=[CourseFactory(course_runs=[CourseRunFactory(key=shared_course_run_key)])]) for __ in range(2)]
    joint_programs = sorted(batch, key=(lambda program: program['title']))
    data = (joint_programs + [ProgramFactory(courses=[CourseFactory(course_runs=[CourseRunFactory(key=solo_course_run_key)])]), ProgramFactory()])
    mock_get_programs.return_value = data
    self._create_enrollments(solo_course_run_key, shared_course_run_key)
    meter = ProgramProgressMeter(self.site, self.user)
    self._attach_detail_url(data)
    programs = data[:3]
    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, [])
