Пример #1
0
 def test_topic_notification_comment_handler(self):
     """
     set is_read=False when a comment is posted
     """
     comment = utils.create_comment(topic=self.topic)
     comment_posted.send(sender=self.topic.__class__, comment=comment, mentions=None)
     self.assertFalse(TopicNotification.objects.get(pk=self.topic_notification.pk).is_read)
Пример #2
0
 def test_topic_notification_comment_handler_unactive(self):
     """
     do nothing if notification is_active=False
     """
     TopicNotification.objects.filter(pk=self.topic_notification.pk).update(is_active=False)
     comment = utils.create_comment(topic=self.topic_notification.topic)
     comment_posted.send(sender=self.topic.__class__, comment=comment, mentions=None)
     self.assertTrue(TopicNotification.objects.get(pk=self.topic_notification.pk).is_read)
Пример #3
0
 def test_topic_notification_mention_handler(self):
     """
     create notification on mention
     """
     topic = utils.create_topic(self.category)
     mentions = {self.user.username: self.user, }
     comment = utils.create_comment(topic=topic)
     comment_posted.send(sender=self.topic.__class__, comment=comment, mentions=mentions)
     self.assertEqual(TopicNotification.objects.get(user=self.user, comment=comment).action, MENTION)
     self.assertFalse(TopicNotification.objects.get(user=self.user, comment=comment).is_read)
Пример #4
0
 def test_topic_notification_comment_handler(self):
     """
     set is_read=False when a comment is posted
     """
     comment = utils.create_comment(topic=self.topic)
     comment_posted.send(sender=self.topic.__class__,
                         comment=comment,
                         mentions=None)
     self.assertFalse(
         TopicNotification.objects.get(
             pk=self.topic_notification.pk).is_read)
Пример #5
0
 def test_topic_notification_mention_handler_unactive(self):
     """
     set is_read=False when user gets mentioned
     even if is_active=False
     """
     TopicNotification.objects.filter(pk=self.topic_notification.pk).update(is_active=False)
     mentions = {self.user.username: self.user, }
     comment = utils.create_comment(topic=self.topic_notification.topic)
     comment_posted.send(sender=self.topic.__class__, comment=comment, mentions=mentions)
     self.assertEqual(TopicNotification.objects.get(pk=self.topic_notification.pk).action, MENTION)
     self.assertFalse(TopicNotification.objects.get(pk=self.topic_notification.pk).is_read)
Пример #6
0
 def test_topic_notification_comment_handler_unactive(self):
     """
     do nothing if notification is_active=False
     """
     TopicNotification.objects.filter(pk=self.topic_notification.pk).update(
         is_active=False)
     comment = utils.create_comment(topic=self.topic_notification.topic)
     comment_posted.send(sender=self.topic.__class__,
                         comment=comment,
                         mentions=None)
     self.assertTrue(
         TopicNotification.objects.get(
             pk=self.topic_notification.pk).is_read)
Пример #7
0
 def test_topic_notification_mention_handler(self):
     """
     create notification on mention
     """
     topic = utils.create_topic(self.category)
     mentions = {
         self.user.username: self.user,
     }
     comment = utils.create_comment(topic=topic)
     comment_posted.send(sender=self.topic.__class__,
                         comment=comment,
                         mentions=mentions)
     self.assertEqual(
         TopicNotification.objects.get(user=self.user,
                                       comment=comment).action, MENTION)
     self.assertFalse(
         TopicNotification.objects.get(user=self.user,
                                       comment=comment).is_read)
Пример #8
0
 def test_topic_notification_mention_handler_unactive(self):
     """
     set is_read=False when user gets mentioned
     even if is_active=False
     """
     TopicNotification.objects.filter(pk=self.topic_notification.pk).update(
         is_active=False)
     mentions = {
         self.user.username: self.user,
     }
     comment = utils.create_comment(topic=self.topic_notification.topic)
     comment_posted.send(sender=self.topic.__class__,
                         comment=comment,
                         mentions=mentions)
     self.assertEqual(
         TopicNotification.objects.get(
             pk=self.topic_notification.pk).action, MENTION)
     self.assertFalse(
         TopicNotification.objects.get(
             pk=self.topic_notification.pk).is_read)