Commit 606ad7ab by Greg Price

Remove dead code

parent c51e504e
...@@ -265,13 +265,6 @@ def add_cohort(course_key, name): ...@@ -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): def add_user_to_cohort(cohort, username_or_email):
""" """
Look up the given user, and if successful, add them to the specified cohort. 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): ...@@ -307,17 +300,3 @@ def add_user_to_cohort(cohort, username_or_email):
cohort.users.add(user) cohort.users.add(user)
return (user, previous_cohort) 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()
...@@ -408,34 +408,3 @@ class TestCohorts(django.test.TestCase): ...@@ -408,34 +408,3 @@ class TestCohorts(django.test.TestCase):
User.DoesNotExist, User.DoesNotExist,
lambda: cohorts.add_user_to_cohort(first_cohort, "non_existent_username") 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")
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment