From be8fef3513a93c1591592230c784304a315c1673 Mon Sep 17 00:00:00 2001 From: Alan Zarembok Date: Fri, 20 Dec 2019 16:43:16 -0500 Subject: [PATCH] PROD-1113: Fix retry_failed_photo_verifications to work when no database arguments exist. --- .../commands/retry_failed_photo_verifications.py | 3 ++- .../management/commands/tests/test_verify_student.py | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lms/djangoapps/verify_student/management/commands/retry_failed_photo_verifications.py b/lms/djangoapps/verify_student/management/commands/retry_failed_photo_verifications.py index d75e5a6335..515c3ad8eb 100644 --- a/lms/djangoapps/verify_student/management/commands/retry_failed_photo_verifications.py +++ b/lms/djangoapps/verify_student/management/commands/retry_failed_photo_verifications.py @@ -46,7 +46,8 @@ class Command(BaseCommand): sspv_retry_config = SSPVerificationRetryConfig.current() if not sspv_retry_config.enabled: - raise CommandError('SSPVerificationRetryConfig is disabled, but --args-from-database was requested.') + log.warning('SSPVerificationRetryConfig is disabled or empty, but --args-from-database was requested.') + return {} # We don't need fancy shell-style whitespace/quote handling - none of our arguments are complicated argv = sspv_retry_config.arguments.split() diff --git a/lms/djangoapps/verify_student/management/commands/tests/test_verify_student.py b/lms/djangoapps/verify_student/management/commands/tests/test_verify_student.py index 986aa2ffe2..6fdc032b52 100644 --- a/lms/djangoapps/verify_student/management/commands/tests/test_verify_student.py +++ b/lms/djangoapps/verify_student/management/commands/tests/test_verify_student.py @@ -73,10 +73,14 @@ class TestVerifyStudentCommand(MockS3Mixin, TestCase): """Test management command arguments injected from config model.""" # Nothing in the database, should default to disabled - # pylint: disable=deprecated-method, useless-suppression - with self.assertRaisesRegex(CommandError, 'SSPVerificationRetryConfig is disabled*'): + with LogCapture(LOGGER_NAME) as log: call_command('retry_failed_photo_verifications', '--args-from-database') - + log.check_present( + ( + LOGGER_NAME, 'WARNING', + u"SSPVerificationRetryConfig is disabled or empty, but --args-from-database was requested." + ), + ) # Add a config config = SSPVerificationRetryConfig.current() config.arguments = '--verification-ids 1 2 3'