Update tests

This commit is contained in:
Awais Jibran
2020-09-29 21:57:46 +05:00
parent ea71b27c36
commit 01832220e2

View File

@@ -58,7 +58,7 @@ class BulkUnenrollTests(SharedModuleStoreTestCase):
csv = self._write_test_csv(csv, lines=["amy,test_course\n"])
with LogCapture(LOGGER_NAME) as log:
call_command("bulk_unenroll", "--csv_path={}".format(csv.name))
call_command("bulk_unenroll", "--csv_path={} --commit".format(csv.name))
expected_message = 'Invalid course id {}, skipping un-enrollement.'.\
format('test_course')
@@ -76,10 +76,26 @@ class BulkUnenrollTests(SharedModuleStoreTestCase):
with NamedTemporaryFile() as csv:
csv = self._write_test_csv(csv, lines=lines)
call_command("bulk_unenroll", "--csv_path={}".format(csv.name))
call_command("bulk_unenroll", "--csv_path={} --commit".format(csv.name))
for enrollment in CourseEnrollment.objects.all():
self.assertEqual(enrollment.is_active, False)
def test_bulk_un_enroll_without_commit(self):
"""
Verify the ability to dry-run the command.
"""
lines = [
enrollment.user.username + "," +
str(enrollment.course.id) + "\n"
for enrollment in self.enrollments
]
with NamedTemporaryFile() as csv:
csv = self._write_test_csv(csv, lines=lines)
call_command("bulk_unenroll", "--csv_path={}".format(csv.name))
for enrollment in CourseEnrollment.objects.all():
self.assertEqual(enrollment.is_active, True)
def test_bulk_unenroll_from_config_model(self):
"""Verify users are unenrolled using the command."""
lines = "user_id,username,email,course_id\n"
@@ -90,7 +106,7 @@ class BulkUnenrollTests(SharedModuleStoreTestCase):
csv_file = SimpleUploadedFile(name='test.csv', content=lines.encode('utf-8'), content_type='text/csv')
BulkUnenrollConfiguration.objects.create(enabled=True, csv_file=csv_file)
call_command("bulk_unenroll")
call_command("bulk_unenroll --commit")
for enrollment in CourseEnrollment.objects.all():
self.assertEqual(enrollment.is_active, False)
@@ -102,7 +118,7 @@ class BulkUnenrollTests(SharedModuleStoreTestCase):
BulkUnenrollConfiguration.objects.create(enabled=True, csv_file=csv_file)
with LogCapture(LOGGER_NAME) as log:
call_command("bulk_unenroll")
call_command("bulk_unenroll --commit")
log.check(
(
LOGGER_NAME,