From 38b57fe4390a50908af6086d1687d94a6f9f491f Mon Sep 17 00:00:00 2001 From: Varsha Menon Date: Thu, 28 Mar 2024 08:47:27 -0400 Subject: [PATCH] test: refactor --- .../commands/test/test_bulk_add_course_staff.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) 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 183ef946..5dbb4ab3 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 @@ -37,6 +37,7 @@ def _write_test_csv(self, csv, lines): return csv def _assert_user_and_role(self, username, email, course_role, course_id): + """ Helper that asserts that User and CourseStaffRole are created """ user = User.objects.filter(username=username, email=email) assert user.exists() assert CourseStaffRole.objects.filter( @@ -67,9 +68,7 @@ def test_add_course_staff_with_new_user(self): self._assert_user_and_role(username, email, self.course_role, self.course_id) def test_add_course_staff_multiple(self): - """ - Assert that the course staff role is correct given multiple lines - """ + """ Assert that the course staff role is correct given multiple lines """ username, email = 'pam', 'pam@pond.com' username2, email2 = 'cam', 'cam@pond.com' lines = [f'{username},{email},{self.course_role},{self.course_id}\n', @@ -81,14 +80,12 @@ def test_add_course_staff_multiple(self): self._assert_user_and_role(username2, email2, self.course_role, self.course_id) def test_add_course_staff_with_not_default_batch_size(self): - """ - Assert that the number of queries is correct given 2 batches - """ + """ Assert that the number of queries is correct given 2 batches """ 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(10): + with self.assertNumQueries(9): call_command(self.command, f'--csv_path={csv.name}', '--batch_size=1') def test_add_course_staff_with_not_default_batch_delay(self):