'Make sure cohorts.get_cohort() randomizes properly.'

def test_auto_cohorting_randomization(self):

    course = modulestore().get_course(self.toy_course_key)
    self.assertFalse(cohorts.is_course_cohorted(course.id))
    groups = ['group_{0}'.format(n) for n in range(5)]
    config_course_cohorts(course, is_cohorted=True, auto_cohorts=groups)
    for i in range(100):
        user = UserFactory(username='test_{0}'.format(i), email='a@b{0}.com'.format(i))
        cohorts.get_cohort(user, course.id)
    for cohort_name in groups:
        cohort = cohorts.get_cohort_by_name(course.id, cohort_name)
        num_users = cohort.users.count()
        self.assertGreater(num_users, 1)
        self.assertLess(num_users, 50)
