Skip to content

Commit

Permalink
test: add dupe testing
Browse files Browse the repository at this point in the history
  • Loading branch information
varshamenon4 committed Jul 24, 2024
1 parent cf036d3 commit 080355e
Showing 1 changed file with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.test import TestCase

from edx_exams.apps.core.models import CourseStaffRole, User
from edx_exams.apps.core.test_utils.factories import UserFactory
from edx_exams.apps.core.test_utils.factories import CourseStaffRoleFactory, UserFactory


class TestBulkAddCourseStaff(TestCase):
Expand Down Expand Up @@ -130,3 +130,32 @@ def test_dupe_user_csv(self):
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)

def test_existing_course_staff_csv(self):
""" Assert that the course staff role are correctly created given already existing course staff roles in csv """
course_existing = 'course-v1:edx+test+f24'
CourseStaffRoleFactory.create(
user=self.user,
course_id=course_existing,
role=self.course_role,
)
lines = [f'{self.user.username},{self.user.email},{self.course_role},{course_existing}\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(self.user.username, self.user.email, self.course_role, course_existing)

def test_dupe_course_staff_csv(self):
""" Assert that the course staff role are correctly created given dupe course staff roles in csv """
course_existing = 'course-v1:edx+test+f24'
CourseStaffRoleFactory.create(
user=self.user,
course_id=course_existing,
role=self.course_role,
)
lines = [f'{self.user.username},{self.user.email},{self.course_role},{course_existing}\n',
f'{self.user.username},{self.user.email},{self.course_role},{course_existing}\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(self.user.username, self.user.email, self.course_role, course_existing)

0 comments on commit 080355e

Please sign in to comment.