diff --git a/edx_exams/apps/core/management/commands/test/test_bulk_add_course_staff.py b/edx_exams/apps/core/management/commands/test/test_bulk_add_course_staff.py index 756d3d65..2a8dd4aa 100644 --- a/edx_exams/apps/core/management/commands/test/test_bulk_add_course_staff.py +++ b/edx_exams/apps/core/management/commands/test/test_bulk_add_course_staff.py @@ -43,11 +43,9 @@ def test_empty_csv(self): call_command(self.command, f'--csv_path={csv.name}') def test_add_course_staff_with_existing_user(self): - # todo: create course staff with existing user lines = ['amy,amy@pond.com,staff,course-v1:edx+test+f19\n'] with NamedTemporaryFile() as csv: csv = self._write_test_csv(csv, lines) - # todo: assert number of queries is correct with self.assertNumQueries(2): call_command(self.command, f'--csv_path={csv.name}') assert CourseStaffRole.objects.filter(user=self.user.id).exists() @@ -65,12 +63,16 @@ def test_add_course_staff_with_batch_size(self): 'sam,sam@pond.com,staff,course-v1:edx+test+f20\n'] with NamedTemporaryFile() as csv: csv = self._write_test_csv(csv, lines) - # todo: assert number of queries is correct with self.assertNumQueries(2): call_command(self.command, f'--csv_path={csv.name}', '--batch_size=1') assert CourseStaffRole.objects.filter(course_id='course-v1:edx+test+f20').count() == 2 def test_add_course_staff_with_batch_delay(self): - # todo: test with setting batch delay - # todo: see bulk unenroll for example of batch unenroll - return + lines = ['pam,pam@pond.com,staff,course-v1:edx+test+f20\n', + 'sam,sam@pond.com,staff,course-v1:edx+test+f20\n'] + with NamedTemporaryFile() as csv: + csv = self._write_test_csv(csv, lines) + with self.assertNumQueries(2): + call_command(self.command, f'--csv_path={csv.name}', '--batch_size=1', '--batch_delay=2') + assert CourseStaffRole.objects.filter(course_id='course-v1:edx+test+f20').count() == 2 +