Skip to content
Snippets Groups Projects
Commit b73979dc authored by Zia Fazal's avatar Zia Fazal
Browse files

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
parent b284c233
Branches
Tags release-2020-11-09-18.01
No related merge requests found
...@@ -13,6 +13,8 @@ from django.dispatch import receiver ...@@ -13,6 +13,8 @@ from django.dispatch import receiver
from email_marketing.tasks import update_user from email_marketing.tasks import update_user
from enterprise.models import EnterpriseCourseEnrollment, EnterpriseCustomer, EnterpriseCustomerUser 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.tasks import clear_enterprise_customer_data_consent_share_cache
from openedx.features.enterprise_support.utils import clear_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): ...@@ -64,3 +66,15 @@ def update_dsc_cache_on_enterprise_customer_update(sender, instance, **kwargs):
task_id=result.task_id, task_id=result.task_id,
kwargs=kwargs, 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 ...@@ -6,8 +6,12 @@ import logging
import ddt import ddt
from django.test import TestCase from django.test import TestCase
from mock import patch from mock import patch
from student.tests.factories import UserFactory
from edx_django_utils.cache import TieredCache 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 ( from openedx.features.enterprise_support.tests.factories import (
EnterpriseCourseEnrollmentFactory, EnterpriseCourseEnrollmentFactory,
EnterpriseCustomerFactory, EnterpriseCustomerFactory,
...@@ -104,3 +108,20 @@ class EnterpriseSupportSignals(TestCase): ...@@ -104,3 +108,20 @@ class EnterpriseSupportSignals(TestCase):
enterprise_customer.save() enterprise_customer.save()
self.assertFalse(self._is_dsc_cache_found(self.user.id, self.course_id)) 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)
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment