-
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.
Merge pull request #271 from edx/varshamenon4/staff-mgmt-command-fix
fix: handle dupe user case for mgmt cmd
- Loading branch information
Showing
2 changed files
with
14 additions
and
0 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
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 |
---|---|---|
|
@@ -117,3 +117,16 @@ def test_num_queries_correct(self): | |
csv = self._write_test_csv(csv, lines) | ||
with self.assertNumQueries(5 + num_lines): | ||
call_command(self.command, f'--csv_path={csv.name}') | ||
|
||
def test_dupe_user_csv(self): | ||
""" Assert that the course staff roles are correctly created given duplicate users in csv """ | ||
username, email = 'pam', '[email protected]' | ||
course_id_2 = 'course-v1:edx+test+f21' | ||
lines = [f'{username},{email},{self.course_role},{self.course_id}\n', | ||
f'{username},{email},{self.course_role},{course_id_2}\n'] | ||
|
||
with NamedTemporaryFile() as csv: | ||
csv = self._write_test_csv(csv, lines) | ||
call_command(self.command, f'--csv_path={csv.name}') | ||
self._assert_user_and_role(username, email, self.course_role, self.course_id) | ||
self._assert_user_and_role(username, email, self.course_role, course_id_2) |