コード例 #1
0
ファイル: moderator.py プロジェクト: nishant1/django-gstudio
 def test_do_email_notification(self):
     comment = comments.get_model().objects.create(
         comment='My Comment', user=self.author, is_public=True,
         content_object=self.objecttype, site=self.site)
     self.assertEquals(len(mail.outbox), 0)
     moderator = ObjecttypeCommentModerator(Objecttype)
     moderator.mail_comment_notification_recipients = ['*****@*****.**']
     moderator.do_email_notification(comment, self.objecttype, 'request')
     self.assertEquals(len(mail.outbox), 1)
コード例 #2
0
ファイル: moderator.py プロジェクト: nishant1/django-gstudio
 def test_moderate(self):
     comment = comments.get_model().objects.create(
         comment='My Comment', user=self.author, is_public=True,
         content_object=self.objecttype, site=self.site)
     moderator = ObjecttypeCommentModerator(Objecttype)
     moderator.auto_moderate_comments = True
     moderator.spam_checker_backends = ()
     self.assertEquals(moderator.moderate(comment, self.objecttype, 'request'),
                       True)
     moderator.auto_moderate_comments = False
     self.assertEquals(moderator.moderate(comment, self.objecttype, 'request'),
                       False)
     self.assertEquals(comments.get_model().objects.filter(
         flags__flag='spam').count(), 0)
     moderator.spam_checker_backends = (
         'gstudio.spam_checker.backends.all_is_spam',)
     self.assertEquals(moderator.moderate(comment, self.objecttype, 'request'),
                       True)
     self.assertEquals(comments.get_model().objects.filter(
         flags__flag='spam').count(), 1)
コード例 #3
0
ファイル: moderator.py プロジェクト: nishant1/django-gstudio
    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.objecttype, site=self.site)
        moderator = ObjecttypeCommentModerator(Objecttype)
        moderator.email_notification_reply = True
        moderator.mail_comment_notification_recipients = ['*****@*****.**']
        moderator.do_email_reply(comment, self.objecttype, 'request')
        self.assertEquals(len(mail.outbox), 0)

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

        comment = comments.get_model().objects.create(
            comment='My Comment 3', user_email='*****@*****.**',
            content_object=self.objecttype, is_public=True, site=self.site)
        moderator.do_email_reply(comment, self.objecttype, '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.objecttype, site=self.site)
        moderator.do_email_reply(comment, self.objecttype, 'request')
        self.assertEquals(len(mail.outbox), 2)
        self.assertEquals(mail.outbox[1].bcc, [u'*****@*****.**',
                                               u'*****@*****.**'])