-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Upgrading api to use drf 5th api. register_and_enroll_students …
…api (#35084) * feat: upgrading simple api to drf compatible.
- Loading branch information
Showing
3 changed files
with
286 additions
and
261 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 |
---|---|---|
|
@@ -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. | ||
|
Oops, something went wrong.