Beispiel #1
0
    def test_queries_reviewers_swap(self):
        user = StaffFactory()
        submission = InvitedToProposalFactory(lead=user)

        reviewers = ReviewerFactory.create_batch(4)

        AssignedReviewersFactory(submission=submission, reviewer=reviewers[0])
        AssignedReviewersFactory(submission=submission, 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 - Select Review
        # 2 - Cascase
        # 1 - Fetch data
        # 1 - Cache existing
        # 1 - auth group
        # 1 - Add new
        with self.assertNumQueries(8):
            form.save()
Beispiel #2
0
    def test_lead_can_remove_some_reviewers_for_proposal(self):
        submission = InvitedToProposalFactory(lead=self.user,
                                              reviewers=self.reviewers)
        self.assertCountEqual(submission.reviewers.all(), self.reviewers)

        self.post_form(submission, reviewers=self.reviewers[0:2])

        self.assertCountEqual(submission.reviewers.all(), self.reviewers[0:2])
Beispiel #3
0
    def test_previous_and_next_appears_on_page(self):
        proposal = InvitedToProposalFactory()
        response = self.get_page(proposal)
        self.assertContains(response,
                            self.url(proposal.previous, absolute=False))

        response = self.get_page(proposal.previous)
        self.assertContains(response, self.url(proposal, absolute=False))
Beispiel #4
0
 def test_can_progress_different_states(self):
     submission = ApplicationSubmissionFactory()
     other_submission = InvitedToProposalFactory()
     action = 'open-review'
     self.post_page(data=self.data(action, [submission, other_submission]))
     submission = self.refresh(submission)
     other_submission = self.refresh(other_submission)
     self.assertEqual(submission.status, 'internal_review')
     self.assertEqual(other_submission.status, 'proposal_internal_review')
Beispiel #5
0
    def test_can_remove_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.assertCountEqual(submission.reviewers.all(), [reviewer])
Beispiel #6
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()
Beispiel #7
0
    def test_queries_init_and_render(self):
        user = StaffFactory()

        ReviewerRoleFactory.create_batch(3)

        StaffFactory.create_batch(3)
        ReviewerFactory.create_batch(3)

        submission = InvitedToProposalFactory(lead=user, workflow_stages=2)

        # Reviewers
        # Partners
        # Meta categories
        # Assigned Reviewers
        # Roles
        with self.assertNumQueries(5):
            form = UpdateReviewersForm(user=user, instance=submission)

        # 3 x Staff - 1 per Role
        # 1 x reviewers queryset
        # 1 x submission reviewers
        with self.assertNumQueries(5):
            form.as_p()
Beispiel #8
0
 def test_gets_invite_if_invited_to_proposal(self):
     InvitedToProposalFactory(user=self.user, draft=True)
     response = self.get_page()
     self.assertContains(response, 'Start your ')
Beispiel #9
0
 def test_cant_edit_other_submission(self):
     submission = InvitedToProposalFactory(draft=True)
     response = self.get_page(submission, 'edit')
     self.assertEqual(response.status_code, 403)
Beispiel #10
0
 def test_cant_edit_submission_incorrect_state(self):
     submission = InvitedToProposalFactory(user=self.user)
     response = self.get_page(submission, 'edit')
     self.assertEqual(response.status_code, 403)
Beispiel #11
0
 def setUpTestData(cls):
     super().setUpTestData()
     cls.submission = ApplicationSubmissionFactory(user=cls.user)
     cls.draft_proposal_submission = InvitedToProposalFactory(user=cls.user,
                                                              draft=True)