Esempio n. 1
0
 def test_doesnt_remove_if_already_reviewed(self):
     AssignedWithRoleReviewersFactory(reviewer=self.staff[1], submission=self.submissions[0], role=self.roles[0])
     ReviewFactory(author__reviewer=self.staff[1], author__staff=True, submission=self.submissions[0], draft=False)
     ReviewFactory(author__reviewer=self.staff[1], author__staff=True, submission=self.submissions[1], draft=False)
     submissions = self.submissions[0:2]
     reviewer_roles = [self.staff[0]]
     self.post_page(data=self.data(reviewer_roles, submissions))
     for submission in submissions:
         self.assertEqual(submission.assigned.count(), 2)
         reviewers = submission.assigned.values_list('reviewer', flat=True)
         self.assertIn(self.staff[0].pk, reviewers)
         self.assertIn(self.staff[1].pk, reviewers)
Esempio n. 2
0
 def test_opinionated_slash_confused_reviewer(self):
     staff = StaffFactory()
     submission = ApplicationSubmissionFactory()
     review_one = ReviewFactory(submission=submission)
     review_two = ReviewFactory(submission=submission)
     ReviewOpinionFactory(opinion_disagree=True, review=review_one, author__reviewer=staff)
     ReviewOpinionFactory(opinion_agree=True, review=review_two, author__reviewer=staff)
     qs = ApplicationSubmission.objects.for_table(user=staff)
     submission = qs[0]
     self.assertEqual(submission.opinion_disagree, 1)
     self.assertEqual(submission.review_count, 3)
     # Reviewers that disagree are not counted
     self.assertEqual(submission.review_submitted_count, 3)
     self.assertEqual(submission.review_recommendation, MAYBE)
Esempio n. 3
0
    def test_can_be_made_role_and_not_duplciated(self):
        submission = ApplicationSubmissionFactory()

        ReviewFactory(submission=submission, author__reviewer=self.staff[0], author__staff=True)

        self.post_form(submission, reviewer_roles=[self.staff[0]])
        self.assertCountEqual(submission.reviewers.all(), [self.staff[0]])
Esempio n. 4
0
    def test_dont_double_count_review_and_opinion(self):
        staff = StaffFactory()
        submission = ApplicationSubmissionFactory()

        review = ReviewFactory(submission=submission, author__reviewer=staff, author__staff=True)
        opinion = ReviewOpinionFactory(opinion_disagree=True, review=review)

        # Another pair of review/opinion
        review_two = ReviewFactory(author=opinion.author, submission=submission)
        ReviewOpinionFactory(opinion_disagree=True, author__reviewer=staff, author__staff=True, review=review_two)

        qs = ApplicationSubmission.objects.for_table(user=staff)
        submission = qs[0]
        self.assertEqual(submission.opinion_disagree, 2)
        self.assertEqual(submission.review_count, 2)
        self.assertEqual(submission.review_submitted_count, 2)
        self.assertEqual(submission.review_recommendation, MAYBE)
Esempio n. 5
0
    def test_can_add_external_reviewer_and_review_remains(self):
        submission = InvitedToProposalFactory(lead=self.user)
        reviewer = self.reviewers[0]
        AssignedReviewersFactory(submission=submission, reviewer=reviewer)
        ReviewFactory(submission=submission, author__reviewer=reviewer)

        self.post_form(submission, reviewers=[self.reviewers[1]])

        self.assertCountEqual(submission.reviewers.all(), [reviewer, self.reviewers[1]])
Esempio n. 6
0
 def test_handles_negative_reviews(self):
     submission = ApplicationSubmissionFactory()
     ReviewFactory(submission=submission)
     data = ReviewSummarySerializer(submission).data
     self.assertEqual(data['count'], 1)
     self.assertEqual(data['score'], 0)
     self.assertEqual(data['recommendation'], {'value': 0, 'display': 'No'})
     self.assertEqual(len(data['assigned']), 1)
     self.assertEqual(len(data['reviews']), 1)
Esempio n. 7
0
 def test_review_outcome(self):
     staff = StaffFactory()
     submission = ApplicationSubmissionFactory()
     ReviewFactory(submission=submission)
     qs = ApplicationSubmission.objects.for_table(user=staff)
     submission = qs[0]
     self.assertEqual(submission.opinion_disagree, None)
     self.assertEqual(submission.review_count, 1)
     self.assertEqual(submission.review_submitted_count, 1)
     self.assertEqual(submission.review_recommendation, NO)
