def test_proposal_count(self):
        """Verify that proposal list contains count of proposals."""
        self._add_to_reviewers_group()
        # Setup the ProposalKinds for talks and tutorials.
        section = SectionFactory()
        talk_kind = ProposalKindFactory.create(section=section,
                                               name="Talk",
                                               slug="talk")
        tutorial_kind = ProposalKindFactory.create(section=section,
                                                   name="Tutorial",
                                                   slug="tutorial")
        # Create a random number of talks and tutorials.
        num_talks = randint(2, 10)
        num_tutorials = randint(2, 10)
        num_total_proposals = num_talks + num_tutorials
        ProposalFactory.create_batch(size=num_talks, kind=talk_kind)
        ProposalFactory.create_batch(size=num_tutorials, kind=tutorial_kind)

        response = self.client.get(
            reverse(self.reverse_view_name, args=self.reverse_view_args))
        self.assertContains(
            response,
            "<strong>{}</strong> proposals".format(num_total_proposals),
        )
        self.assertContains(response,
                            "<strong>{}</strong> talks".format(num_talks))
        self.assertContains(
            response, "<strong>{}</strong> tutorials".format(num_tutorials))
    def test_no_cancelled_proposals(self):
        """Verify that cancelled proposals do not appear in proposal list."""
        VALID_PROPOSAL_COUNT = 4
        INVALID_PROPOSAL_COUNT = 3

        # Create proposals.
        valid_proposals = ProposalFactory.create_batch(
            size=VALID_PROPOSAL_COUNT, cancelled=False)
        invalid_proposals = ProposalFactory.create_batch(
            size=INVALID_PROPOSAL_COUNT, cancelled=True)

        self._validate_proposals(valid_proposals, True)
        self._validate_proposals(invalid_proposals, False)
    def test_proposal_count(self):
        self._add_to_reviewers_group()

        num_proposals = randint(2, 10)
        ProposalFactory.create_batch(
            size=num_proposals, kind=self.proposal_kind
        )
        response = self.client.get(
            reverse(self.reverse_view_name, args=self.reverse_view_args)
        )
        self.assertContains(
            response,
            "<strong>{}</strong> proposals".format(num_proposals),
        )
    def test_correct_information(self):
        """Verify that shown proposals are correct."""
        self._add_to_reviewers_group()
        shown_proposals = ProposalFactory.create_batch(
            size=randint(5, 10), kind=self.proposal_kind
        )
        unshown_proposals = ProposalFactory.create_batch(size=randint(5, 10))

        response = self.client.get(
            reverse(self.reverse_view_name, args=self.reverse_view_args)
        )
        for proposal in shown_proposals:
            self.assertContains(response, proposal.title)
        for proposal in unshown_proposals:
            self.assertNotContains(response, proposal.title)
    def test_warning_about_unnotified_speakers(self):
        self._become_superuser()
        proposal = ProposalFactory()
        emailless_speaker = SpeakerFactory(user=None)
        # Add an additional **confirmed** speaker that
        # does not have an email address.
        proposal.additional_speakers.add(emailless_speaker)
        additional_speaker = AdditionalSpeaker.objects.get(
            speaker=emailless_speaker, proposalbase=proposal)
        additional_speaker.status = AdditionalSpeaker.SPEAKING_STATUS_ACCEPTED
        additional_speaker.save()

        post_data = {
            "body": self.faker.paragraph(),
            "from_address": self.faker.email(),
            "proposal_pk": proposal.pk,
            "send_notification": True,
            "subject": self.faker.sentence(),
        }
        response = self.client.post(reverse("review_multiedit"),
                                    post_data,
                                    follow=True)
        speaker_warning = ("Speaker {} does not have an email address "
                           "and has not been notified.".format(
                               emailless_speaker.name))
        self.assertContains(response, speaker_warning)
 def test_changing_proposal_status(self):
     self._become_superuser()
     # Create multiple proposals.
     proposals = ProposalFactory.create_batch(size=randint(3, 6))
     for result_status in ProposalResult.RESULT_STATUSES:
         # Use post data to change the first two proposals' statuses.
         post_data = {
             "proposal_pk": [proposals[0].pk, proposals[1].pk],
             "mark_status": result_status[0],
         }
         response = self.client.post(reverse("review_multiedit"), post_data)
         # Verify that we are redirected to the correct page
         # (a list of proposals with the same changed status).
         self.assertRedirects(
             response,
             reverse("review_proposal_result_list",
                     args=[result_status[0]]),
         )
         # Verify that the first two proposals' status has changed
         #  and all other proposals have remained the same.
         for proposal in Proposal.objects.all():
             if proposal.pk in post_data["proposal_pk"]:
                 self.assertEqual(proposal.review_result.status,
                                  result_status[0])
             else:
                 self.assertEqual(
                     proposal.review_result.status,
                     ProposalResult.RESULT_UNDECIDED,
                 )
 def test_all_proposals_are_included(self):
     proposals = ProposalFactory.create_batch(size=randint(2, 4))
     response = ExportProposalSubmittersView().get()
     for proposal in proposals:
         self.assertContains(response, proposal.speaker.name)
         self.assertContains(response, proposal.speaker.email)
         self.assertContains(response, proposal.title)
