Beispiel #1
0
    def test_flag_hide_flags_flag_makes_two_rows(self):
        self.hit_flag_endpoint(user=self.user)
        self.assertEqual(1, EnhancedThreadedCommentFlag.objects.all().count(),
                         "There should be 1 comment flag row created")

        req = make_post_request(user=self.admin,
                                params=_comment_ids_to_params(self.comment.id))
        hide_flags(req, self.instance)
        self.assertEqual(1, EnhancedThreadedCommentFlag.objects.all().count(),
                         "There should still 1 comment flag row after unflag")

        self.hit_flag_endpoint(user=self.user)
        self.assertEqual(2, EnhancedThreadedCommentFlag.objects.all().count(),
                         "There should be 2 comment flag rows")
Beispiel #2
0
    def test_batch_hide_flags(self):
        self.hit_flag_endpoint(user=self.admin)

        self.hit_flag_endpoint(user=self.user)

        self.assertEqual(2, EnhancedThreadedCommentFlag.objects
                         .filter(hidden=False).count(),
                         "There should be 2 non-hidden comment flag rows")

        params = _comment_ids_to_params(self.comment.id, self.comment2.id)
        req = make_request(params, user=self.admin, method='POST')
        hide_flags(req, self.instance)
        self.assertEqual(2, EnhancedThreadedCommentFlag.objects
                         .filter(hidden=True).count(),
                         "There should be 2 hidden comment flag rows")
Beispiel #3
0
    def test_flag_hide_flags_flag_makes_two_rows(self):
        self.hit_flag_endpoint(user=self.user)
        self.assertEqual(1,
                         EnhancedThreadedCommentFlag.objects.all().count(),
                         "There should be 1 comment flag row created")

        req = make_post_request(user=self.admin,
                                params=_comment_ids_to_params(self.comment.id))
        hide_flags(req, self.instance)
        self.assertEqual(1,
                         EnhancedThreadedCommentFlag.objects.all().count(),
                         "There should still 1 comment flag row after unflag")

        self.hit_flag_endpoint(user=self.user)
        self.assertEqual(2,
                         EnhancedThreadedCommentFlag.objects.all().count(),
                         "There should be 2 comment flag rows")
Beispiel #4
0
    def test_batch_hide_flags(self):
        self.hit_flag_endpoint(user=self.admin)

        self.hit_flag_endpoint(user=self.user)

        self.assertEqual(
            2,
            EnhancedThreadedCommentFlag.objects.filter(hidden=False).count(),
            "There should be 2 non-hidden comment flag rows")

        params = _comment_ids_to_params(self.comment.id, self.comment2.id)
        req = make_request(params, user=self.admin, method='POST')
        hide_flags(req, self.instance)
        self.assertEqual(
            2,
            EnhancedThreadedCommentFlag.objects.filter(hidden=True).count(),
            "There should be 2 hidden comment flag rows")
Beispiel #5
0
    def test_hide_flags(self):
        self.hit_flag_endpoint(user=self.user)
        self.hit_flag_endpoint(user=self.admin)
        self.assertEqual(2, EnhancedThreadedCommentFlag.objects
                         .filter(hidden=False).count(),
                         "There should be 2 non-hidden comment flag rows")
        updated_comment = EnhancedThreadedComment.objects.get(
            pk=self.comment.id)
        self.assertTrue(updated_comment.is_flagged_by_user(self.user))
        self.assertTrue(updated_comment.is_flagged_by_user(self.admin))

        req = make_post_request(user=self.admin,
                                params=_comment_ids_to_params(self.comment.id))
        hide_flags(req, self.instance)
        self.assertEqual(2, EnhancedThreadedCommentFlag.objects
                         .filter(hidden=True).count(),
                         "There should be 2 hidden comment flag rows")
        updated_comment = EnhancedThreadedComment.objects.get(
            pk=self.comment.id)
        self.assertFalse(updated_comment.is_flagged_by_user(self.user))
        self.assertFalse(updated_comment.is_flagged_by_user(self.admin))
Beispiel #6
0
    def test_hide_flags(self):
        self.hit_flag_endpoint(user=self.user)
        self.hit_flag_endpoint(user=self.admin)
        self.assertEqual(
            2,
            EnhancedThreadedCommentFlag.objects.filter(hidden=False).count(),
            "There should be 2 non-hidden comment flag rows")
        updated_comment = EnhancedThreadedComment.objects.get(
            pk=self.comment.id)
        self.assertTrue(updated_comment.is_flagged_by_user(self.user))
        self.assertTrue(updated_comment.is_flagged_by_user(self.admin))

        req = make_post_request(user=self.admin,
                                params=_comment_ids_to_params(self.comment.id))
        hide_flags(req, self.instance)
        self.assertEqual(
            2,
            EnhancedThreadedCommentFlag.objects.filter(hidden=True).count(),
            "There should be 2 hidden comment flag rows")
        updated_comment = EnhancedThreadedComment.objects.get(
            pk=self.comment.id)
        self.assertFalse(updated_comment.is_flagged_by_user(self.user))
        self.assertFalse(updated_comment.is_flagged_by_user(self.admin))