diff --git a/openedx/core/djangoapps/programs/tasks/v1/tasks.py b/openedx/core/djangoapps/programs/tasks/v1/tasks.py index 98a35a9286..b3888f5761 100644 --- a/openedx/core/djangoapps/programs/tasks/v1/tasks.py +++ b/openedx/core/djangoapps/programs/tasks/v1/tasks.py @@ -147,13 +147,13 @@ def award_program_certificates(self, username): LOGGER.warning( 'Task award_program_certificates cannot be executed when program certification is disabled in API config', ) - return + raise self.retry(countdown=countdown, max_retries=config.max_retries) if not CredentialsApiConfig.current().is_learner_issuance_enabled: LOGGER.warning( 'Task award_program_certificates cannot be executed when credentials issuance is disabled in API config', ) - return + raise self.retry(countdown=countdown, max_retries=config.max_retries) try: try: diff --git a/openedx/core/djangoapps/programs/tasks/v1/tests/test_tasks.py b/openedx/core/djangoapps/programs/tasks/v1/tests/test_tasks.py index fea3c6b01a..487c5a2079 100644 --- a/openedx/core/djangoapps/programs/tasks/v1/tests/test_tasks.py +++ b/openedx/core/djangoapps/programs/tasks/v1/tests/test_tasks.py @@ -3,6 +3,7 @@ Tests for programs celery tasks. """ import ddt +from celery.exceptions import MaxRetriesExceededError from django.conf import settings from django.test import override_settings, TestCase from edx_rest_api_client.client import EdxRestApiClient @@ -250,7 +251,7 @@ class AwardProgramCertificatesTestCase(TestCase, ProgramsApiConfigMixin, Credent ('credentials', 'enable_learner_issuance'), ) @ddt.unpack - def test_abort_if_config_disabled( + def test_retry_if_config_disabled( self, disabled_config_type, disabled_config_attribute, @@ -262,7 +263,8 @@ class AwardProgramCertificatesTestCase(TestCase, ProgramsApiConfigMixin, Credent """ getattr(self, 'create_{}_config'.format(disabled_config_type))(**{disabled_config_attribute: False}) with mock.patch(TASKS_MODULE + '.LOGGER.warning') as mock_warning: - tasks.award_program_certificates.delay(self.student.username).get() + with self.assertRaises(MaxRetriesExceededError): + tasks.award_program_certificates.delay(self.student.username).get() self.assertTrue(mock_warning.called) for mock_helper in mock_helpers: self.assertFalse(mock_helper.called)