コード例 #1
0
 def test_do_email_notification(self):
     comment = comments.get_model().objects.create(
         comment='My Comment', user=self.author, is_public=True,
         content_object=self.gbobject, site=self.site)
     self.assertEquals(len(mail.outbox), 0)
     moderator = GbobjectCommentModerator(Gbobject)
     moderator.mail_comment_notification_recipients = ['*****@*****.**']
     moderator.do_email_notification(comment, self.gbobject, 'request')
     self.assertEquals(len(mail.outbox), 1)
コード例 #2
0
 def test_moderate(self):
     comment = comments.get_model().objects.create(
         comment='My Comment', user=self.author, is_public=True,
         content_object=self.gbobject, site=self.site)
     moderator = GbobjectCommentModerator(Gbobject)
     moderator.auto_moderate_comments = True
     moderator.spam_checker_backends = ()
     self.assertEquals(moderator.moderate(comment, self.gbobject, 'request'),
                       True)
     moderator.auto_moderate_comments = False
     self.assertEquals(moderator.moderate(comment, self.gbobject, 'request'),
                       False)
     self.assertEquals(comments.get_model().objects.filter(
         flags__flag='spam').count(), 0)
     moderator.spam_checker_backends = (
         'objectapp.spam_checker.backends.all_is_spam',)
     self.assertEquals(moderator.moderate(comment, self.gbobject, 'request'),
                       True)
     self.assertEquals(comments.get_model().objects.filter(
         flags__flag='spam').count(), 1)
コード例 #3
0
    def test_do_email_reply(self):
        comment = comments.get_model().objects.create(
            comment='My Comment 1', user=self.author, is_public=True,
            content_object=self.gbobject, site=self.site)
        moderator = GbobjectCommentModerator(Gbobject)
        moderator.email_notification_reply = True
        moderator.mail_comment_notification_recipients = ['*****@*****.**']
        moderator.do_email_reply(comment, self.gbobject, 'request')
        self.assertEquals(len(mail.outbox), 0)

        comment = comments.get_model().objects.create(
            comment='My Comment 2', user_email='*****@*****.**',
            content_object=self.gbobject, is_public=True, site=self.site)
        moderator.do_email_reply(comment, self.gbobject, 'request')
        self.assertEquals(len(mail.outbox), 0)

        comment = comments.get_model().objects.create(
            comment='My Comment 3', user_email='*****@*****.**',
            content_object=self.gbobject, is_public=True, site=self.site)
        moderator.do_email_reply(comment, self.gbobject, 'request')
        self.assertEquals(len(mail.outbox), 1)
        self.assertEquals(mail.outbox[0].bcc, [u'*****@*****.**'])

        comment = comments.get_model().objects.create(
            comment='My Comment 4', user=self.author, is_public=True,
            content_object=self.gbobject, site=self.site)
        moderator.do_email_reply(comment, self.gbobject, 'request')
        self.assertEquals(len(mail.outbox), 2)
        self.assertEquals(mail.outbox[1].bcc, [u'*****@*****.**',
                                               u'*****@*****.**'])