示例#1
0
文件: tests.py 项目: betagouv/itou
    def setUp(self, _mock):
        job_application = JobApplicationWithCompleteJobSeekerProfileFactory()
        employee_record = EmployeeRecord.from_job_application(job_application)
        employee_record.update_as_ready()

        self.employee_record = employee_record
        self.job_application = job_application
示例#2
0
文件: tests.py 项目: betagouv/itou
    def setUp(self, _mock):
        # Make job application cancellable
        hiring_date = date.today() + timedelta(days=7)

        self.job_application = JobApplicationWithCompleteJobSeekerProfileFactory(
            hiring_start_at=hiring_date)
        self.employee_record = EmployeeRecord.from_job_application(
            self.job_application)
        self.employee_record.update_as_ready()
示例#3
0
    def setUp(self, _mock):
        # We only care about status filtering: no coherence check on ASP return values
        job_application = JobApplicationWithCompleteJobSeekerProfileFactory()
        self.employee_record = EmployeeRecord.from_job_application(
            job_application)
        self.employee_record.update_as_ready()

        self.siae = job_application.to_siae
        self.siae_member = self.siae.members.first()
        self.user = job_application.job_seeker
示例#4
0
    def setUp(self):
        self.client = APIClient()

        # We only care about status filtering: no coherence check on ASP return values
        job_application = JobApplicationWithCompleteJobSeekerProfileFactory()
        self.employee_record_ready = EmployeeRecordWithProfileFactory(
            job_application=job_application,
            status=EmployeeRecord.Status.READY)

        self.user = self.employee_record_ready.job_application.to_siae.members.first(
        )
        self.unauthorized_user = SiaeStaffFactory()
示例#5
0
文件: tests.py 项目: betagouv/itou
    def test_prepare_failed_geoloc(self):
        """
        Test the failure of employee record preparation

        Mainly caused by:
        - geoloc issues (no API mock on this test)
        """
        # Complete profile, but geoloc API not reachable
        job_application = JobApplicationWithCompleteJobSeekerProfileFactory()

        with self.assertRaises(ValidationError):
            employee_record = EmployeeRecord.from_job_application(
                job_application)
            employee_record.update_as_ready()
示例#6
0
文件: tests.py 项目: betagouv/itou
    def test_prepare_successful(self, _mock):
        """
        Mainly format the job seeker address to Hexa format
        """
        job_application = JobApplicationWithCompleteJobSeekerProfileFactory()
        employee_record = EmployeeRecord.from_job_application(job_application)
        employee_record.update_as_ready()

        job_seeker = job_application.job_seeker
        self.assertIsNotNone(job_seeker.jobseeker_profile)

        # Surface check, this is not a job seeker profile test
        profile = job_seeker.jobseeker_profile
        self.assertIsNotNone(profile.hexa_commune)
示例#7
0
文件: tests.py 项目: betagouv/itou
    def test_creation_from_job_application(self):
        """
        Employee record objects are created from a job application giving them access to:
        - user / job seeker
        - job seeker profile
        - approval

        Creation is defensive, expect ValidationError if out of the lane
        """
        # Creation with invalid job application state
        with self.assertRaises(AssertionError):
            employee_record = EmployeeRecord.from_job_application(None)

        # Job application is not accepted
        with self.assertRaisesMessage(
                ValidationError,
                EmployeeRecord.ERROR_JOB_APPLICATION_MUST_BE_ACCEPTED):
            job_application = JobApplicationWithApprovalFactory(
                state=JobApplicationWorkflow.STATE_NEW)
            employee_record = EmployeeRecord.from_job_application(
                job_application)

        # Job application has no approval
        with self.assertRaisesMessage(
                ValidationError,
                EmployeeRecord.ERROR_JOB_APPLICATION_WITHOUT_APPROVAL):
            job_application = JobApplicationWithoutApprovalFactory()
            employee_record = EmployeeRecord.from_job_application(
                job_application)

        # Job application is duplicated (already existing with same approval and SIAE)
        job_application = JobApplicationWithCompleteJobSeekerProfileFactory()

        # Must be ok
        EmployeeRecord.from_job_application(job_application).save()

        with self.assertRaisesMessage(
                ValidationError,
                EmployeeRecord.ERROR_EMPLOYEE_RECORD_IS_DUPLICATE):
            # Must not
            employee_record = EmployeeRecord.from_job_application(
                job_application)

        # Job seeker has no existing profile (must be filled before creation)
        with self.assertRaisesMessage(
                ValidationError,
                EmployeeRecord.ERROR_JOB_SEEKER_HAS_NO_PROFILE):
            job_application = JobApplicationWithApprovalNotCancellableFactory()
            employee_record = EmployeeRecord.from_job_application(
                job_application)

        # Job seeker has an incomplete profile
        with self.assertRaises(ValidationError):
            # Message checked in profile tests
            job_application = JobApplicationWithJobSeekerProfileFactory()
            employee_record = EmployeeRecord.from_job_application(
                job_application)

        # Standard / normal case
        job_application = JobApplicationWithCompleteJobSeekerProfileFactory()
        employee_record = EmployeeRecord.from_job_application(job_application)
        self.assertIsNotNone(employee_record)