Esempio n. 8
0
 def test_review_saved_on_activity(self):
     review = ReviewFactory()
     self.adapter.send_message(
         'a message',
         user=review.author.reviewer,
         source=review.submission,
         sources=[],
         related=review,
     )
     activity = Activity.objects.first()
     self.assertEqual(activity.related_object, review)
Esempio n. 9
0
    def test_lead_can_change_role_reviewer_and_review_remains(self):
        submission = ApplicationSubmissionFactory()
        AssignedWithRoleReviewersFactory(role=self.roles[0], submission=submission, reviewer=self.staff[0])

        # Add a review from that staff reviewer
        ReviewFactory(submission=submission, author__reviewer=self.staff[0], author__staff=True)

        # Assign a different reviewer to the same role
        self.post_form(submission, reviewer_roles=[self.staff[1]])

        # Make sure that the ex-role-reviewer is still assigned record
        self.assertCountEqual(submission.reviewers.all(), self.staff[0:2])
Esempio n. 10
0
    def test_queries_existing_reviews(self):
        user = StaffFactory()
        submission = InvitedToProposalFactory(lead=user)

        reviewers = ReviewerFactory.create_batch(4)

        ReviewFactory(submission=submission, author__reviewer=reviewers[0])
        ReviewFactory(submission=submission, author__reviewer=reviewers[1])

        data = {'reviewer_reviewers': [reviewer.id for reviewer in reviewers[2:]]}

        form = UpdateReviewersForm(data, user=user, instance=submission)

        self.assertTrue(form.is_valid())

        # 1 - Submission
        # 1 - Delete old
        # 1 - Cache existing
        # 1 - Add new
        with self.assertNumQueries(5):
            form.save()
Esempio n. 11
0
 def test_disagree_review_is_maybe(self):
     staff = StaffFactory()
     submission = ApplicationSubmissionFactory()
     review = ReviewFactory(submission=submission)
     ReviewOpinionFactory(opinion_disagree=True, review=review)
     qs = ApplicationSubmission.objects.for_table(user=staff)
     submission = qs[0]
     self.assertEqual(submission.opinion_disagree, 1)
     self.assertEqual(submission.review_count, 2)
     # Reviewers that disagree are not counted
     self.assertEqual(submission.review_submitted_count, 1)
     self.assertEqual(submission.review_recommendation, MAYBE)
Esempio n. 12
0
    def test_submissions_dont_conflict(self):
        staff = StaffFactory()
        submission_one = ApplicationSubmissionFactory()
        submission_two = ApplicationSubmissionFactory()
        review_one = ReviewFactory(submission=submission_one)
        ReviewOpinionFactory(opinion_disagree=True, review=review_one)

        ReviewFactory(submission=submission_two)

        qs = ApplicationSubmission.objects.order_by('pk').for_table(user=staff)
        submission = qs[0]
        self.assertEqual(submission, submission_one)
        self.assertEqual(submission.opinion_disagree, 1)
        self.assertEqual(submission.review_count, 2)
        # Reviewers that disagree are not counted
        self.assertEqual(submission.review_submitted_count, 1)
        self.assertEqual(submission.review_recommendation, MAYBE)

        submission = qs[1]
        self.assertEqual(submission, submission_two)
        self.assertEqual(submission.opinion_disagree, None)
        self.assertEqual(submission.review_count, 1)
        self.assertEqual(submission.review_submitted_count, 1)
        self.assertEqual(submission.review_recommendation, NO)
Esempio n. 13
0
 def test_waiting_for_review_after_agreement_is_empty(self):
     staff = StaffFactory()
     submission = ApplicationSubmissionFactory(status='external_review',
                                               workflow_stages=2,
                                               reviewers=[staff, self.user])
     review = ReviewFactory(submission=submission,
                            author__reviewer=staff,
                            author__staff=True,
                            recommendation_yes=True)
     ReviewOpinionFactory(review=review,
                          author__reviewer=self.user,
                          opinion_agree=True)
     response = self.get_page()
     self.assertContains(response, 'Waiting for your review')
     self.assertContains(response, "Nice! You're all caught up.")
     self.assertEquals(response.context['awaiting_reviews']['count'], 0)