Exemple #1
0
    def test_comment_filters(self):
        GemSettings.objects.create(site_id=Main.objects.first().get_site().pk,
                                   banned_keywords_and_patterns='naughty')

        form_data = self.getValidData(self.article)

        # check if user has typed in a number
        comment_form = MoloCommentForm(self.article,
                                       data=dict(form_data,
                                                 comment="0821111111"))

        self.assertFalse(comment_form.is_valid())

        # check if user has typed in an email address
        comment_form = MoloCommentForm(self.article,
                                       data=dict(form_data,
                                                 comment="*****@*****.**"))

        self.assertFalse(comment_form.is_valid())

        # check if user has used a banned keyword
        comment_form = MoloCommentForm(self.article,
                                       data=dict(form_data, comment="naughty"))

        self.assertFalse(comment_form.is_valid())
Exemple #2
0
 def test_anonymous_comment_with_alias(self):
     self.client.login(username='******', password='******')
     self.user.profile.alias = 'this is my alias'
     self.user.profile.save()
     data = MoloCommentForm(self.user, {}).generate_security_data()
     data.update({
         'comment': 'Foo',
         'submit_anonymously': '1',
     })
     self.client.post(reverse('molo.commenting:molo-comments-post'), data)
     comment = MoloComment.objects.filter(user=self.user).first()
     self.assertEqual(comment.comment, 'Foo')
     self.assertEqual(comment.user_name, 'Anonymous')
Exemple #3
0
 def getValidData(self, obj):
     form = MoloCommentForm(obj)
     form_data = self.getData()
     form_data.update(form.initial)
     return form_data