'Make sure cohorts.get_cohort_by_name() properly finds a cohort by name for a given course.  Also verify that it
raises an error when the cohort is not found.'

def test_get_cohort_by_name(self):

    course = modulestore().get_course(self.toy_course_key)
    self.assertRaises(CourseUserGroup.DoesNotExist, (lambda : cohorts.get_cohort_by_name(course.id, 'CohortDoesNotExist')))
    cohort = CohortFactory(course_id=course.id, name='MyCohort')
    self.assertEqual(cohorts.get_cohort_by_name(course.id, 'MyCohort'), cohort)
    self.assertRaises(CourseUserGroup.DoesNotExist, (lambda : cohorts.get_cohort_by_name(CourseLocator('course', 'does_not', 'exist'), cohort)))
