From e524af5c7c01e1e4eea91ef7e6de504c035d0c02 Mon Sep 17 00:00:00 2001 From: Muhammad Adeel Tajamul <77053848+muhammadadeeltajamul@users.noreply.github.com> Date: Thu, 7 Sep 2023 13:54:54 +0500 Subject: [PATCH] feat: added notification_expiry_days in notification count api (#33187) --- .../core/djangoapps/notifications/tests/test_views.py | 10 ++++++++++ openedx/core/djangoapps/notifications/views.py | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/openedx/core/djangoapps/notifications/tests/test_views.py b/openedx/core/djangoapps/notifications/tests/test_views.py index 1cc0cab1a1..4a0855e689 100644 --- a/openedx/core/djangoapps/notifications/tests/test_views.py +++ b/openedx/core/djangoapps/notifications/tests/test_views.py @@ -550,6 +550,16 @@ class NotificationCountViewSetTestCase(ModuleStoreTestCase): self.assertEqual(response.data['count'], 0) self.assertEqual(response.data['count_by_app_name'], {'discussion': 0}) + def test_get_expiry_days_in_count_view(self): + """ + Tests if "notification_expiry_days" exists in API response + """ + user = UserFactory() + self.client.login(username=user.username, password='test') + response = self.client.get(self.url) + self.assertEqual(response.status_code, 200) + self.assertEqual(response.data['notification_expiry_days'], 60) + class MarkNotificationsSeenAPIViewTestCase(APITestCase): """ diff --git a/openedx/core/djangoapps/notifications/views.py b/openedx/core/djangoapps/notifications/views.py index 8614bb49f6..17b1b696f5 100644 --- a/openedx/core/djangoapps/notifications/views.py +++ b/openedx/core/djangoapps/notifications/views.py @@ -298,7 +298,8 @@ class NotificationCountView(APIView): "count_by_app_name": { (str) app_name: (int) number_of_unseen_notifications, ... - } + }, + "notification_expiry_days": 60 } ``` **Response Error Codes**: @@ -328,6 +329,7 @@ class NotificationCountView(APIView): "show_notifications_tray": show_notifications_tray, "count": count_total, "count_by_app_name": count_by_app_name_dict, + "notification_expiry_days": settings.NOTIFICATIONS_EXPIRY })