Skip to content

Commit

Permalink
test: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
varshamenon4 committed Mar 28, 2024
1 parent cabfa59 commit 38b57fe
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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', '[email protected]'
username2, email2 = 'cam', '[email protected]'
lines = [f'{username},{email},{self.course_role},{self.course_id}\n',
Expand All @@ -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,[email protected],staff,course-v1:edx+test+f20\n',
'sam,[email protected],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):
Expand Down

0 comments on commit 38b57fe

Please sign in to comment.