Skip to content

Commit

Permalink
fix: updated unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AhtishamShahid committed Sep 24, 2024
1 parent 077a5ca commit 64c8efa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions openedx/core/djangoapps/notifications/notification_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ def get_notification_context_with_author_pronoun(context: Dict) -> Dict:

# Returns notification content for the new_comment notification.
def get_new_comment_notification_context(context):
"""
Returns the context for the new_comment notification
"""
if not context.get('grouped'):
return get_notification_context_with_author_pronoun(context)
num_repliers = context['grouped_count']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_group_creates_grouping_keys(self):
"""
updated_context = NewCommentGrouper().group(self.new_notification, self.old_notification)

self.assertIn('replier_name_grouped', updated_context)
self.assertIn('replier_name_list', updated_context)
self.assertIn('grouped_count', updated_context)
self.assertEqual(updated_context['grouped_count'], 2)
self.assertTrue(updated_context['grouped'])
Expand All @@ -76,16 +76,16 @@ def test_group_appends_to_existing_grouping(self):
# Mock a pre-grouped notification
self.old_notification.content_context = {
'replier_name': 'User1',
'replier_name_grouped': ['User1', 'User2'],
'replier_name_list': ['User1', 'User2'],
'grouped': True,
'grouped_count': 2
}
self.new_notification.content_context = {'replier_name': 'User3'}

updated_context = NewCommentGrouper().group(self.new_notification, self.old_notification)

self.assertIn('replier_name_grouped', updated_context)
self.assertEqual(len(updated_context['replier_name_grouped']), 3)
self.assertIn('replier_name_list', updated_context)
self.assertEqual(len(updated_context['replier_name_list']), 3)
self.assertEqual(updated_context['grouped_count'], 3)


Expand Down

0 comments on commit 64c8efa

Please sign in to comment.