fix: Update ORA notification type for grouper (#36517)
This commit is contained in:
6
openedx/core/djangoapps/notifications/exceptions.py
Normal file
6
openedx/core/djangoapps/notifications/exceptions.py
Normal file
@@ -0,0 +1,6 @@
|
||||
""" Notification-related exceptions. """
|
||||
|
||||
|
||||
class InvalidNotificationTypeError(Exception):
|
||||
""" Exception raised when an invalid notification type is passed. """
|
||||
pass # lint-amnesty, pylint: disable=unnecessary-pass
|
||||
@@ -2,14 +2,16 @@
|
||||
Notification grouping utilities for notifications
|
||||
"""
|
||||
import datetime
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Dict, Type, Union
|
||||
|
||||
from pytz import utc
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
from openedx.core.djangoapps.notifications.base_notification import COURSE_NOTIFICATION_TYPES
|
||||
from openedx.core.djangoapps.notifications.models import Notification
|
||||
|
||||
from .exceptions import InvalidNotificationTypeError
|
||||
|
||||
|
||||
class BaseNotificationGrouper(ABC):
|
||||
"""
|
||||
@@ -42,6 +44,10 @@ class NotificationRegistry:
|
||||
"""
|
||||
Registers the grouper class for the given notification type.
|
||||
"""
|
||||
if notification_type not in COURSE_NOTIFICATION_TYPES:
|
||||
raise InvalidNotificationTypeError(
|
||||
f"'{notification_type}' is not a valid notification type."
|
||||
)
|
||||
cls._groupers[notification_type] = grouper_class
|
||||
return grouper_class
|
||||
|
||||
@@ -106,7 +112,7 @@ class NewPostGrouper(BaseNotificationGrouper):
|
||||
}
|
||||
|
||||
|
||||
@NotificationRegistry.register('ora_staff_notification')
|
||||
@NotificationRegistry.register('ora_staff_notifications')
|
||||
class OraStaffGrouper(BaseNotificationGrouper):
|
||||
"""
|
||||
Grouper for new ora staff notifications.
|
||||
|
||||
@@ -26,6 +26,10 @@ class TestNotificationRegistry(unittest.TestCase):
|
||||
Tests for the NotificationRegistry class
|
||||
"""
|
||||
|
||||
@patch.dict(
|
||||
'openedx.core.djangoapps.notifications.base_notification.COURSE_NOTIFICATION_TYPES',
|
||||
{'test_notification': 'Test Notification'}
|
||||
)
|
||||
def test_register_and_get_grouper(self):
|
||||
"""
|
||||
Test that the register and get_grouper methods work as expected
|
||||
|
||||
Reference in New Issue
Block a user