コード例 #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!')
コード例 #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!')
コード例 #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!')
コード例 #4
0
ファイル: test_views.py プロジェクト: ella/ella-flatcomments
    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!')
コード例 #5
0
ファイル: test_views.py プロジェクト: ella/ella-flatcomments
    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!')
コード例 #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())
コード例 #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)
コード例 #8
0
ファイル: test_views.py プロジェクト: ella/ella-flatcomments
 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())
コード例 #9
0
ファイル: test_views.py プロジェクト: ella/ella-flatcomments
 def test_login_required(self):
     response = views.post_comment(self.get_request(method='POST'), self.get_context())
     tools.assert_equals(302, response.status_code)