Example #1
0
    def test_no_email(self):
        """
        Test that no e-mails are being send when the deadline has not passed or
        when there are applications
        """
        Position.objects.create(
            role=self.role,
            recruitment_start=date.today() - timedelta(days=10),
            recruitment_end=date.today(),
            term_from=date.today() + timedelta(days=4),
            term_to=date.today() + timedelta(days=365),
        )
        applied = Position.objects.create(
            role=self.role,
            recruitment_start=date.today() - timedelta(days=10),
            recruitment_end=date.today() - timedelta(days=1),
            term_from=date.today() + timedelta(days=4),
            term_to=date.today() + timedelta(days=365),
        )
        Application.objects.create(
            position=applied,
            applicant=self.admin,
            status='submitted',
        )

        send_extension_emails()

        self.assertEqual(len(mail.outbox), 0)
Example #2
0
    def test_send_email(self):
        """
        Test that an e-mail is being send when the deadline for an position
        passes without any applications.
        """
        pos = Position.objects.create(
            role=self.role,
            recruitment_start=date.today() - timedelta(days=10),
            recruitment_end=date.today() - timedelta(days=1),
            term_from=date.today() + timedelta(days=4),
            term_to=date.today() + timedelta(days=365),
        )
        send_extension_emails()

        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(mail.outbox[0].to, [self.role.election_email])
        self.assertIn(reverse('involvement_position_extend', args=[pos.pk]),
                      mail.outbox[0].body)