Skip to content

Commit

Permalink
refactor: removed additional user object
Browse files Browse the repository at this point in the history
  • Loading branch information
Anas12091101 committed Mar 1, 2024
1 parent 7a6fbc8 commit a4116b1
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions edx_sga/tests/integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,7 @@ def test_student_view_with_upload(self, fragment, render_template):
block = self.make_one()
student = self.make_student(block, "fred", sha1="foo", filename="foo.bar")
self.personalize(block, **student)
user = student["module"].student
student_id = anonymous_id_for_user(user,self.course_id)
student_id = anonymous_id_for_user(student["module"].student,self.course_id)
with mock.patch.object(StaffGradedAssignmentXBlock.get_submission,"__defaults__",(student_id,)):
block.student_view()
context = render_template.call_args[0][1]
Expand All @@ -278,8 +277,7 @@ def test_student_view_with_annotated(self, fragment, render_template):
block = self.make_one(annotated_sha1="foo", annotated_filename="foo.bar")
student = self.make_student(block, "fred")
self.personalize(block, **student)
user = student["module"].student
student_id = anonymous_id_for_user(user,self.course_id)
student_id = anonymous_id_for_user(student["module"].student,self.course_id)
with mock.patch.object(StaffGradedAssignmentXBlock.get_submission,"__defaults__",(student_id,)):
block.student_view()
context = render_template.call_args[0][1]
Expand All @@ -296,8 +294,7 @@ def test_student_view_with_score(self, fragment, render_template):
block = self.make_one()
student = self.make_student(block, "fred", filename="foo.txt", score=10)
self.personalize(block, **student)
user = student["module"].student
student_id = anonymous_id_for_user(user,self.course_id)
student_id = anonymous_id_for_user(student["module"].student,self.course_id)

with mock.patch.object(StaffGradedAssignmentXBlock.get_submission,"__defaults__",(student_id,)),\
mock.patch.object(StaffGradedAssignmentXBlock.get_score, "__defaults__",(student_id,)):
Expand Down Expand Up @@ -550,8 +547,7 @@ def test_staff_download(self):
for student_name, filename, text in students_info:
student = self.make_student(block, student_name)
self.personalize(block, **student)
user = student["module"].student
student_id = anonymous_id_for_user(user,self.course_id)
student_id = anonymous_id_for_user(student["module"].student,self.course_id)

with mock.patch.object(StaffGradedAssignmentXBlock.get_student_item_dict,"__defaults__",(student_id,)),\
self.dummy_upload(filename, text) as (upload, __):
Expand Down Expand Up @@ -613,8 +609,7 @@ def test_staff_download_unicode_filename(self):
block = self.make_one()
student = self.make_student(block, "fred")
self.personalize(block, **student)
user = student["module"].student
student_id = anonymous_id_for_user(user,self.course_id)
student_id = anonymous_id_for_user(student["module"].student,self.course_id)

with mock.patch.object(StaffGradedAssignmentXBlock.get_student_item_dict,"__defaults__",(student_id,)),\
self.dummy_upload("файл.txt") as (upload, expected):
Expand Down Expand Up @@ -643,8 +638,7 @@ def test_staff_download_filename_with_spaces(self):
block = self.make_one()
student = self.make_student(block, "fred")
self.personalize(block, **student)
user = student["module"].student
student_id = anonymous_id_for_user(user,self.course_id)
student_id = anonymous_id_for_user(student["module"].student,self.course_id)

with mock.patch.object(StaffGradedAssignmentXBlock.get_student_item_dict,"__defaults__",(student_id,)),\
self.dummy_upload(file_name) as (upload, expected):
Expand All @@ -666,8 +660,7 @@ def test_file_download_comma_in_name(self, file_name):
block = self.make_one()
student = self.make_student(block, "fred")
self.personalize(block, **student)
user = student["module"].student
student_id = anonymous_id_for_user(user,self.course_id)
student_id = anonymous_id_for_user(student["module"].student,self.course_id)

with mock.patch.object(StaffGradedAssignmentXBlock.get_student_item_dict,"__defaults__",(student_id,)),\
self.dummy_upload(file_name) as (upload, expected):
Expand Down

0 comments on commit a4116b1

Please sign in to comment.