Esempio n. 8
0
 def _create_proposals(self):
     """Create proposals if needed to test a view."""
     try:
         # If we already have a proposal, this is a DetailView
         # and we shouldn't create more.
         return [self.proposal]
     except AttributeError:
         return ProposalFactory.create_batch(size=randint(2, 5))
 def test_additional_speakers_are_included(self):
     """Verify that we are picking up both types of speakers."""
     proposal = ProposalFactory()
     additional_speakers = SpeakerFactory.create_batch(size=randint(2, 4))
     proposal.additional_speakers.add(*additional_speakers)
     response = ExportProposalSubmittersView().get()
     for speaker in additional_speakers:
         self.assertContains(response, speaker.name)
         self.assertContains(response, speaker.email)
Esempio n. 10
0
    def test_no_cancelled_proposals(self):
        """Verify that cancelled proposals do not appear in proposal list."""
        VALID_PROPOSAL_COUNT = 4
        INVALID_PROPOSAL_COUNT = 3

        # Create proposals.
        valid_proposals = ProposalFactory.create_batch(
            size=VALID_PROPOSAL_COUNT, cancelled=False)
        invalid_proposals = ProposalFactory.create_batch(
            size=INVALID_PROPOSAL_COUNT, cancelled=True)

        # User must be in the reviewers group in order to access
        # this view.
        self._add_to_reviewers_group()
        response = self.client.get(
            reverse(self.reverse_view_name, args=self.reverse_view_args))
        for valid_proposal in valid_proposals:
            self.assertContains(response, valid_proposal.title)
        for invalid_proposal in invalid_proposals:
            self.assertNotContains(response, invalid_proposal.title)
