Пример #1
0
 def get_visitors_from_past_round(self, scenario):
     return (
         ("not logged in", None),
         ("no comrade", factories.UserFactory()),
         ("only comrade", factories.ComradeFactory().account),
         ("organizer", factories.ComradeFactory(account__is_staff=True).account),
         ("applicant", scenario.applicant1.applicant.account),
         ("mentor", scenario.mentor.account),
         ("coordinator", scenario.coordinator.account),
         ("reviewer", scenario.reviewer.account),
     )
 def get_visitors(self, scenario):
     return (
         ("only comrade", factories.ComradeFactory().account),
         ("applicant", scenario.applicant1.applicant.account),
         ("mentor", scenario.mentor.account),
         ("coordinator", scenario.coordinator.account),
     )
    def test_staff_and_logged_in(self):
        """
        This tests that informal chat contracts are visible to staff who is logged in
        """

        staff = factories.ComradeFactory(account__is_staff=True)

        self.client.force_login(staff.account)
        self.assert_permission_approved_on_informal_chat_contacts()
    def test_sponsor_info_visible(self):
        """
        This tests that sponsor information is visible to staff.
         - Create a community with one sponsor, who is approved to participate in the current round
         - Create a second community with two sponsors, who is approved to participate
         - Check that the sponsor page is visible
        """
        current_round = factories.RoundPageFactory(start_from='pingnew')

        # Create a community with one sponsor, who is approved to participate in the current round
        sponsorship_a = factories.SponsorshipFactory(
            participation__participating_round=current_round,
            participation__approval_status=models.ApprovalStatus.APPROVED,
            name="Sponsor A",
            amount=13000,
            funding_secured=True,
        )

        # Create a second community with one sponsor, who is approved to participate
        sponsorship_b = factories.SponsorshipFactory(
            participation__participating_round=current_round,
            participation__approval_status=models.ApprovalStatus.APPROVED,
            name="Sponsor B",
            amount=6500,
            funding_secured=True,
        )

        # Add a second sponsor to the second community
        sponsorship_c = factories.SponsorshipFactory(
            participation=sponsorship_b.participation,
            name="Sponsor C",
            amount=19500,
            funding_secured=True,
        )

        organizer = factories.ComradeFactory()
        organizer.account.is_staff = True
        organizer.account.save()

        self.client.logout()
        self.client.force_login(organizer.account)

        response = self.client.get(
            reverse('sponsor-info', kwargs={'round_slug': current_round.slug}))
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, '<td>Sponsor A</td>', html=True)
        self.assertContains(response, '<td>Sponsor B</td>', html=True)
        self.assertContains(response, '<td>Sponsor C</td>', html=True)
        self.assertContains(response,
                            '<h3>{}</h3>'.format(
                                sponsorship_a.participation.community.name),
                            html=True)
        self.assertContains(response,
                            '<h3>{}</h3>'.format(
                                sponsorship_b.participation.community.name),
                            html=True)
 def get_visitors(self, scenario):
     return (
         ("not logged in", None),
         ("no comrade", factories.UserFactory()),
         ("only comrade", factories.ComradeFactory().account),
         ("applicant", scenario.applicant1.applicant.account),
         ("mentor", scenario.mentor.account),
         ("coordinator", scenario.coordinator.account),
         ("reviewer", scenario.reviewer.account),
     )
Пример #6
0
    def test_initial_application_form_closed_after_period(self):
        """
        This tests that the initial application form is closed after the initial application deadline
        """
        current_round = factories.RoundPageFactory(start_from='initial_applications_close')
        applicant = factories.ComradeFactory()
        self.client.force_login(applicant.account)

        response = self.client.get(reverse('eligibility'))
        self.assertEqual(response.status_code, 403)
Пример #7
0
    def test_initial_application_form_open_during_period(self):
        """
        This tests that the initial application form is open during the initial application period
        """
        current_round = factories.RoundPageFactory(start_from='initial_applications_open')
        applicant = factories.ComradeFactory()
        self.client.force_login(applicant.account)

        response = self.client.get(reverse('eligibility'))
        self.assertEqual(response.status_code, 200)
    def test_new_coordinator_signs_up_community_to_participate(self):
        """
        This tests submitting a new community to participate in this round.
         - Create a new RoundPage for the upcoming round where the CFP is open
         - Check that the community CFP page shows community participation sign up is open
        """
        current_round = factories.RoundPageFactory(start_from='pingnew')

        self.client.logout()
        self.check_community_signup_marked_open()

        new_community_signup_path = reverse('community-add')
        response = self.client.get(new_community_signup_path)
        self.assertRedirects(
            response,
            settings.LOGIN_URL + '?next={}'.format(new_community_signup_path))

        # Assume Comrade account sign up works - TODO: test this separately
        coordinator = factories.ComradeFactory()
        self.client.force_login(coordinator.account)
        response = self.client.post(
            new_community_signup_path,
            {
                'name': 'Debian',
                'reason_for_participation':
                'We want more diversity in our community.',
                'mentorship_programs':
                'We have participated in Google Summer of Code since 2013.',
                'approved_license': 'on',
                'no_proprietary_software': 'on',
                'participating_orgs':
                'Debian is comprised of volunteers from around the world. Some corporations pay maintainers to participate.',
                'approved_advertising': 'on',
            },
            follow=True,
        )

        # Ensure the Community object and NewCommunity object was created
        community = Community.objects.get(name='Debian')
        newcommunity = NewCommunity.objects.get(community=community)
        coordinatorapproval = CoordinatorApproval.objects.get(
            coordinator=coordinator,
            community=community,
            approval_status=ApprovalStatus.APPROVED)

        new_community_participation_path = reverse('participation-action',
                                                   kwargs={
                                                       'action':
                                                       'submit',
                                                       'round_slug':
                                                       current_round.slug,
                                                       'community_slug':
                                                       community.slug,
                                                   })
        self.assertRedirects(response, new_community_participation_path)
    def test_inactive_contact(self):
        """
        This tests that inactive informal chat contracts are NOT visible to staff who is logged in
        """

        contact = models.InformalChatContact(
            active=False,
            name="Given Name Family Names",
            email="*****@*****.**",
        )
        contact.save()

        staff = factories.ComradeFactory(account__is_staff=True)
        self.client.force_login(staff.account)
        response = self.client.get(reverse('informal-chat-contacts'))
        self.assertNotContains(
            response,
            '<div class="card-header bg-light">{}</div>'.format(contact.name),
            html=True)
    def test_visible_to_organizers(self):
        """
        This tests that intern review page is visible to anyone with staff privileges (Outreachy organizers).
        """
        scenario = scenarios.InternSelectionScenario(
                applicant1__applicant__public_name="Applicant 1",
                applicant2__applicant__public_name="Applicant 2",
                )

        organizer = factories.ComradeFactory()
        organizer.account.is_staff = True
        organizer.account.save()

        self.client.logout()
        self.client.force_login(organizer.account)

        response = self.client.get(reverse('review-interns', kwargs={'round_slug': scenario.round.slug}))
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, '<td><a href="#intern-{}">Applicant 1</a></td>'.format(scenario.applicant1.applicant.account.pk), html=True)
        self.assertContains(response, '<td><a href="#intern-{}">Applicant 2</a></td>'.format(scenario.applicant2.applicant.account.pk), html=True)