Exemple #1
0
    def test_add_guest(self):
        data = {
            "text": "Foo bar text",
            'text_filter': "markdown",
            "nickname": "Test User",
            "email": "*****@*****.**",
        }
        initial_request = self.client.get("/foobar/")
        response_dict = views.add_comment(
                    initial_request,
                    next="/",
                    post=self.post
            )
        response_dict["comment_form"].as_p()
        data.update(self.hack_captcha(initial_request))

        request = self.client.post("/foobar/", data=data)
        request.session = initial_request.session

        response = views.add_comment(
                            request,
                            next="/",
                            post=self.post
                    )

        self.assert_(isinstance(response, http.HttpResponse))
        self.assertResponseStatus(response, http.HttpResponseRedirect.status_code)

        comment = Comment.objects.get()

        self.assertEqual(comment.status, Comment.statuses.published)
Exemple #2
0
    def test_add(self):
        self.login()

        data = {
            "text": "Foo bar text",
            'text_filter': "markdown"
        }

        request = self.client.post("/foobar/", data=data)

        response = views.add_comment(
            request,
            next="/",
            post=self.post
        )

        self.assert_(isinstance(response, http.HttpResponse))
        self.assertResponseStatus(response, http.HttpResponseRedirect.status_code)

        comment = Comment.objects.get()

        self.assertEqual(comment.status, Comment.statuses.published)

        post = Post.objects.get(pk=self.post.pk)
        self.assertEqual(post.comment_count, 1)
Exemple #3
0
    def test_edit(self):
        comment = self._create_comment()

        self.login()

        data = {
            "text": "New comment text",
            'text_filter': "markdown",
        }

        request = self.client.post("/foobar/", data=data)

        response = views.add_comment(
            request,
            next="/",
            post=self.post,
            comment=comment
        )
        self.assert_(isinstance(response, http.HttpResponse))
        self.assertResponseStatus(response, http.HttpResponseRedirect.status_code)

        comment = Comment.objects.get()

        self.assertEqual(comment.text, data["text"])