def test_can_bypass_staff_moderation(self, mock_reply_to_review):
     user = BypassStaffModerationUserFactory()
     serializer = ResponseSerializerFactory(author=user)
     self.assertTrue(serializer.instance.approved)
     self.assertTrue(serializer.instance.staff_approved)
     self.assertTrue(serializer.instance.submitted_to_play_store)
     mock_reply_to_review.assert_called()
Ejemplo n.º 2
0
    def test_mod_two_cant_see_rejected_responses(self):
        self.client.force_login(BypassStaffModerationUserFactory())
        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)
Ejemplo n.º 3
0
 def test_mod_two_cant_see_staff_approved_responses(self):
     self.client.force_login(BypassStaffModerationUserFactory())
     ResponseFactory(approved=False, author=UserFactory(username="******"))
     ResponseFactory(approved=True, author=UserFactory(username="******"))
     ResponseFactory(approved=True, staff_approved=True, author=UserFactory(username="******"))
     result = self.client.get('/api/response/')
     self.assertEqual(result.status_code, 200)
     self.assertEqual(len(result.json()['results']), 2)
Ejemplo n.º 4
0
 def test_user_with_non_matching_moderator_languages(self):
     user = BypassStaffModerationUserFactory(
         profile=factory.RelatedFactory(
             "mresponse.users.tests.factories.UserProfileFactory",
             factory_related_name="user",
             permissions_in_locales=["de", "fr"],
         )
     )
     review = ReviewFactory(review_language="es")
     self.assertFalse(user_can_bypass_staff_approval_for_review(user, review))
 def test_cannot_bypass_staff_moderation_with_wrong_locale(
         self, mock_user_can_bypass_staff_approval_for_review,
         mock_reply_to_review):
     mock_user_can_bypass_staff_approval_for_review.return_value = False
     user = BypassStaffModerationUserFactory()
     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()
Ejemplo n.º 6
0
    def test_approval_as_mod_two(self):
        user = BypassStaffModerationUserFactory()
        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.assertTrue(response.staff_approved)
Ejemplo n.º 7
0
    def test_put_changes_to_response_as_moderator_two(self):
        user = BypassStaffModerationUserFactory()
        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_two(self, mock_reply_to_review):
        user = BypassStaffModerationUserFactory()
        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_called()

        response.refresh_from_db()
        self.assertTrue(response.approved)
        self.assertTrue(response.staff_approved)
        self.assertTrue(response.submitted_to_play_store)
Ejemplo n.º 9
0
    def test_mod_two_can_see_approved_responses(self):
        self.client.force_login(BypassStaffModerationUserFactory())
        response = ResponseFactory(approved=False, author=UserFactory(username="******"))
        ModerationFactory(response=response, moderator=UserFactory(username="******"))
        ModerationFactory(response=response, moderator=UserFactory(username="******"))
        ModerationFactory(response=response, moderator=UserFactory(username="******"))
        response.refresh_from_db()
        self.assertTrue(response.is_community_approved())

        ResponseFactory(approved=True, author=UserFactory(username="******"))
        ResponseFactory(approved=True, staff_approved=True, author=UserFactory(username="******"))
        result = self.client.get('/api/response/')
        self.assertEqual(result.status_code, 200)
        self.assertEqual(len(result.json()['results']), 2)
Ejemplo n.º 10
0
    def test_is_staff_approved_after_moderation_by_mod_two(self):
        response = ResponseFactory(approved=False, author=UserFactory(username="******"))
        ModerationFactory(response=response, positive_in_tone=True)
        ModerationFactory(response=response, positive_in_tone=True)

        self.client.force_login(BypassStaffModerationUserFactory())
        result = self.client.post(
            reverse("create_moderation", kwargs={"response_pk": response.pk}),
            data=dict(positive_in_tone=True, addressing_the_issue=True, personal=True),
        )

        self.assertEqual(result.status_code, 201)

        response.refresh_from_db()
        self.assertTrue(response.approved)
        self.assertTrue(response.staff_approved)
Ejemplo n.º 11
0
    def test_isnt_staff_approved_after_moderation_by_mod_two_without_locale(
        self, mock_moderator_in_review_langauge, mock_reply_to_review
    ):
        mock_moderator_in_review_langauge.return_value = False
        response = ResponseFactory(approved=False, author=UserFactory(username="******"))

        self.client.force_login(BypassStaffModerationUserFactory())
        result = self.client.post(
            reverse("create_moderation", kwargs={"response_pk": response.pk}),
            data=dict(positive_in_tone=True, addressing_the_issue=True, personal=True),
        )

        self.assertEqual(result.status_code, 201)
        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)
Ejemplo n.º 12
0
    def test_approval_after_moderation_by_staff(self):
        user = BypassStaffModerationUserFactory()
        self.client.force_login(user)
        self.assertEqual(user.profile.karma_points, 0)

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

        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, 3)
        self.assertEqual(author.profile.karma_points, 1)
Ejemplo n.º 13
0
 def test_can_bypass_staff_moderation(self):
     user = BypassStaffModerationUserFactory()
     serializer = ResponseSerializerFactory(author=user)
     self.assertTrue(serializer.instance.staff_approved)