示例#8
0
    def test_fetch_employee_record_list(self, _mock):
        """
        Fetch list of employee records with and without `status` query param
        """
        # Using session auth (same as token but less steps)
        self.client.login(username=self.siae_member.username,
                          password=DEFAULT_PASSWORD)

        # Get list without filtering by status (PROCESSED)
        # note: there is no way to create a processed employee record
        # (and this is perfectly normal)
        self.employee_record.update_as_sent("RIAE_FS_20210410130000.json", 1)
        process_code, process_message = "0000", "La ligne de la fiche salarié a été enregistrée avec succès."

        # There should be no result at this point
        response = self.client.get(ENDPOINT_URL, format="json")

        self.assertEqual(response.status_code, 200)

        result = response.json()

        self.assertEqual(len(result.get("results")), 0)

        self.employee_record.update_as_accepted(process_code, process_message,
                                                "{}")
        response = self.client.get(ENDPOINT_URL, format="json")

        self.assertEqual(response.status_code, 200)

        result = response.json()

        self.assertEqual(len(result.get("results")), 1)
        self.assertContains(response, self.siae.siret)

        # status = SENT
        job_application = JobApplicationWithCompleteJobSeekerProfileFactory(
            to_siae=self.siae)
        employee_record_sent = EmployeeRecord.from_job_application(
            job_application=job_application)
        employee_record_sent.update_as_ready()

        # There should be no result at this point
        response = self.client.get(ENDPOINT_URL + "?status=SENT",
                                   format="json")

        self.assertEqual(response.status_code, 200)

        result = response.json()

        self.assertEqual(len(result.get("results")), 0)

        employee_record_sent.update_as_sent("RIAE_FS_20210410130001.json", 1)
        response = self.client.get(ENDPOINT_URL + "?status=SENT",
                                   format="json")

        self.assertEqual(response.status_code, 200)

        result = response.json()

        self.assertEqual(len(result.get("results")), 1)
        self.assertContains(response, self.siae.siret)

        # status = REJECTED
        job_application = JobApplicationWithCompleteJobSeekerProfileFactory(
            to_siae=self.siae)
        employee_record_rejected = EmployeeRecord.from_job_application(
            job_application=job_application)
        employee_record_rejected.update_as_ready()
        employee_record_rejected.update_as_sent("RIAE_FS_20210410130002.json",
                                                1)

        # There should be no result at this point
        response = self.client.get(ENDPOINT_URL + "?status=REJECTED",
                                   format="json")
        self.assertEqual(response.status_code, 200)

        result = response.json()

        self.assertEqual(len(result.get("results")), 0)

        err_code, err_message = "12", "JSON Invalide"
        employee_record_rejected.update_as_rejected(err_code, err_message)

        # Status case is not important
        response = self.client.get(ENDPOINT_URL + "?status=rEjEcTeD",
                                   format="json")
        self.assertEqual(response.status_code, 200)

        result = response.json()

        self.assertEqual(len(result.get("results")), 1)
        self.assertContains(response, self.siae.siret)