Esempio n. 11
0
 def test_all_proposals_are_included(self):
     proposals = ProposalFactory.create_batch(size=randint(2, 4))
     response = ExportProposalsView().get()
     for proposal in proposals:
         self.assertContains(response, proposal.number)
         self.assertContains(response, proposal.title)
         self.assertContains(response, proposal.speaker.name)
         self.assertContains(response, proposal.kind.name)
         self.assertContains(response,
                             proposal.get_audience_level_display())
         self.assertContains(response, proposal.date_created)
         self.assertContains(response, proposal.date_last_modified)
    def test_sending_notifications(self):
        self._become_superuser()
        notified_proposal = ProposalFactory()
        # Create additional proposals.
        ProposalFactory.create_batch(size=2)

        from_address = self.faker.email()
        subject = self.faker.sentence()
        body = self.faker.paragraph()

        post_data = {
            "body": body,
            "from_address": from_address,
            "proposal_pk": notified_proposal.pk,
            "send_notification": True,
            "subject": subject,
        }
        response = self.client.post(reverse("review_multiedit"),
                                    post_data,
                                    follow=True)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(len(mail.outbox), 1)
    def test_creating_presentations(self):
        self._become_superuser()
        proposals = ProposalFactory.create_batch(size=3)
        # Create a single presentation and validate the response.
        post_data = {
            "proposal_pk": [proposals[0].pk],
            "create_presentations": "show me a presentation",
        }
        response = self.client.post(reverse("review_multiedit"),
                                    post_data,
                                    follow=True)
        self.assertRedirects(
            response,
            reverse(
                "review_proposal_result_list",
                args=[ProposalResult.RESULT_ACCEPTED],
            ),
        )
        self.assertContains(response, "1 presentation created")

        # Verify that POSTing the same data does not create an
        # additional presentation.
        response = self.client.post(reverse("review_multiedit"),
                                    post_data,
                                    follow=True)
        self.assertContains(
            response, "All selected proposals already had presentations")

        # Verify that the other two proposals do not have presentations.
        for proposal in Proposal.objects.all():
            if proposal.pk == post_data["proposal_pk"][0]:
                # Verify that the first proposal has a presentation
                # and that their metadata is the same.
                self.assertEqual(proposal.title, proposal.presentation.title)
            else:
                with self.assertRaises(ObjectDoesNotExist):
                    proposal.presentation

        # Verify that creating multiple presentations works.
        post_data["proposal_pk"] = [proposals[1].pk, proposals[2].pk]
        response = self.client.post(reverse("review_multiedit"),
                                    post_data,
                                    follow=True)
        self.assertContains(response, "2 presentations created")
        # All proposals should now have presentations.
        for proposal in Proposal.objects.all():
            self.assertEqual(proposal.title, proposal.presentation.title)
Esempio n. 14
0
 def setUp(self):
     # Create base conference infrastructure that has to exist in
     # order to create a Proposal.
     self.conference = ConferenceFactory()
     self.section = SectionFactory()
     self.proposal = ProposalFactory()
