history on bulk create of enrollments (#23389)

fixes bug where bulk creation of enrollments caused no new history records to be created
This commit is contained in:
Zachary Hancock
2020-03-13 12:55:58 -04:00
committed by GitHub
parent 65cd6c5899
commit 2325b3af7a
2 changed files with 11 additions and 6 deletions

View File

@@ -55,19 +55,23 @@ class WritingProgramEnrollmentTest(CacheIsolationTestCase):
def test_write_program_enrollments_status_ended(self):
"""
Successfully updates program enrollment to status ended if requested
Successfully updates program enrollment to status ended if requested.
This also validates history records are created on both create and update.
"""
assert ProgramEnrollment.objects.count() == 0
assert ProgramEnrollment.historical_records.count() == 0 # pylint: disable=no-member
write_program_enrollments(self.program_uuid_x, [{
'external_user_key': self.user_0,
'status': PEStatuses.PENDING,
'curriculum_uuid': self.curriculum_uuid_a,
}], True, False)
assert ProgramEnrollment.objects.count() == 1
assert ProgramEnrollment.historical_records.count() == 1 # pylint: disable=no-member
write_program_enrollments(self.program_uuid_x, [{
'external_user_key': self.user_0,
'status': PEStatuses.ENDED,
'curriculum_uuid': self.curriculum_uuid_a,
}], False, True)
assert ProgramEnrollment.objects.count() == 1
assert ProgramEnrollment.historical_records.count() == 2 # pylint: disable=no-member
assert ProgramEnrollment.objects.filter(status=PEStatuses.ENDED).exists()