Update the award_program_cert task to fix celery registration

[MICROBA-676]
This commit is contained in:
Albert (AJ) St. Aubin
2020-10-23 13:00:57 -04:00
parent e0795b1f03
commit 8cef028429
13 changed files with 15 additions and 16 deletions

View File

@@ -1218,7 +1218,6 @@ CELERY_IMPORTS = (
'cms.djangoapps.contentstore.tasks',
'openedx.core.djangoapps.bookmarks.tasks',
'openedx.core.djangoapps.ccxcon.tasks',
'openedx.core.djangoapps.programs.tasks.v1.tasks',
)
# Message configuration

View File

@@ -358,7 +358,7 @@ class CertificateInvalidationTest(SharedModuleStoreTestCase):
CertificateInvalidation.has_certificate_invalidation(self.user, self.course_id)
)
@patch('openedx.core.djangoapps.programs.tasks.v1.tasks.revoke_program_certificates.delay')
@patch('openedx.core.djangoapps.programs.tasks.revoke_program_certificates.delay')
@patch(
'openedx.core.djangoapps.credentials.models.CredentialsApiConfig.is_learner_issuance_enabled',
return_value=True,

View File

@@ -2233,7 +2233,6 @@ DEBUG_TOOLBAR_PATCH_SETTINGS = False
# Celery's task autodiscovery won't find tasks nested in a tasks package.
# Tasks are only registered when the module they are defined in is imported.
CELERY_IMPORTS = (
'openedx.core.djangoapps.programs.tasks.v1.tasks',
'poll.tasks'
)

View File

@@ -8,7 +8,7 @@ if and only if the service is deployed in the Open edX installation.
To ensure maximum separation of concerns, and a minimum of interdependencies,
this package should be kept small, thin, and stateless.
"""
default_app_config = 'openedx.core.djangoapps.programs.apps.ProgramsConfig'
from openedx.core.djangoapps.waffle_utils import WaffleSwitch, WaffleSwitchNamespace

View File

@@ -13,4 +13,5 @@ class ProgramsConfig(AppConfig):
name = u'openedx.core.djangoapps.programs'
def ready(self):
from . import signals
# noinspection PyUnresolvedReferences
from . import signals, tasks # pylint: disable=unused-variable

View File

@@ -12,7 +12,7 @@ from opaque_keys.edx.keys import CourseKey
from course_modes.models import CourseMode
from lms.djangoapps.certificates.models import CertificateStatuses, GeneratedCertificate
from openedx.core.djangoapps.catalog.utils import get_programs
from openedx.core.djangoapps.programs.tasks.v1.tasks import award_program_certificates
from openedx.core.djangoapps.programs.tasks import award_program_certificates
from openedx.core.djangoapps.programs.models import CustomProgramsConfig

View File

@@ -57,7 +57,7 @@ def handle_course_cert_awarded(sender, user, course_key, mode, status, **kwargs)
status,
)
# import here, because signal is registered at startup, but items in tasks are not yet able to be loaded
from openedx.core.djangoapps.programs.tasks.v1.tasks import award_program_certificates
from openedx.core.djangoapps.programs.tasks import award_program_certificates
award_program_certificates.delay(user.username)
@@ -133,7 +133,7 @@ def handle_course_cert_changed(sender, user, course_key, mode, status, **kwargs)
status,
)
# import here, because signal is registered at startup, but items in tasks are not yet able to be loaded
from openedx.core.djangoapps.programs.tasks.v1.tasks import award_course_certificate
from openedx.core.djangoapps.programs.tasks import award_course_certificate
award_course_certificate.delay(user.username, str(course_key))
@@ -176,7 +176,7 @@ def handle_course_cert_revoked(sender, user, course_key, mode, status, **kwargs)
status,
)
# import here, because signal is registered at startup, but items in tasks are not yet able to be loaded
from openedx.core.djangoapps.programs.tasks.v1.tasks import revoke_program_certificates
from openedx.core.djangoapps.programs.tasks import revoke_program_certificates
revoke_program_certificates.delay(user.username, course_key)
@@ -209,5 +209,5 @@ def handle_course_cert_date_change(sender, course_key, **kwargs):
course_key,
)
# import here, because signal is registered at startup, but items in tasks are not yet loaded
from openedx.core.djangoapps.programs.tasks.v1.tasks import update_certificate_visible_date_on_course_update
from openedx.core.djangoapps.programs.tasks import update_certificate_visible_date_on_course_update
update_certificate_visible_date_on_course_update.delay(course_key)

View File

@@ -28,7 +28,7 @@ TEST_COURSE_KEY = CourseKey.from_string('course-v1:edX+test_course+1')
# The credentials app isn't installed for the CMS.
@skip_unless_lms
@mock.patch('openedx.core.djangoapps.programs.tasks.v1.tasks.award_program_certificates.delay')
@mock.patch('openedx.core.djangoapps.programs.tasks.award_program_certificates.delay')
@mock.patch(
'openedx.core.djangoapps.credentials.models.CredentialsApiConfig.is_learner_issuance_enabled',
new_callable=mock.PropertyMock,
@@ -89,7 +89,7 @@ class CertAwardedReceiverTest(TestCase):
# The credentials app isn't installed for the CMS.
@skip_unless_lms
@mock.patch('openedx.core.djangoapps.programs.tasks.v1.tasks.award_course_certificate.delay')
@mock.patch('openedx.core.djangoapps.programs.tasks.award_course_certificate.delay')
@mock.patch(
'openedx.core.djangoapps.credentials.models.CredentialsApiConfig.is_learner_issuance_enabled',
new_callable=mock.PropertyMock,
@@ -172,7 +172,7 @@ class CertChangedReceiverTest(TestCase):
# The credentials app isn't installed for the CMS.
@skip_unless_lms
@mock.patch('openedx.core.djangoapps.programs.tasks.v1.tasks.revoke_program_certificates.delay')
@mock.patch('openedx.core.djangoapps.programs.tasks.revoke_program_certificates.delay')
@mock.patch(
'openedx.core.djangoapps.credentials.models.CredentialsApiConfig.is_learner_issuance_enabled',
new_callable=mock.PropertyMock,
@@ -232,7 +232,7 @@ class CertRevokedReceiverTest(TestCase):
@skip_unless_lms
@mock.patch('openedx.core.djangoapps.programs.tasks.v1.tasks.update_certificate_visible_date_on_course_update.delay')
@mock.patch('openedx.core.djangoapps.programs.tasks.update_certificate_visible_date_on_course_update.delay')
@mock.patch(
'openedx.core.djangoapps.credentials.models.CredentialsApiConfig.is_learner_issuance_enabled',
new_callable=mock.PropertyMock,

View File

@@ -24,7 +24,7 @@ from openedx.core.djangoapps.certificates.config import waffle
from openedx.core.djangoapps.content.course_overviews.tests.factories import CourseOverviewFactory
from openedx.core.djangoapps.credentials.tests.mixins import CredentialsApiConfigMixin
from openedx.core.djangoapps.oauth_dispatch.tests.factories import ApplicationFactory
from openedx.core.djangoapps.programs.tasks.v1 import tasks
from openedx.core.djangoapps.programs import tasks
from openedx.core.djangoapps.site_configuration.tests.factories import SiteConfigurationFactory, SiteFactory
from openedx.core.djangolib.testing.utils import skip_unless_lms
from student.tests.factories import UserFactory
@@ -32,7 +32,7 @@ from student.tests.factories import UserFactory
log = logging.getLogger(__name__)
CREDENTIALS_INTERNAL_SERVICE_URL = 'https://credentials.example.com'
TASKS_MODULE = 'openedx.core.djangoapps.programs.tasks.v1.tasks'
TASKS_MODULE = 'openedx.core.djangoapps.programs.tasks'
@skip_unless_lms