diff --git a/lms/djangoapps/verify_student/models.py b/lms/djangoapps/verify_student/models.py index 2d5d5dd8ca..e3da4537fd 100644 --- a/lms/djangoapps/verify_student/models.py +++ b/lms/djangoapps/verify_student/models.py @@ -647,6 +647,9 @@ class SoftwareSecurePhotoVerification(PhotoVerification): # verification functionality. If you do want to work on it, you have to # explicitly enable these in your private settings. if settings.FEATURES.get('AUTOMATIC_VERIFY_STUDENT_IDENTITY_FOR_TESTING'): + # fake photo id key is set only for initial verification + self.photo_id_key = 'fake-photo-id-key' + self.save() return aes_key = random_aes_key() diff --git a/lms/djangoapps/verify_student/tests/test_models.py b/lms/djangoapps/verify_student/tests/test_models.py index 78fd9a1af1..f55d0256cc 100644 --- a/lms/djangoapps/verify_student/tests/test_models.py +++ b/lms/djangoapps/verify_student/tests/test_models.py @@ -2,6 +2,7 @@ from datetime import timedelta, datetime import ddt import json +import mock import requests.exceptions import pytz @@ -236,6 +237,22 @@ class TestPhotoVerification(ModuleStoreTestCase): attempt = self.create_and_submit() assert_equals(attempt.status, "must_retry") + @mock.patch.dict(settings.FEATURES, {'AUTOMATIC_VERIFY_STUDENT_IDENTITY_FOR_TESTING': True}) + def test_submission_while_testing_flag_is_true(self): + """ Test that a fake value is set for field 'photo_id_key' of user's + initial verification when the feature flag 'AUTOMATIC_VERIFY_STUDENT_IDENTITY_FOR_TESTING' + is enabled. + """ + user = UserFactory.create() + attempt = SoftwareSecurePhotoVerification(user=user) + user.profile.name = "test-user" + + attempt.upload_photo_id_image("Image data") + attempt.mark_ready() + attempt.submit() + + self.assertEqual(attempt.photo_id_key, "fake-photo-id-key") + def test_active_for_user(self): """ Make sure we can retrive a user's active (in progress) verification