Skip to content

Commit

Permalink
feat: Upgrading api to use drf 5th api. register_and_enroll_students …
Browse files Browse the repository at this point in the history
…api (#35084)

* feat: upgrading simple api to drf compatible.
  • Loading branch information
awais786 authored Aug 19, 2024
1 parent 0077269 commit 6bcbb1d
Show file tree
Hide file tree
Showing 3 changed files with 286 additions and 261 deletions.
19 changes: 19 additions & 0 deletions lms/djangoapps/instructor/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,25 @@ def setUp(self):
last_name='Student'
)

def test_api_without_login(self):
"""
verify in case of no authentication it returns 401.
"""
self.client.logout()
uploaded_file = SimpleUploadedFile("temp.jpg", io.BytesIO(b"some initial binary data: \x00\x01").read())
response = self.client.post(self.url, {'students_list': uploaded_file})
assert response.status_code == 401

def test_api_without_permission(self):
"""
verify in case of no authentication it returns 403.
"""
# removed role from course for instructor
CourseInstructorRole(self.course.id).remove_users(self.instructor)
uploaded_file = SimpleUploadedFile("temp.jpg", io.BytesIO(b"some initial binary data: \x00\x01").read())
response = self.client.post(self.url, {'students_list': uploaded_file})
assert response.status_code == 403

@patch('lms.djangoapps.instructor.views.api.log.info')
@ddt.data(
b"[email protected],test_student_1,tester1,USA", # Typical use case.
Expand Down
Loading

0 comments on commit 6bcbb1d

Please sign in to comment.