fix: changes count_by_app_name in counts api to return apps with zero… (#32629)
* fix: changes count_by_app_name in counts api to return apps with zero unseen count * refactor: initialised count_by_app_name_dict with zeros
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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']
|
||||
|
||||
Reference in New Issue
Block a user