Exemple #1
0
 def test_cancel(self):
     # Hiring date is today: cancellation should be possible.
     job_application = JobApplicationWithApprovalFactory(
         state=JobApplicationWorkflow.STATE_ACCEPTED)
     siae_user = job_application.to_siae.members.first()
     self.client.login(username=siae_user.email, password=DEFAULT_PASSWORD)
     url = reverse("apply:cancel",
                   kwargs={"job_application_id": job_application.pk})
     response = self.client.get(url)
     self.assertEqual(response.status_code, 302)
     job_application.refresh_from_db()
     self.assertTrue(job_application.state.is_cancelled)
Exemple #2
0
    def test_cancel_delete_linked_approval(self):
        job_application = JobApplicationWithApprovalFactory()
        self.assertEqual(job_application.job_seeker.approvals.count(), 1)
        self.assertEqual(
            JobApplication.objects.filter(
                approval=job_application.approval).count(), 1)

        cancellation_user = job_application.to_siae.active_members.first()
        job_application.cancel(user=cancellation_user)

        self.assertEqual(job_application.state,
                         JobApplicationWorkflow.STATE_CANCELLED)

        job_application.refresh_from_db()
        self.assertFalse(job_application.approval)
Exemple #3
0
 def test_cannot_cancel(self):
     cancellation_period_end = datetime.date.today() - relativedelta(
         days=JobApplication.CANCELLATION_DAYS_AFTER_HIRING_STARTED)
     job_application = JobApplicationWithApprovalFactory(
         state=JobApplicationWorkflow.STATE_ACCEPTED,
         hiring_start_at=(cancellation_period_end - relativedelta(days=1)),
     )
     siae_user = job_application.to_siae.members.first()
     self.client.login(username=siae_user.email, password=DEFAULT_PASSWORD)
     url = reverse("apply:cancel",
                   kwargs={"job_application_id": job_application.pk})
     response = self.client.get(url)
     self.assertEqual(response.status_code, 302)
     job_application.refresh_from_db()
     self.assertFalse(job_application.state.is_cancelled)
Exemple #4
0
    def test_cannot_cancel(self, *args, **kwargs):
        job_application = JobApplicationWithApprovalFactory(
            state=JobApplicationWorkflow.STATE_ACCEPTED,
            hiring_start_at=timezone.localdate() + relativedelta(days=1),
        )
        siae_user = job_application.to_siae.members.first()
        # Add a blocking employee record
        EmployeeRecordFactory(job_application=job_application, status=EmployeeRecord.Status.PROCESSED)

        self.client.login(username=siae_user.email, password=DEFAULT_PASSWORD)
        url = reverse("apply:cancel", kwargs={"job_application_id": job_application.pk})
        response = self.client.get(url)
        next_url = reverse("apply:details_for_siae", kwargs={"job_application_id": job_application.pk})
        self.assertRedirects(response, next_url)

        job_application.refresh_from_db()
        self.assertFalse(job_application.state.is_cancelled)
Exemple #5
0
    def test_cancel(self, *args, **kwargs):
        # Hiring date is today: cancellation should be possible.
        job_application = JobApplicationWithApprovalFactory(state=JobApplicationWorkflow.STATE_ACCEPTED)
        siae_user = job_application.to_siae.members.first()
        self.client.login(username=siae_user.email, password=DEFAULT_PASSWORD)
        url = reverse("apply:cancel", kwargs={"job_application_id": job_application.pk})
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)

        post_data = {
            "confirm": "true",
        }
        response = self.client.post(url, data=post_data)
        next_url = reverse("apply:details_for_siae", kwargs={"job_application_id": job_application.pk})
        self.assertRedirects(response, next_url)

        job_application.refresh_from_db()
        self.assertTrue(job_application.state.is_cancelled)
Exemple #6
0
    def test_cancel_do_not_delete_linked_approval(self):

        # The approval is linked to two accepted job applications
        job_application = JobApplicationWithApprovalFactory()
        approval = job_application.approval
        JobApplicationWithApprovalFactory(
            approval=approval, job_seeker=job_application.job_seeker)

        self.assertEqual(job_application.job_seeker.approvals.count(), 1)
        self.assertEqual(
            JobApplication.objects.filter(approval=approval).count(), 2)

        cancellation_user = job_application.to_siae.active_members.first()
        job_application.cancel(user=cancellation_user)

        self.assertEqual(job_application.state,
                         JobApplicationWorkflow.STATE_CANCELLED)

        job_application.refresh_from_db()
        self.assertTrue(job_application.approval)