Added signal handler for COURSE_GRADE_NOW_PASSED
Added signal handler for COURSE_GRADE_NOW_PASSED to trigger single learner data transmission task in edx-enterprise. Bumped edx-enterprise version to 1.10.7 Revert edx-enterprise version bump
This commit is contained in:
@@ -13,6 +13,8 @@ from django.dispatch import receiver
|
||||
from email_marketing.tasks import update_user
|
||||
|
||||
from enterprise.models import EnterpriseCourseEnrollment, EnterpriseCustomer, EnterpriseCustomerUser
|
||||
from integrated_channels.integrated_channel.tasks import transmit_single_learner_data
|
||||
from openedx.core.djangoapps.signals.signals import COURSE_GRADE_NOW_PASSED
|
||||
from openedx.features.enterprise_support.tasks import clear_enterprise_customer_data_consent_share_cache
|
||||
from openedx.features.enterprise_support.utils import clear_data_consent_share_cache
|
||||
|
||||
@@ -64,3 +66,15 @@ def update_dsc_cache_on_enterprise_customer_update(sender, instance, **kwargs):
|
||||
task_id=result.task_id,
|
||||
kwargs=kwargs,
|
||||
))
|
||||
|
||||
|
||||
@receiver(COURSE_GRADE_NOW_PASSED, dispatch_uid="new_passing_enterprise_learner")
|
||||
def handle_enterprise_learner_passing_grade(sender, user, course_id, **kwargs): # pylint: disable=unused-argument
|
||||
"""
|
||||
Listen for a learner passing a course, transmit data to relevant integrated channel
|
||||
"""
|
||||
kwargs = {
|
||||
'username': six.text_type(user.username),
|
||||
'course_run_id': six.text_type(course_id)
|
||||
}
|
||||
transmit_single_learner_data.apply_async(kwargs=kwargs)
|
||||
|
||||
@@ -6,8 +6,12 @@ import logging
|
||||
import ddt
|
||||
from django.test import TestCase
|
||||
from mock import patch
|
||||
from student.tests.factories import UserFactory
|
||||
|
||||
from edx_django_utils.cache import TieredCache
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
|
||||
from student.tests.factories import UserFactory
|
||||
from openedx.core.djangoapps.signals.signals import COURSE_GRADE_NOW_PASSED
|
||||
from openedx.features.enterprise_support.tests.factories import (
|
||||
EnterpriseCourseEnrollmentFactory,
|
||||
EnterpriseCustomerFactory,
|
||||
@@ -104,3 +108,20 @@ class EnterpriseSupportSignals(TestCase):
|
||||
enterprise_customer.save()
|
||||
|
||||
self.assertFalse(self._is_dsc_cache_found(self.user.id, self.course_id))
|
||||
|
||||
def test_handle_enterprise_learner_passing_grade(self):
|
||||
"""
|
||||
Test to assert transmit_single_learner_data is called when COURSE_GRADE_NOW_PASSED signal is fired
|
||||
"""
|
||||
with patch(
|
||||
'integrated_channels.integrated_channel.tasks.transmit_single_learner_data.apply_async',
|
||||
return_value=None
|
||||
) as mock_task_apply:
|
||||
course_key = CourseKey.from_string(self.course_id)
|
||||
COURSE_GRADE_NOW_PASSED.disconnect(dispatch_uid='new_passing_learner')
|
||||
COURSE_GRADE_NOW_PASSED.send(sender=None, user=self.user, course_id=course_key)
|
||||
task_kwargs = {
|
||||
'username': self.user.username,
|
||||
'course_run_id': self.course_id
|
||||
}
|
||||
mock_task_apply.assert_called_once_with(kwargs=task_kwargs)
|
||||
|
||||
Reference in New Issue
Block a user