Skip to content

Commit

Permalink
Merge pull request openedx#34478 from openedx/michaelroytman/COSMO-23…
Browse files Browse the repository at this point in the history
…8-idv-approval-management-command

Add must_retry as valid status to approve_id_verifications management command.
  • Loading branch information
MichaelRoytman authored Apr 5, 2024
2 parents a27cda2 + 541bc6f commit 7a96729
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,7 +32,7 @@ class Command(BaseCommand):
Example usage:
$ ./manage.py lms idv_verifications <absolute path of file with user IDs (one per line)>
"""
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(
Expand Down Expand Up @@ -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
Expand All @@ -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(),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Tests for django admin commands in the verify_student module
"""

import ddt
import logging
import os
import tempfile
Expand All @@ -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
Expand Down Expand Up @@ -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.
"""
Expand All @@ -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
Expand Down

0 comments on commit 7a96729

Please sign in to comment.