diff --git a/common/djangoapps/course_groups/cohorts.py b/common/djangoapps/course_groups/cohorts.py index 9a6340c2bf..12a54e0673 100644 --- a/common/djangoapps/course_groups/cohorts.py +++ b/common/djangoapps/course_groups/cohorts.py @@ -265,13 +265,6 @@ def add_cohort(course_key, name): ) -class CohortConflict(Exception): - """ - Raised when user to be added is already in another cohort in same course. - """ - pass - - def add_user_to_cohort(cohort, username_or_email): """ Look up the given user, and if successful, add them to the specified cohort. @@ -307,17 +300,3 @@ def add_user_to_cohort(cohort, username_or_email): cohort.users.add(user) return (user, previous_cohort) - - -def delete_empty_cohort(course_key, name): - """ - Remove an empty cohort. Raise ValueError if cohort is not empty. - """ - cohort = get_cohort_by_name(course_key, name) - if cohort.users.exists(): - raise ValueError(_("You cannot delete non-empty cohort {cohort_name} in course {course_key}").format( - cohort_name=name, - course_key=course_key - )) - - cohort.delete() diff --git a/common/djangoapps/course_groups/tests/test_cohorts.py b/common/djangoapps/course_groups/tests/test_cohorts.py index 16d971dded..f92333d51c 100644 --- a/common/djangoapps/course_groups/tests/test_cohorts.py +++ b/common/djangoapps/course_groups/tests/test_cohorts.py @@ -408,34 +408,3 @@ class TestCohorts(django.test.TestCase): User.DoesNotExist, lambda: cohorts.add_user_to_cohort(first_cohort, "non_existent_username") ) - - def test_delete_empty_cohort(self): - """ - Make sure that cohorts.delete_empty_cohort() properly removes an empty cohort - for a given course. - """ - course = modulestore().get_course(self.toy_course_key) - user = UserFactory(username="Username", email="a@b.com") - empty_cohort = CohortFactory(course_id=course.id, name="EmptyCohort") - nonempty_cohort = CohortFactory(course_id=course.id, name="NonemptyCohort") - nonempty_cohort.users.add(user) - - cohorts.delete_empty_cohort(course.id, "EmptyCohort") - - # Make sure we cannot access the deleted cohort - self.assertRaises( - CourseUserGroup.DoesNotExist, - lambda: cohorts.get_cohort_by_id(course.id, empty_cohort.id) - ) - self.assertRaises( - ValueError, - lambda: cohorts.delete_empty_cohort(course.id, "NonemptyCohort") - ) - self.assertRaises( - CourseUserGroup.DoesNotExist, - lambda: cohorts.delete_empty_cohort(SlashSeparatedCourseKey('course', 'does_not', 'exist'), "EmptyCohort") - ) - self.assertRaises( - CourseUserGroup.DoesNotExist, - lambda: cohorts.delete_empty_cohort(course.id, "NonExistentCohort") - )