(feat) Enable course cert sync for all courses

Removes waffle flag restriction for syncing certificate available dates
to the credentials service.
This commit is contained in:
Matt Tuchfarber
2021-03-16 14:31:11 -04:00
parent 6b7d63af09
commit ed8604534c
4 changed files with 3 additions and 47 deletions

View File

@@ -1,36 +0,0 @@
"""
This module contains various configuration settings via
waffle switches for the course_details view.
"""
from edx_toggles.toggles import LegacyWaffleFlagNamespace, LegacyWaffleSwitchNamespace
from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag
COURSE_DETAIL_WAFFLE_NAMESPACE = 'course_detail'
COURSE_DETAIL_WAFFLE_FLAG_NAMESPACE = LegacyWaffleFlagNamespace(name=COURSE_DETAIL_WAFFLE_NAMESPACE)
WAFFLE_SWITCHES = LegacyWaffleSwitchNamespace(name=COURSE_DETAIL_WAFFLE_NAMESPACE)
# Course Override Flag
COURSE_DETAIL_UPDATE_CERTIFICATE_DATE = 'course_detail_update_certificate_date'
def waffle_flags():
"""
Returns the namespaced, cached, audited Waffle flags dictionary for course detail.
"""
return {
COURSE_DETAIL_UPDATE_CERTIFICATE_DATE: CourseWaffleFlag(
waffle_namespace=COURSE_DETAIL_WAFFLE_NAMESPACE,
flag_name=COURSE_DETAIL_UPDATE_CERTIFICATE_DATE,
module_name=__name__,
)
}
def enable_course_detail_update_certificate_date(course_id):
"""
Returns True if course_detail_update_certificate_date course override flag is enabled,
otherwise False.
"""
return waffle_flags()[COURSE_DETAIL_UPDATE_CERTIFICATE_DATE].is_enabled(course_id)

View File

@@ -8,7 +8,6 @@ import logging
from django.dispatch import receiver
from openedx.core.djangoapps.credentials.helpers import is_learner_records_enabled_for_org
from openedx.core.djangoapps.models.config.waffle import enable_course_detail_update_certificate_date
from openedx.core.djangoapps.signals.signals import (
COURSE_CERT_AWARDED,
COURSE_CERT_CHANGED,
@@ -196,9 +195,6 @@ def handle_course_cert_date_change(sender, course_key, available_date, **kwargs)
None
"""
# Stop if cert date updating isn't in effect for the course
if not enable_course_detail_update_certificate_date(course_key):
return
# Import here instead of top of file since this module gets imported before
# the credentials app is loaded, resulting in a Django deprecation warning.

View File

@@ -239,7 +239,6 @@ class CertRevokedReceiverTest(TestCase):
new_callable=mock.PropertyMock,
return_value=False,
)
@mock.patch("openedx.core.djangoapps.programs.signals.enable_course_detail_update_certificate_date")
class CourseCertAvailableDateChangedReceiverTest(TestCase):
"""
Tests for the `handle_course_cert_date_change` signal handler function.
@@ -256,7 +255,7 @@ class CourseCertAvailableDateChangedReceiverTest(TestCase):
'available_date': datetime.datetime.now()
}
def test_signal_received(self, mock_enable_update, mock_is_learner_issuance_enabled, mock_task): # pylint: disable=unused-argument
def test_signal_received(self, mock_is_learner_issuance_enabled, mock_task): # pylint: disable=unused-argument
"""
Ensures the receiver function is invoked when COURSE_CERT_DATE_CHANGE is
sent.
@@ -265,26 +264,23 @@ class CourseCertAvailableDateChangedReceiverTest(TestCase):
to the way django signals work), we mock a configuration call that is
known to take place inside the function.
"""
mock_enable_update.return_value = True
COURSE_CERT_DATE_CHANGE.send(**self.signal_kwargs)
assert mock_is_learner_issuance_enabled.call_count == 1
def test_programs_disabled(self, mock_enable_update, mock_is_learner_issuance_enabled, mock_task):
def test_programs_disabled(self, mock_is_learner_issuance_enabled, mock_task):
"""
Ensures that the receiver function does nothing when the credentials API
configuration is not enabled.
"""
mock_enable_update.return_value = True
handle_course_cert_date_change(**self.signal_kwargs)
assert mock_is_learner_issuance_enabled.call_count == 1
assert mock_task.call_count == 0
def test_programs_enabled(self, mock_enable_update, mock_is_learner_issuance_enabled, mock_task):
def test_programs_enabled(self, mock_is_learner_issuance_enabled, mock_task):
"""
Ensures that the receiver function invokes the expected celery task
when the credentials API configuration is enabled.
"""
mock_enable_update.return_value = True
mock_is_learner_issuance_enabled.return_value = True
handle_course_cert_date_change(**self.signal_kwargs)