-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9a8ddf9
commit 7307b91
Showing
1 changed file
with
11 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,16 +55,15 @@ def test_add_course_staff_with_new_user(self): | |
call_command(self.command, f'--csv_path={csv.name}') | ||
assert CourseStaffRole.objects.filter(course_id='course-v1:edx+test+f20').count() == 1 | ||
|
||
def test_add_course_staff_with_batch_size(self): | ||
def test_add_course_staff_with_not_default_batch_size(self): | ||
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) | ||
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 batch delay | ||
def test_add_course_staff_with_not_default_batch_delay(self): | ||
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: | ||
|
@@ -73,11 +72,14 @@ def test_add_course_staff_with_batch_delay(self): | |
assert CourseStaffRole.objects.filter(course_id='course-v1:edx+test+f20').count() == 2 | ||
|
||
def test_num_queries_correct(self): | ||
# todo: test num queries correct | ||
lines = ['pam,[email protected],staff,course-v1:edx+test+f20\n', | ||
'sam,[email protected],staff,course-v1:edx+test+f20\n'] | ||
""" | ||
Expect the number of queries to be 3 + 3 * number of lines | ||
- 2 for savepoint/release savepoint, 1 for count check below, 1 to get existing usernames | ||
- 3 for each user, assuming not existing (1 to create user, 1 to get user, 1 to add course role) | ||
""" | ||
num_lines = 20 | ||
lines = [f'pam{i},pam{i}@pond.com,staff,course-v1:edx+test+f20\n' for i in range(num_lines)] | ||
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 | ||
with self.assertNumQueries(3 + 3 * num_lines): | ||
call_command(self.command, f'--csv_path={csv.name}') |