Skip to content
Snippets Groups Projects
Commit 264cec0c authored by Sanford Student's avatar Sanford Student
Browse files

EDUCATOR-2689: retire ManualEnrollmentAudit

parent 2b48649a
No related merge requests found
......@@ -2117,6 +2117,14 @@ class ManualEnrollmentAudit(models.Model):
manual_enrollment = None
return manual_enrollment
@classmethod
def retire_manual_enrollments(cls, enrollments, retired_email):
"""
Removes PII (enrolled_email and reason) from any rows corresponding to
the enrollment passed in. Bubbles up any exceptions.
"""
return cls.objects.filter(enrollment__in=enrollments).update(reason="", enrolled_email=retired_email)
class CourseEnrollmentAllowed(DeletableByUserValue, models.Model):
"""
......
......@@ -24,6 +24,8 @@ from student.models import (
CourseEnrollment,
CourseEnrollmentAllowed,
PendingEmailChange,
ManualEnrollmentAudit,
ALLOWEDTOENROLL_TO_ENROLLED,
PendingNameChange
)
from student.tests.factories import CourseEnrollmentFactory, UserFactory
......@@ -297,3 +299,52 @@ class TestCourseEnrollmentAllowed(TestCase):
email=self.email
)
self.assertTrue(user_search_results.exists())
class TestManualEnrollmentAudit(SharedModuleStoreTestCase):
"""
Tests for the ManualEnrollmentAudit model.
"""
@classmethod
def setUpClass(cls):
super(TestManualEnrollmentAudit, cls).setUpClass()
cls.course = CourseFactory()
cls.other_course = CourseFactory()
cls.user = UserFactory()
cls.instructor = UserFactory(username='staff', is_staff=True)
def test_retirement(self):
"""
Tests that calling the retirement method for a specific enrollment retires
the enrolled_email and reason columns of each row associated with that
enrollment.
"""
enrollment = CourseEnrollment.enroll(self.user, self.course.id)
other_enrollment = CourseEnrollment.enroll(self.user, self.other_course.id)
ManualEnrollmentAudit.create_manual_enrollment_audit(
self.instructor, self.user.email, ALLOWEDTOENROLL_TO_ENROLLED,
'manually enrolling unenrolled user', enrollment
)
ManualEnrollmentAudit.create_manual_enrollment_audit(
self.instructor, self.user.email, ALLOWEDTOENROLL_TO_ENROLLED,
'manually enrolling unenrolled user again', enrollment
)
ManualEnrollmentAudit.create_manual_enrollment_audit(
self.instructor, self.user.email, ALLOWEDTOENROLL_TO_ENROLLED,
'manually enrolling unenrolled user', other_enrollment
)
ManualEnrollmentAudit.create_manual_enrollment_audit(
self.instructor, self.user.email, ALLOWEDTOENROLL_TO_ENROLLED,
'manually enrolling unenrolled user again', other_enrollment
)
self.assertTrue(ManualEnrollmentAudit.objects.filter(enrollment=enrollment).exists())
# retire the ManualEnrollmentAudit objects associated with the above enrollments
enrollments = CourseEnrollment.objects.filter(user=self.user)
ManualEnrollmentAudit.retire_manual_enrollments(enrollments=enrollments, retired_email="xxx")
self.assertTrue(ManualEnrollmentAudit.objects.filter(enrollment=enrollment).exists())
self.assertFalse(ManualEnrollmentAudit.objects.filter(enrollment=enrollment).exclude(
enrolled_email="xxx"
))
self.assertFalse(ManualEnrollmentAudit.objects.filter(enrollment=enrollment).exclude(
reason=""
))
......@@ -2,6 +2,7 @@
import datetime
import json
from unittest import skip
import ddt
from nose.plugins.attrib import attr
......@@ -231,6 +232,7 @@ class VideoBumperEventsTest(VideoEventsTestMixin):
}
self.course_fixture.add_advanced_settings(additional_data)
@skip("student: 5/2/18: flaky test")
@ddt.data(
('edx.video.bumper.skipped', watch_video_and_skip),
('edx.video.bumper.dismissed', watch_video_and_dismiss),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment