def test_is_approved_after_moderation(self): response = ResponseFactory(approved=False, author=UserFactory(username="******")) 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) user = UserFactory(username="******") self.client.force_login(user) 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) user = UserFactory(username="******") self.client.force_login(user) 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)
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)
def test_create_moderation(self, mock_reply_to_review): response = ResponseFactory(approved=False, author=UserFactory(username="******")) 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.assertFalse(response.approved) self.assertFalse(response.staff_approved) self.assertFalse(response.submitted_to_play_store)
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)
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)
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)
def test_is_rejected_after_negative_moderations(self, mock_reply_to_review): response = ResponseFactory(approved=False, author=UserFactory(username="******")) # TODO: I don't think these ModerationFactories should be required - once a review has a moderation # failing on all three counts, it won't meet the approved criteria and should be immediately rejected, no? ModerationFactory(response=response) ModerationFactory(response=response) result = self.client.post( reverse("create_moderation", kwargs={"response_pk": response.pk}), data=dict(positive_in_tone=False, addressing_the_issue=False, personal=False), ) response.refresh_from_db() self.assertEqual(result.status_code, 201) self.assertTrue(response.rejected)
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)