diff --git a/eox_nelp/signals/receivers.py b/eox_nelp/signals/receivers.py index 6f161868..0b41f7e6 100644 --- a/eox_nelp/signals/receivers.py +++ b/eox_nelp/signals/receivers.py @@ -392,9 +392,7 @@ def pearson_vue_course_completion_handler(instance, **kwargs): # pylint: disabl Arguments: instance: Instance of BlockCompletion model. """ - if not getattr(settings, "PEARSON_RTI_ACTIVATE_COMPLETION_GATE", False) or not getattr( - settings, "PEARSON_RTI_COURSES_DATA", {} - ).get(str(instance.context_key)): + if not getattr(settings, "PEARSON_RTI_ACTIVATE_COMPLETION_GATE", False): return is_complete, graded = get_completed_and_graded(user_id=instance.user_id, course_id=str(instance.context_key)) @@ -408,12 +406,16 @@ def pearson_vue_course_completion_handler(instance, **kwargs): # pylint: disabl ) if getattr(settings, "USE_PEARSON_ENGINE_SERVICE", False): + if not getattr(settings, "PEARSON_RTI_COURSES_DATA", {}).get(str(instance.context_key)): + return real_time_import_task_v2.delay( user_id=instance.user_id, exam_id=str(instance.context_key), action_name="rti", ) else: + if not getattr(settings, "PEARSON_RTI_COURSES_DATA", {}).get(str(instance.context_key)): + return real_time_import_task.delay( user_id=instance.user_id, course_id=str(instance.context_key), @@ -430,9 +432,7 @@ def pearson_vue_course_passed_handler(user, course_id, **kwargs): # pylint: dis user : Instance of auth user model. course_id : Course locator. """ - if not getattr(settings, "PEARSON_RTI_ACTIVATE_GRADED_GATE", False) or not getattr( - settings, "PEARSON_RTI_COURSES_DATA", {} - ).get(str(course_id)): + if not getattr(settings, "PEARSON_RTI_ACTIVATE_GRADED_GATE", False): return LOGGER.info( @@ -441,12 +441,16 @@ def pearson_vue_course_passed_handler(user, course_id, **kwargs): # pylint: dis ) if getattr(settings, "USE_PEARSON_ENGINE_SERVICE", False): + if not getattr(settings, "PEARSON_RTI_COURSES_DATA", {}).get(str(course_id)): + return real_time_import_task_v2.delay( user_id=user.id, exam_id=str(course_id), action_name="rti", ) else: + if not getattr(settings, "PEARSON_RTI_COURSES_DATA", {}).get(str(course_id)): + return real_time_import_task.delay( course_id=str(course_id), user_id=user.id, diff --git a/eox_nelp/signals/tests/test_receivers.py b/eox_nelp/signals/tests/test_receivers.py index bcd0fd7a..449b53d3 100644 --- a/eox_nelp/signals/tests/test_receivers.py +++ b/eox_nelp/signals/tests/test_receivers.py @@ -723,10 +723,11 @@ def test_invalid_feature_flag(self, task_mock): task_mock.delay.assert_not_called() - @data({}, {"course-v1:notdesired": {"exam_series_code": "OTT"}}, {"key": 6}) @override_settings(PEARSON_RTI_ACTIVATE_COMPLETION_GATE=True) + @data({}, {"course-v1:notdesired": {"exam_series_code": "OTT"}}, {"key": 6}) + @patch("eox_nelp.signals.receivers.get_completed_and_graded") @patch("eox_nelp.signals.receivers.real_time_import_task") - def test_invalid_course_configuration(self, wrong_course_config, task_mock): + def test_invalid_course_configuration(self, wrong_course_config, task_mock, get_completed_and_graded_mock): """Test when the PEARSON_RTI_ACTIVATE_COMPLETION_GATE settings is True, but invalid course configuration for PEARSON_RTI_COURSES_DATA. Expected behavior: @@ -735,6 +736,7 @@ def test_invalid_course_configuration(self, wrong_course_config, task_mock): instance = Mock() instance.user_id = self.user_id instance.context_key = CourseKey.from_string(self.course_id) + get_completed_and_graded_mock.return_value = (True, False) setattr(settings, "PEARSON_RTI_COURSES_DATA", wrong_course_config) pearson_vue_course_completion_handler(instance)