From 541bc6f5cb0fda98a6a4267b1632b3860a118f6c Mon Sep 17 00:00:00 2001 From: michaelroytman Date: Fri, 5 Apr 2024 13:33:16 -0400 Subject: [PATCH] feat: add must_retry as valid status to approve_id_verifications management command Sometimes, submissions to an IDV provider fail, which results in an IDV attempt moving from the "ready" status into the "must_retry" status instead of the "submitted" status. We would like to approve these attempts too. --- .../management/commands/approve_id_verifications.py | 8 ++++---- .../commands/tests/test_approve_id_verifications.py | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lms/djangoapps/verify_student/management/commands/approve_id_verifications.py b/lms/djangoapps/verify_student/management/commands/approve_id_verifications.py index edada5fd7a2a..48ef6e6cf3a9 100644 --- a/lms/djangoapps/verify_student/management/commands/approve_id_verifications.py +++ b/lms/djangoapps/verify_student/management/commands/approve_id_verifications.py @@ -21,7 +21,7 @@ class Command(BaseCommand): """ This command manually approves ID verification attempts for a provided set of learners whose ID verification - attempt is in the submitted state. + attempt is in the submitted or must_retry state. This command differs from the similar manual_verifications command in that it approves the SoftwareSecurePhotoVerification instance instead of creating a ManualVerification instance. This is advantageous @@ -32,7 +32,7 @@ class Command(BaseCommand): Example usage: $ ./manage.py lms idv_verifications """ - help = 'Manually approves ID verifications for users with an ID verification attempt in the submitted state.' + help = 'Manually approve ID verifications for users with an attempt in the submitted or must_retry state.' def add_arguments(self, parser): parser.add_argument( @@ -126,7 +126,7 @@ def _approve_verifications_from_file(self, user_ids_file, batch_size, sleep_time def _approve_id_verifications(self, user_ids): """ This command manually approves ID verification attempts for a provided set of learners whose ID verification - attempt is in the submitted state. + attempt is in the submitted or must_retry state. Arguments: user_ids (list): user IDs of the users whose ID verification attempt should be manually approved @@ -136,7 +136,7 @@ def _approve_id_verifications(self, user_ids): """ existing_id_verifications = SoftwareSecurePhotoVerification.objects.filter( user_id__in=user_ids, - status='submitted', + status__in=['submitted', 'must_retry'], created_at__gte=earliest_allowed_verification_date(), ) diff --git a/lms/djangoapps/verify_student/management/commands/tests/test_approve_id_verifications.py b/lms/djangoapps/verify_student/management/commands/tests/test_approve_id_verifications.py index 5e616d04fbe0..90947a2b0771 100644 --- a/lms/djangoapps/verify_student/management/commands/tests/test_approve_id_verifications.py +++ b/lms/djangoapps/verify_student/management/commands/tests/test_approve_id_verifications.py @@ -2,7 +2,7 @@ Tests for django admin commands in the verify_student module """ - +import ddt import logging import os import tempfile @@ -18,6 +18,7 @@ LOGGER_NAME = 'lms.djangoapps.verify_student.management.commands.approve_id_verifications' +@ddt.ddt class TestApproveIDVerificationsCommand(TestCase): """ Tests for django admin commands in the verify_student module @@ -50,7 +51,8 @@ def create_user_ids_file(file_path, user_ids): with open(file_path, 'w') as temp_file: temp_file.write(str("\n".join(user_ids))) - def test_approve_id_verifications(self): + @ddt.data('submitted', 'must_retry') + def test_approve_id_verifications(self, status): """ Tests that the approve_id_verifications management command executes successfully. """ @@ -59,7 +61,7 @@ def test_approve_id_verifications(self): SoftwareSecurePhotoVerification.objects.create( user=user.user, name=user.name, - status='submitted', + status=status, ) assert SoftwareSecurePhotoVerification.objects.filter(status='approved').count() == 0