diff --git a/openedx/core/djangoapps/notifications/email/tests/test_utils.py b/openedx/core/djangoapps/notifications/email/tests/test_utils.py index 6e79c497a4fe..1f3da983a020 100644 --- a/openedx/core/djangoapps/notifications/email/tests/test_utils.py +++ b/openedx/core/djangoapps/notifications/email/tests/test_utils.py @@ -16,7 +16,6 @@ COURSE_NOTIFICATION_TYPES, ) from openedx.core.djangoapps.notifications.config.waffle import ENABLE_EMAIL_NOTIFICATIONS -from openedx.core.djangoapps.notifications.email_notifications import EmailCadence from openedx.core.djangoapps.notifications.models import CourseNotificationPreference, Notification from openedx.core.djangoapps.notifications.email.utils import ( add_additional_attributes_to_notifications, @@ -320,9 +319,7 @@ def test_value_with_channel_param(self, param_channel, new_value): if channel == param_channel: assert type_prefs[channel] == new_value if channel == 'email': - cadence_value = EmailCadence.NEVER - if new_value: - cadence_value = self.get_default_cadence_value(app_name, noti_type) + cadence_value = self.get_default_cadence_value(app_name, noti_type) assert type_prefs['email_cadence'] == cadence_value else: default_app_json = self.default_json[app_name] @@ -381,9 +378,7 @@ def test_value_with_app_name_param(self, param_app_name, new_value): if app_name == param_app_name: assert type_prefs[channel] == new_value if channel == 'email': - cadence_value = EmailCadence.NEVER - if new_value: - cadence_value = self.get_default_cadence_value(app_name, noti_type) + cadence_value = self.get_default_cadence_value(app_name, noti_type) assert type_prefs['email_cadence'] == cadence_value else: default_app_json = self.default_json[app_name] @@ -415,9 +410,7 @@ def test_value_with_notification_type_param(self, param_notification_type, new_v if noti_type == param_notification_type: assert type_prefs[channel] == new_value if channel == 'email': - cadence_value = EmailCadence.NEVER - if new_value: - cadence_value = self.get_default_cadence_value(app_name, noti_type) + cadence_value = self.get_default_cadence_value(app_name, noti_type) assert type_prefs['email_cadence'] == cadence_value else: default_app_json = self.default_json[app_name] diff --git a/openedx/core/djangoapps/notifications/email/utils.py b/openedx/core/djangoapps/notifications/email/utils.py index 582e867d629d..d855494012ea 100644 --- a/openedx/core/djangoapps/notifications/email/utils.py +++ b/openedx/core/djangoapps/notifications/email/utils.py @@ -406,9 +406,7 @@ def get_updated_preference(pref): continue if is_editable(app_name, noti_type, channel): type_prefs[channel] = pref_value - if channel == 'email': - cadence_value = get_default_cadence_value(app_name, noti_type)\ - if pref_value else EmailCadence.NEVER - type_prefs['email_cadence'] = cadence_value + if channel == 'email' and pref_value and type_prefs.get('email_cadence') == EmailCadence.NEVER: + type_prefs['email_cadence'] = get_default_cadence_value(app_name, noti_type) preference.save() notification_preference_unsubscribe_event(user) diff --git a/openedx/core/djangoapps/notifications/tests/test_views.py b/openedx/core/djangoapps/notifications/tests/test_views.py index b7bd0414a27f..70e6fbc5739c 100644 --- a/openedx/core/djangoapps/notifications/tests/test_views.py +++ b/openedx/core/djangoapps/notifications/tests/test_views.py @@ -27,7 +27,6 @@ FORUM_ROLE_MODERATOR ) from openedx.core.djangoapps.notifications.config.waffle import ENABLE_NOTIFICATIONS -from openedx.core.djangoapps.notifications.email_notifications import EmailCadence from openedx.core.djangoapps.notifications.models import ( CourseNotificationPreference, Notification, @@ -936,7 +935,6 @@ def test_if_preference_is_updated(self, request_type): for app_name, app_prefs in config.items(): for type_prefs in app_prefs['notification_types'].values(): assert type_prefs['email'] is False - assert type_prefs['email_cadence'] == EmailCadence.NEVER def test_if_config_version_is_updated(self): """