Esempio n. 1
0
 def test_molo_post_comment(self):
     data = MoloCommentForm(self.user, {}).generate_security_data()
     data.update({
         'name': 'the supplied name',
         'comment': 'Foo',
     })
     self.client.post(
         reverse('molo.commenting:molo-comments-post'), data)
     [comment] = MoloComment.objects.filter(user=self.user)
     self.assertEqual(comment.comment, 'Foo')
     self.assertEqual(comment.user_name, 'the supplied name')
Esempio n. 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')
Esempio n. 3
0
    def test_molo_post_comment_without_email_address(self):
        self.user.email = ''
        self.user.save()

        data = MoloCommentForm(self.user, {}).generate_security_data()
        data.update({
            'name': 'the supplied name',
            'comment': 'Foo',
        })
        self.client.post(
            reverse('molo.commenting:molo-comments-post'), data)
        [comment] = MoloComment.objects.filter(user=self.user)
        self.assertEqual(comment.comment, 'Foo')
        self.assertEqual(comment.user_name, 'the supplied name')
        self.assertEqual(comment.user_email, '*****@*****.**')
Esempio n. 4
0
 def test_commenting_open(self):
     article = ArticlePage.objects.create(
         title='article 1', depth=1,
         subtitle='article 1 subtitle',
         slug='article-1', path=[1], commenting_state='O')
     article.save()
     initial = {
         'object_pk': article.id,
         'content_type': "core.articlepage"
     }
     data = MoloCommentForm(article, {},
                            initial=initial).generate_security_data()
     data.update({
         'comment': "This is a second comment",
     })
     response = self.client.post(
         reverse('molo.commenting:molo-comments-post'), data)
     self.assertEqual(response.status_code, 302)