Пример #1
0
 def test_mod_one_cant_see_approved_responses(self):
     self.client.force_login(BypassCommunityModerationUserFactory())
     ResponseFactory(approved=False, author=UserFactory(username="******"))
     ResponseFactory(approved=True, author=UserFactory(username="******"))
     result = self.client.get("/api/response/")
     self.assertEqual(result.status_code, 200)
     self.assertEqual(len(result.json()["results"]), 1)
Пример #2
0
    def test_mod_one_cant_see_reject_responses(self):
        self.client.force_login(BypassCommunityModerationUserFactory())
        response = ResponseFactory(approved=False, author=UserFactory(username="******"))
        ModerationFactory(
            response=response,
            addressing_the_issue=False,
            personal=False,
            positive_in_tone=False,
            moderator=UserFactory(username="******"),
        )
        ModerationFactory(
            response=response,
            addressing_the_issue=False,
            personal=False,
            positive_in_tone=False,
            moderator=UserFactory(username="******"),
        )
        ModerationFactory(
            response=response,
            addressing_the_issue=False,
            personal=False,
            positive_in_tone=False,
            moderator=UserFactory(username="******"),
        )

        result = self.client.get("/api/response/")
        self.assertEqual(result.status_code, 200)
        self.assertEqual(len(result.json()["results"]), 0)
 def test_can_bypass_community_moderation(self, mock_reply_to_review):
     user = BypassCommunityModerationUserFactory()
     serializer = ResponseSerializerFactory(author=user)
     self.assertTrue(serializer.instance.approved)
     self.assertFalse(serializer.instance.staff_approved)
     self.assertFalse(serializer.instance.submitted_to_play_store)
     mock_reply_to_review.assert_not_called()
Пример #4
0
    def test_approval_as_mod_one(self):
        user = BypassCommunityModerationUserFactory()
        self.client.force_login(user)
        response = ResponseFactory(approved=False,
                                   author=UserFactory(username="******"))
        result = self.client.post(
            reverse('approve', kwargs={"response_pk": response.pk}))
        self.assertEqual(result.status_code, 200)

        response.refresh_from_db()
        self.assertTrue(response.approved)
        self.assertFalse(response.staff_approved)
Пример #5
0
    def test_put_changes_to_response_as_moderator_one(self):
        user = BypassCommunityModerationUserFactory()
        self.client.force_login(user)

        response = ResponseFactory(approved=False,
                                   text="Bad response",
                                   author=self.author_user)
        good_text = "GooD Response."
        result = self.client.put('/api/response/{}/'.format(response.pk),
                                 dict(text=good_text))
        self.assertEqual(result.status_code, 200)
        response.refresh_from_db()
        self.assertEqual(response.text, good_text)
    def test_approval_as_mod_one(self, mock_reply_to_review):
        user = BypassCommunityModerationUserFactory()
        self.client.force_login(user)
        response = ResponseFactory(approved=False, author=UserFactory(username="******"))
        result = self.client.post(
            reverse("approve", kwargs={"response_pk": response.pk})
        )
        self.assertEqual(result.status_code, 200)
        mock_reply_to_review.assert_not_called()

        response.refresh_from_db()
        self.assertTrue(response.approved)
        self.assertFalse(response.staff_approved)
        self.assertFalse(response.submitted_to_play_store)
Пример #7
0
    def test_first_approval(self):
        user = BypassCommunityModerationUserFactory()
        self.client.force_login(user)

        author = UserFactory(username="******")
        response = ResponseFactory(approved=False, author=author)

        result = self.client.post(
            reverse('approve', kwargs={"response_pk": response.pk}))
        self.assertEqual(result.status_code, 200)

        user.profile.refresh_from_db()
        author.profile.refresh_from_db()

        self.assertEqual(user.profile.karma_points, 1)
        self.assertEqual(author.profile.karma_points, 1)
Пример #8
0
 def test_can_skip_community_response_moderation(self):
     user = BypassCommunityModerationUserFactory()
     self.assertTrue(user.profile.can_skip_community_response_moderation)
 def test_can_bypass_community_moderation(self):
     user = BypassCommunityModerationUserFactory()
     serializer = ResponseSerializerFactory(author=user)
     self.assertTrue(serializer.instance.approved)