diff --git a/openedx/core/djangoapps/notifications/tests/test_views.py b/openedx/core/djangoapps/notifications/tests/test_views.py index 3a977ea6ce..ec3dbe4dcb 100644 --- a/openedx/core/djangoapps/notifications/tests/test_views.py +++ b/openedx/core/djangoapps/notifications/tests/test_views.py @@ -496,7 +496,8 @@ class NotificationCountViewSetTestCase(ModuleStoreTestCase): self.assertEqual(response.status_code, 200) self.assertEqual(response.data['count'], 4) - self.assertEqual(response.data['count_by_app_name'], {'App Name 1': 2, 'App Name 2': 1, 'App Name 3': 1}) + self.assertEqual(response.data['count_by_app_name'], { + 'App Name 1': 2, 'App Name 2': 1, 'App Name 3': 1, 'discussion': 0}) self.assertEqual(response.data['show_notifications_tray'], show_notifications_tray_enabled) def test_get_unseen_notifications_count_for_unauthenticated_user(self): @@ -517,7 +518,7 @@ class NotificationCountViewSetTestCase(ModuleStoreTestCase): self.assertEqual(response.status_code, 200) self.assertEqual(response.data['count'], 0) - self.assertEqual(response.data['count_by_app_name'], {}) + self.assertEqual(response.data['count_by_app_name'], {'discussion': 0}) class MarkNotificationsSeenAPIViewTestCase(APITestCase): diff --git a/openedx/core/djangoapps/notifications/views.py b/openedx/core/djangoapps/notifications/views.py index 2ea38d5e8a..83838bd6c4 100644 --- a/openedx/core/djangoapps/notifications/views.py +++ b/openedx/core/djangoapps/notifications/views.py @@ -289,8 +289,11 @@ class NotificationCountView(APIView): .annotate(count=Count('*')) ) count_total = 0 - count_by_app_name_dict = {} show_notifications_tray_enabled = False + count_by_app_name_dict = { + app_name: 0 + for app_name in COURSE_NOTIFICATION_APPS + } for item in count_by_app_name: app_name = item['app_name']