-
Notifications
You must be signed in to change notification settings - Fork 85
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 #518 from edx/mroytman/update-on-review-callback
update backend.on_review_callback to not modify payload parameter
- Loading branch information
Showing
4 changed files
with
39 additions
and
46 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 |
---|---|---|
|
@@ -11,7 +11,6 @@ | |
|
||
from django.test import TestCase | ||
from django.utils import translation | ||
from django.contrib.auth.models import User | ||
|
||
from edx_proctoring.backends.rest import BaseRestProctoringProvider | ||
from edx_proctoring.exceptions import BackendProviderCannotRegisterAttempt, BackendProviderCannotRetireUser | ||
|
@@ -218,7 +217,7 @@ def test_update_exam_attempt_status(self, provider_method_name, corresponding_st | |
|
||
def test_on_review_callback(self): | ||
""" | ||
on_review_callback should just return the payload when called without review author | ||
on_review_callback should just return the payload | ||
""" | ||
attempt = { | ||
'id': 1, | ||
|
@@ -234,42 +233,6 @@ def test_on_review_callback(self): | |
new_payload = self.provider.on_review_callback(attempt, payload) | ||
self.assertEqual(payload, new_payload) | ||
|
||
def test_on_review_callback_with_reviewer(self): | ||
""" | ||
on_review_callback should find a user if an email is provided | ||
""" | ||
person = User( | ||
username='tester', | ||
email='[email protected]' | ||
) | ||
person.save() | ||
attempt = { | ||
'id': 1, | ||
'external_id': 'abcd', | ||
'user': 1 | ||
} | ||
|
||
def payload_with_email(email): | ||
""" | ||
generic payload with variable email | ||
""" | ||
return { | ||
'status': 'verified', | ||
'comments': [ | ||
{'comment': 'something happened', 'status': 'ok'}, | ||
], | ||
'reviewed_by': email, | ||
} | ||
|
||
payload = payload_with_email('[email protected]') | ||
new_payload = self.provider.on_review_callback(attempt, payload) | ||
self.assertEqual(new_payload['reviewed_by'], person) | ||
|
||
payload = payload_with_email('[email protected]') | ||
new_payload = self.provider.on_review_callback(attempt, payload) | ||
|
||
self.assertEqual(new_payload['reviewed_by'], None) | ||
|
||
def test_get_javascript(self): | ||
self.assertEqual(self.provider.get_javascript(), '') | ||
|
||
|
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 |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
import ddt | ||
from mock import patch | ||
|
||
from django.contrib.auth.models import User | ||
from django.test import RequestFactory | ||
from django.urls import reverse | ||
|
||
|
@@ -382,3 +383,34 @@ def test_clean_status(self): | |
|
||
attempt = get_exam_attempt_by_id(self.attempt_id) | ||
self.assertEqual(attempt['status'], ProctoredExamStudentAttemptStatus.second_review_required) | ||
|
||
def test_status_reviewed_by_field(self): | ||
""" | ||
Test that `reviewed_by` field of Review model is correctly assigned to None or to a User object. | ||
""" | ||
# no reviewed_by field | ||
test_payload = self.get_review_payload(ReviewStatus.suspicious) | ||
# submit a Suspicious review payload | ||
ProctoredExamReviewCallback().make_review(self.attempt, test_payload) | ||
|
||
review = ProctoredExamSoftwareSecureReview.objects.get(attempt_code=self.attempt['attempt_code']) | ||
self.assertIsNone(review.reviewed_by) | ||
|
||
# reviewed_by field with no corresponding User object | ||
reviewed_by_email = '[email protected]' | ||
test_payload['reviewed_by'] = reviewed_by_email | ||
|
||
# submit a Suspicious review payload | ||
ProctoredExamReviewCallback().make_review(self.attempt, test_payload) | ||
review = ProctoredExamSoftwareSecureReview.objects.get(attempt_code=self.attempt['attempt_code']) | ||
self.assertIsNone(review.reviewed_by) | ||
|
||
# reviewed_by field with corresponding User object | ||
user = User.objects.create( | ||
email=reviewed_by_email, | ||
username='TestyMcTesterson' | ||
) | ||
# submit a Suspicious review payload | ||
ProctoredExamReviewCallback().make_review(self.attempt, test_payload) | ||
review = ProctoredExamSoftwareSecureReview.objects.get(attempt_code=self.attempt['attempt_code']) | ||
self.assertEqual(review.reviewed_by, user) |
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