class ProposalDetailViewAccessTestCase(ReviewingTestCase, AccountsTestCase):
    reverse_view_name = "review_proposal_detail"

    def setUp(self):
        super(ProposalDetailViewAccessTestCase, self).setUp()
        self.proposal = ProposalFactory()
        self.reverse_view_args = [self.proposal.pk]

    def test_blind_reviewing_types_as_author(self):
        """Verify whether BLIND_AUTHORS setting works properly."""
        self._i_am_the_speaker_now()

        # Create a feedback comment, otherwise this test will pass
        # when it should fail.
        ProposalFeedbackFactory(proposal=self.proposal,
                                author=self.reviewer.user)

        with override_config(BLIND_AUTHORS=True):
            response = self.client.get(
                reverse(self.reverse_view_name, args=self.reverse_view_args))
            self.assertNotContains(response, self.reviewer.name)
            self.assertNotContains(response, self.reviewer.user.username)
            self.assertNotContains(response, self.reviewer.email)

    def test_blind_reviewing_means_no_notes_section(self):
        """
        Verify that the Notes section does not appear if BLIND_REVIEWERS is on.
        """
        self._add_to_reviewers_group()
        # Set this proposal's notes field to something memorable.
        self.proposal.additional_notes = "xyzzy"
        self.proposal.save()

        with override_config(BLIND_REVIEWERS=True):
            response = self.client.get(
                reverse(self.reverse_view_name, args=self.reverse_view_args))
            self.assertNotContains(response, "Notes")
            self.assertNotContains(response, self.proposal.additional_notes)

    def test_primary_speaker_cannot_view_votes_tab(self):
        """Verify that proposal speakers cannot view their proposal's votes."""
        self._i_am_the_speaker_now()
        response = self.client.get(
            reverse(self.reverse_view_name, args=self.reverse_view_args))
        self.assertNotContains(response, "proposal-reviews")

    def test_additional_speakers_cannot_view_votes_tab(self):
        """
        Verify that additional speakers cannot view their proposal's votes.
        """
        self._i_am_also_a_speaker_now()
        response = self.client.get(
            reverse(self.reverse_view_name, args=self.reverse_view_args))
        self.assertNotContains(response, "proposal-reviews")

    def test_reviewer_can_view_votes_tab(self):
        """Verify that a reviewer can view a proposal's votes."""
        self._add_to_reviewers_group()
        response = self.client.get(
            reverse(self.reverse_view_name, args=self.reverse_view_args))
        self.assertContains(response, "proposal-reviews")

    def test_primary_speaker_cannot_view_result_buttons(self):
        """Verify that proposal speakers cannot view result buttons section."""
        self._i_am_the_speaker_now()
        response = self.client.get(
            reverse(self.reverse_view_name, args=self.reverse_view_args))
        self.assertNotContains(response, "div-proposal-result-buttons")

    def test_additional_speakers_cannot_view_result_buttons(self):
        """Verify that additional speakers cannot view result buttons."""
        self._i_am_also_a_speaker_now()
        response = self.client.get(
            reverse(self.reverse_view_name, args=self.reverse_view_args))
        self.assertNotContains(response, "div-proposal-result-buttons")

    def test_reviewer_cannot_view_result_buttons(self):
        """
        Verify that proposal reviewers cannot view result buttons section.
        """
        self._add_to_reviewers_group()
        response = self.client.get(
            reverse(self.reverse_view_name, args=self.reverse_view_args))
        self.assertNotContains(response, "div-proposal-result-buttons")

    def test_superuser_can_view_result_buttons(self):
        """Verify that superusers can view result buttons section."""
        self._become_superuser()
        response = self.client.get(
            reverse(self.reverse_view_name, args=self.reverse_view_args))
        self.assertContains(response, "div-proposal-result-buttons")

    def test_reviewer_cannot_view_other_reviewers_names(self):
        """Verify that a reviewer cannot view other reviewers' names."""
        other_vote = ProposalVoteFactory(proposal=self.proposal)
        other_feedback = ProposalFeedbackFactory.create(proposal=self.proposal)

        self._add_to_reviewers_group()
        with override_config(BLIND_REVIEWERS=True):
            response = self.client.get(
                reverse(self.reverse_view_name, args=self.reverse_view_args))
            self.assertContains(response, "Anonymous")

            self.assertNotContains(response, other_vote.voter.username)
            self.assertNotContains(response, other_vote.voter.email)

            self.assertNotContains(response, other_feedback.author.username)
            self.assertNotContains(response, other_feedback.author.email)

    def _test_button_text(self, good_text, bad_text):
        self._add_to_reviewers_group()
        response = self._get_response()
        self.assertContains(response, good_text)
        self.assertNotContains(response, bad_text)
        return response

    def test_submit_button_with_no_preexisting_vote(self):
        """Test that 'Submit Review' appears by default."""
        self._test_button_text("Submit Review", "Update Review")

    def test_submit_button_with_other_votes(self):
        """Test that other votes don't let 'Update Review' appear."""
        ProposalVoteFactory.create_batch(size=5, proposal=self.proposal)
        self._test_button_text("Submit Review", "Update Review")

    def test_update_button_with_preexisting_vote(self):
        """Test that 'Update Review' appears if reviewer has voted."""
        vote = ProposalVoteFactory.create(proposal=self.proposal,
                                          voter=self.user)
        response = self._test_button_text("Update Review", "Submit Review")
        # Vote comment should appear twice - once in the list of votes
        # and once in the form field.
        self.assertContains(response, vote.comment, 2)
 def setUp(self):
     super(ProposalDetailViewAccessTestCase, self).setUp()
     self.proposal = ProposalFactory()
     self.reverse_view_args = [self.proposal.pk]
Esempio n. 17
0
    def setUp(self):
        super().setUp()

        self.faker = Faker()
        self.proposal = ProposalFactory()
        self.reverse_view_args = [self.proposal.pk]
Esempio n. 18
0
 def test_include_cancelled_proposal_status(self):
     proposal = ProposalFactory.create(cancelled=True)
     response = ExportProposalsView().get()
     self.assertContains(response, proposal.title)
     self.assertContains(response, "Cancelled")