def test_suspended_user_can_delete_own_comment(self):
     question = self.post_question()
     comment = self.user.post_comment(
                     parent_post = question,
                     body_text = 'test comment'
                 )
     self.user.set_status('s')
     self.user.delete_comment(comment)
     self.assertTrue(
         template_filters.can_delete_comment(
             self.user, 
             comment
         )
     )
 def test_moderator_can_delete_comment(self):
     question = self.post_question()
     comment = self.user.post_comment(
                     parent_post = question,
                     body_text = 'test comment'
                 )
     self.other_user.set_status('m')
     self.other_user.delete_comment(comment)
     self.assertTrue(
         template_filters.can_delete_comment(
             self.other_user, 
             comment
         )
     )
 def test_admin_can_delete_comment(self):
     question = self.post_question()
     comment = self.user.post_comment(
                     parent_post = question,
                     body_text = 'test comment'
                 )
     self.other_user.is_superuser = True
     self.other_user.delete_comment(comment)
     self.assertTrue(
         template_filters.can_delete_comment(
             self.other_user, 
             comment
         )
     )
    def test_high_rep_user_can_delete_comment(self):
        question = self.post_question()
        comment = self.user.post_comment(
                        parent_post = question,
                        body_text = 'test comment'
                    )
        self.other_user.reputation = \
            askbot_settings.MIN_REP_TO_DELETE_OTHERS_COMMENTS

        self.other_user.delete_comment(comment)
        self.assertTrue(
            template_filters.can_delete_comment(
                self.other_user, 
                comment
            )
        )
 def test_blocked_user_cannot_delete_own_comment(self):
     question = self.post_question()
     comment = self.user.post_comment(
                     parent_post = question,
                     body_text = 'test comment'
                 )
     self.user.set_status('b')
     self.assertRaises(
         exceptions.PermissionDenied,
         self.user.delete_post,
         post = comment
     )
     self.assertFalse(
         template_filters.can_delete_comment(
             self.user, 
             comment
         )
     )
 def test_high_rep_suspended_user_cannot_delete_others_comment(self):
     question = self.post_question()
     comment = self.user.post_comment(
                     parent_post = question,
                     body_text = 'test comment'
                 )
     self.other_user.reputation = \
         askbot_settings.MIN_REP_TO_DELETE_OTHERS_COMMENTS + 1
     self.other_user.set_status('s')
     self.assertRaises(
             exceptions.PermissionDenied,
             self.other_user.delete_post,
             post = comment
         )
     self.assertFalse(
         template_filters.can_delete_comment(
             self.other_user, 
             comment
         )
     )
 def test_low_rep_user_can_delete_own_comment(self):
     question = self.post_question()
     answer = self.other_user.post_answer(
                     question = question,
                     body_text = 'test answer'
                 )
     comment = self.user.post_comment(
                     parent_post = answer,
                     body_text = 'test comment'
                 )
     assert(
         self.user.reputation < \
         askbot_settings.MIN_REP_TO_DELETE_OTHERS_COMMENTS
     )
     self.user.delete_comment(comment)
     self.assertTrue(
         template_filters.can_delete_comment(
             self.user, 
             comment
         )
     )