'Ensures mode_slug is a valid mode for course_id. Will raise an error if invalid.'

@classmethod
def ensure_valid_mode(cls, mode_slug, course_id):

    if (mode_slug is None):
        raise ValueError('Cannot    create    a    CourseModeTarget    without    specifying    a    mode_slug.')
    try:
        validate_course_mode(unicode(course_id), mode_slug, include_expired=True)
    except CourseModeNotFoundError:
        raise ValueError('Track    {track}    does    not    exist    in    course    {course_id}'.format(track=mode_slug, course_id=course_id))
