Esempio n. 1
0
    def test_post_with_content_goes_through(self):
        response = views.post_comment(self.get_request(method='POST', user=self.user, data={'comment': 'New Comment!'}), self.get_context())

        tools.assert_equals(302, response.status_code)
        tools.assert_equals(1, self.comment_list.count())
        c = self.comment_list.last_comment()
        tools.assert_equals(c.get_absolute_url(), response['Location'])
        tools.assert_equals(c.comment, 'New Comment!')
Esempio n. 2
0
    def test_users_can_edit_their_comments(self):
        c = self._get_comment()
        c.post()
        response = views.post_comment(self.get_request(method='POST', user=self.user, data={'comment': 'New Comment Text!'}), self.get_context(), str(c.pk))

        tools.assert_equals(302, response.status_code)
        tools.assert_equals(1, self.comment_list.count())
        c = self.comment_list.last_comment()
        tools.assert_equals(c.get_absolute_url(), response['Location'])
        tools.assert_equals(c.comment, 'New Comment Text!')
Esempio n. 3
0
    def test_users_cannot_other_users_comments(self):
        c = self._get_comment()
        c.post()
        user = User.objects.create_user('some_OTHER_user', '*****@*****.**')

        response = views.post_comment(self.get_request(method='POST', user=user, data={'comment': 'New Comment Text!'}), self.get_context(), str(c.pk))

        tools.assert_equals(403, response.status_code)
        c = self.comment_list.last_comment()
        tools.assert_not_equals(c.comment, 'New Comment Text!')
Esempio n. 4
0
    def test_users_can_edit_their_comments(self):
        c = self._get_comment()
        c.post()
        response = views.post_comment(self.get_request(method='POST', user=self.user, data={'comment': 'New Comment Text!'}), self.get_context(), str(c.pk))

        tools.assert_equals(302, response.status_code)
        tools.assert_equals(1, self.comment_list.count())
        c = self.comment_list.last_comment()
        tools.assert_equals(c.get_absolute_url(), response['Location'])
        tools.assert_equals(c.comment, 'New Comment Text!')
Esempio n. 5
0
    def test_users_cannot_other_users_comments(self):
        c = self._get_comment()
        c.post()
        user = User.objects.create_user('some_OTHER_user', '*****@*****.**')

        response = views.post_comment(self.get_request(method='POST', user=user, data={'comment': 'New Comment Text!'}), self.get_context(), str(c.pk))

        tools.assert_equals(403, response.status_code)
        c = self.comment_list.last_comment()
        tools.assert_not_equals(c.comment, 'New Comment Text!')
Esempio n. 6
0
 def test_honeypot_causes_post_to_fail(self):
     response = views.post_comment(self.get_request(method='POST', user=self.user, data={'comment': 'New Comment!', 'honeypot': 'Heya'}), self.get_context())
     tools.assert_equals(200, response.status_code)
     tools.assert_equals(0, self.comment_list.count())
Esempio n. 7
0
 def test_login_required(self):
     response = views.post_comment(self.get_request(method='POST'), self.get_context())
     tools.assert_equals(302, response.status_code)
Esempio n. 8
0
 def test_honeypot_causes_post_to_fail(self):
     response = views.post_comment(self.get_request(method='POST', user=self.user, data={'comment': 'New Comment!', 'honeypot': 'Heya'}), self.get_context())
     tools.assert_equals(200, response.status_code)
     tools.assert_equals(0, self.comment_list.count())
Esempio n. 9
0
 def test_login_required(self):
     response = views.post_comment(self.get_request(method='POST'), self.get_context())
     tools.assert_equals(302, response.status_code)