'Verify that completed programs are correctly identified.'

@mock.patch((UTILS_MODULE + '.ProgramProgressMeter.completed_course_runs'), new_callable=mock.PropertyMock)
def test_completed_programs(self, mock_completed_course_runs, mock_get_programs):

    data = ProgramFactory.create_batch(3)
    mock_get_programs.return_value = data
    program_uuids = []
    course_run_keys = []
    for program in data:
        program_uuids.append(program['uuid'])
        for course in program['courses']:
            for course_run in course['course_runs']:
                course_run_keys.append(course_run['key'])
    meter = ProgramProgressMeter(self.site, self.user)
    self.assertEqual(meter.completed_programs, [])
    self._create_enrollments(*course_run_keys)
    mock_completed_course_runs.return_value = [{'course_run_id': course_run_key, 'type': MODES.verified} for course_run_key in course_run_keys]
    meter = ProgramProgressMeter(self.site, self.user)
    self.assertEqual(meter.completed_programs, program_uuids)
