-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Candidature : vérifier la cohérence du NIR avec la date de naissance et la civilité #4746
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ | |
from itou.job_applications.models import JobApplication | ||
from itou.siae_evaluations.models import Sanctions | ||
from itou.users.enums import LackOfNIRReason, LackOfPoleEmploiId | ||
from itou.users.models import User | ||
from itou.users.models import JobSeekerProfile, User | ||
from itou.utils.mocks.address_format import mock_get_first_geocoding_data, mock_get_geocoding_data_by_ban_api_resolved | ||
from itou.utils.models import InclusiveDateRange | ||
from itou.utils.session import SessionNamespace | ||
|
@@ -346,7 +346,7 @@ def test_apply_as_jobseeker(self): | |
response = self.client.get(next_url) | ||
assert response.status_code == 200 | ||
|
||
nir = "141068078200557" | ||
nir = "178122978200508" | ||
post_data = {"nir": nir, "confirm": 1} | ||
|
||
response = self.client.post(next_url, data=post_data) | ||
|
@@ -1399,6 +1399,9 @@ def test_apply_as_prescriber(self, _mock): | |
jobseeker_profile__with_hexa_address=True, | ||
jobseeker_profile__with_education_level=True, | ||
with_ban_geoloc_address=True, | ||
jobseeker_profile__nir="178122978200508", | ||
jobseeker_profile__birthdate=datetime.date(1978, 12, 20), | ||
title="M", | ||
) | ||
|
||
# Entry point. | ||
|
@@ -1473,6 +1476,36 @@ def test_apply_as_prescriber(self, _mock): | |
geispolsheim = create_city_geispolsheim() | ||
birthdate = dummy_job_seeker.jobseeker_profile.birthdate | ||
|
||
# Let's check for consistency between the NIR, the birthdate and the title. | ||
# ---------------------------------------------------------------------- | ||
|
||
post_data = { | ||
"title": "MME", # inconsistent title | ||
"first_name": dummy_job_seeker.first_name, | ||
"last_name": dummy_job_seeker.last_name, | ||
"birthdate": birthdate, | ||
"lack_of_nir": False, | ||
"lack_of_nir_reason": "", | ||
} | ||
response = self.client.post(next_url, data=post_data) | ||
assert response.status_code == 200 | ||
self.assertContains(response, JobSeekerProfile.ERROR_JOBSEEKER_INCONSISTENT_NIR_TITLE % "") | ||
|
||
post_data = { | ||
"title": "M", | ||
"first_name": dummy_job_seeker.first_name, | ||
"last_name": dummy_job_seeker.last_name, | ||
"birthdate": datetime.date(1978, 11, 20), # inconsistent birthdate | ||
"lack_of_nir": False, | ||
"lack_of_nir_reason": "", | ||
} | ||
response = self.client.post(next_url, data=post_data) | ||
assert response.status_code == 200 | ||
self.assertContains(response, JobSeekerProfile.ERROR_JOBSEEKER_INCONSISTENT_NIR_BIRTHDATE % "") | ||
|
||
# Resume to valid data and proceed with "normal" flow. | ||
# ---------------------------------------------------------------------- | ||
|
||
post_data = { | ||
"title": dummy_job_seeker.title, | ||
"first_name": dummy_job_seeker.first_name, | ||
|
@@ -1674,6 +1707,41 @@ def test_apply_as_prescriber_on_job_seeker_tunnel(self): | |
response, reverse("apply:start", kwargs={"company_pk": company.pk}), fetch_redirect_response=False | ||
) | ||
|
||
def test_check_info_as_prescriber_for_job_seeker_with_incomplete_info(self): | ||
company = CompanyFactory(with_membership=True, with_jobs=True, romes=("N1101", "N1105")) | ||
user = PrescriberFactory() | ||
self.client.force_login(user) | ||
|
||
dummy_job_seeker = JobSeekerFactory( | ||
jobseeker_profile__with_hexa_address=True, | ||
jobseeker_profile__with_education_level=True, | ||
with_ban_geoloc_address=True, | ||
jobseeker_profile__nir="178122978200508", | ||
jobseeker_profile__birthdate=None, | ||
title="M", | ||
) | ||
|
||
next_url = reverse( | ||
"apply:step_check_job_seeker_info", | ||
kwargs={"company_pk": company.pk, "job_seeker_public_id": dummy_job_seeker.public_id}, | ||
) | ||
|
||
post_data = { | ||
"phone": "", | ||
"birthdate": datetime.date(1978, 11, 20), # inconsistent birthdate | ||
"pole_emploi_id": "3454471C", | ||
} | ||
response = self.client.post(next_url, data=post_data) | ||
assert response.status_code == 200 | ||
self.assertContains( | ||
response, | ||
( | ||
"Une erreur a été détectée. " | ||
"La date de naissance renseignée ne correspond pas au numéro de sécurité " | ||
"sociale 178122978200508 enregistré." | ||
Comment on lines
+1739
to
+1741
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. J'ai écrit le message d'erreur en dur pour être sûr le NIR soit bien inclus. |
||
), | ||
) | ||
|
||
|
||
@pytest.mark.ignore_unknown_variable_template_error("job_seeker") | ||
class ApplyAsPrescriberNirExceptionsTest(TestCase): | ||
|
@@ -1943,6 +2011,36 @@ def _test_apply_as_company(self, user, company, dummy_job_seeker, _mock): | |
geispolsheim = create_city_geispolsheim() | ||
birthdate = dummy_job_seeker.jobseeker_profile.birthdate | ||
|
||
# Let's check for consistency between the NIR, the birthdate and the title. | ||
# ---------------------------------------------------------------------- | ||
|
||
post_data = { | ||
"title": "M", # inconsistent title | ||
"first_name": dummy_job_seeker.first_name, | ||
"last_name": dummy_job_seeker.last_name, | ||
"birthdate": birthdate, | ||
"lack_of_nir": False, | ||
"lack_of_nir_reason": "", | ||
} | ||
response = self.client.post(next_url, data=post_data) | ||
assert response.status_code == 200 | ||
self.assertContains(response, JobSeekerProfile.ERROR_JOBSEEKER_INCONSISTENT_NIR_TITLE % "") | ||
|
||
post_data = { | ||
"title": "MME", | ||
"first_name": dummy_job_seeker.first_name, | ||
"last_name": dummy_job_seeker.last_name, | ||
"birthdate": datetime.date(1978, 11, 20), # inconsistent birthdate | ||
"lack_of_nir": False, | ||
"lack_of_nir_reason": "", | ||
} | ||
response = self.client.post(next_url, data=post_data) | ||
assert response.status_code == 200 | ||
self.assertContains(response, JobSeekerProfile.ERROR_JOBSEEKER_INCONSISTENT_NIR_BIRTHDATE % "") | ||
|
||
# Resume to valid data and proceed with "normal" flow. | ||
# ---------------------------------------------------------------------- | ||
|
||
post_data = { | ||
"title": dummy_job_seeker.title, | ||
"first_name": dummy_job_seeker.first_name, | ||
|
@@ -2127,6 +2225,9 @@ def test_apply_as_employer(self): | |
jobseeker_profile__with_hexa_address=True, | ||
jobseeker_profile__with_education_level=True, | ||
with_ban_geoloc_address=True, | ||
jobseeker_profile__nir="278122978200555", | ||
jobseeker_profile__birthdate=datetime.date(1978, 12, 20), | ||
title="MME", | ||
) | ||
self._test_apply_as_company(employer, company, dummy_job_seeker) | ||
|
||
|
@@ -2142,9 +2243,47 @@ def test_apply_as_another_employer(self): | |
jobseeker_profile__with_hexa_address=True, | ||
jobseeker_profile__with_education_level=True, | ||
with_ban_geoloc_address=True, | ||
jobseeker_profile__nir="278122978200555", | ||
jobseeker_profile__birthdate=datetime.date(1978, 12, 20), | ||
title="MME", | ||
) | ||
self._test_apply_as_company(employer, company, dummy_job_seeker) | ||
|
||
def test_check_info_as_employer_for_job_seeker_with_incomplete_info(self): | ||
company = CompanyFactory(with_membership=True, with_jobs=True, romes=("N1101", "N1105")) | ||
employer = EmployerFactory(with_company=True) | ||
self.client.force_login(employer) | ||
|
||
dummy_job_seeker = JobSeekerFactory( | ||
jobseeker_profile__with_hexa_address=True, | ||
jobseeker_profile__with_education_level=True, | ||
with_ban_geoloc_address=True, | ||
jobseeker_profile__nir="278122978200555", | ||
jobseeker_profile__birthdate=None, | ||
title="MME", | ||
) | ||
|
||
next_url = reverse( | ||
"apply:step_check_job_seeker_info", | ||
kwargs={"company_pk": company.pk, "job_seeker_public_id": dummy_job_seeker.public_id}, | ||
) | ||
|
||
post_data = { | ||
"phone": "", | ||
"birthdate": datetime.date(1978, 11, 20), # inconsistent birthdate | ||
"pole_emploi_id": "3454471C", | ||
} | ||
response = self.client.post(next_url, data=post_data) | ||
assert response.status_code == 200 | ||
self.assertContains( | ||
response, | ||
( | ||
"Une erreur a été détectée. " | ||
"La date de naissance renseignée ne correspond pas au numéro de sécurité " | ||
"sociale 278122978200555 enregistré." | ||
), | ||
) | ||
|
||
@pytest.mark.ignore_unknown_variable_template_error("job_seeker") | ||
def test_cannot_create_job_seeker_with_pole_emploi_email(self): | ||
# It's unlikely to happen | ||
|
@@ -2235,6 +2374,9 @@ def test_hire_as_company(self, _mock): | |
jobseeker_profile__with_hexa_address=True, | ||
jobseeker_profile__with_education_level=True, | ||
with_ban_geoloc_address=True, | ||
jobseeker_profile__nir="178122978200508", | ||
jobseeker_profile__birthdate=datetime.date(1978, 12, 20), | ||
title="M", | ||
) | ||
|
||
geispolsheim = create_city_geispolsheim() | ||
|
@@ -2298,6 +2440,36 @@ def test_hire_as_company(self, _mock): | |
|
||
birthdate = dummy_job_seeker.jobseeker_profile.birthdate | ||
|
||
# Let's check for consistency between the NIR, the birthdate and the title. | ||
# ---------------------------------------------------------------------- | ||
|
||
post_data = { | ||
"title": "MME", # inconsistent title | ||
"first_name": dummy_job_seeker.first_name, | ||
"last_name": dummy_job_seeker.last_name, | ||
"birthdate": birthdate, | ||
"lack_of_nir": False, | ||
"lack_of_nir_reason": "", | ||
} | ||
response = self.client.post(next_url, data=post_data) | ||
assert response.status_code == 200 | ||
self.assertContains(response, JobSeekerProfile.ERROR_JOBSEEKER_INCONSISTENT_NIR_TITLE % "") | ||
|
||
post_data = { | ||
"title": "M", | ||
"first_name": dummy_job_seeker.first_name, | ||
"last_name": dummy_job_seeker.last_name, | ||
"birthdate": datetime.date(1978, 11, 20), # inconsistent birthdate | ||
"lack_of_nir": False, | ||
"lack_of_nir_reason": "", | ||
} | ||
response = self.client.post(next_url, data=post_data) | ||
assert response.status_code == 200 | ||
self.assertContains(response, JobSeekerProfile.ERROR_JOBSEEKER_INCONSISTENT_NIR_BIRTHDATE % "") | ||
|
||
# Resume to valid data and proceed with "normal" flow. | ||
# ---------------------------------------------------------------------- | ||
|
||
post_data = { | ||
"title": dummy_job_seeker.title, | ||
"first_name": dummy_job_seeker.first_name, | ||
|
@@ -2990,7 +3162,12 @@ class UpdateJobSeekerBaseTestCase(TestCase): | |
@classmethod | ||
def setUpTestData(cls): | ||
cls.company = CompanyFactory(subject_to_eligibility=True, with_membership=True) | ||
cls.job_seeker = JobSeekerFactory(with_ban_geoloc_address=True) | ||
cls.job_seeker = JobSeekerFactory( | ||
with_ban_geoloc_address=True, | ||
jobseeker_profile__nir="178122978200508", | ||
jobseeker_profile__birthdate=datetime.date(1978, 12, 20), | ||
title="M", | ||
) | ||
cls.step_1_url = reverse( | ||
cls.STEP_1_VIEW_NAME, | ||
kwargs={"company_pk": cls.company.pk, "job_seeker_public_id": cls.job_seeker.public_id}, | ||
|
@@ -3037,6 +3214,38 @@ def _check_everything_allowed(self, user, extra_post_data_1=None): | |
self.assertContains(response, self.job_seeker.first_name) | ||
self.assertNotContains(response, self.INFO_MODIFIABLE_PAR_CANDIDAT_UNIQUEMENT) | ||
|
||
# Let's check for consistency between the NIR, the birthdate and the title. | ||
# (but do not check when there is no NIR) | ||
# ---------------------------------------------------------------------- | ||
|
||
if self.job_seeker.jobseeker_profile.nir != "": | ||
post_data = { | ||
"title": "MME", # Inconsistent title | ||
"first_name": self.job_seeker.first_name, | ||
"last_name": self.job_seeker.last_name, | ||
"birthdate": self.job_seeker.jobseeker_profile.birthdate, | ||
"lack_of_nir": False, | ||
"lack_of_nir_reason": "", | ||
} | ||
response = self.client.post(self.step_1_url, data=post_data) | ||
assert response.status_code == 200 | ||
self.assertContains(response, JobSeekerProfile.ERROR_JOBSEEKER_INCONSISTENT_NIR_TITLE % "") | ||
|
||
post_data = { | ||
"title": "M", | ||
"first_name": self.job_seeker.first_name, | ||
"last_name": self.job_seeker.last_name, | ||
"birthdate": datetime.date(1978, 11, 20), # Inconsistent birthdate | ||
"lack_of_nir": False, | ||
"lack_of_nir_reason": "", | ||
} | ||
response = self.client.post(self.step_1_url, data=post_data) | ||
assert response.status_code == 200 | ||
self.assertContains(response, JobSeekerProfile.ERROR_JOBSEEKER_INCONSISTENT_NIR_BIRTHDATE % "") | ||
|
||
# Resume to valid data and proceed with "normal" flow. | ||
# ---------------------------------------------------------------------- | ||
|
||
NEW_FIRST_NAME = "New first name" | ||
PROCESS_TITLE = "Modification du compte candidat" | ||
|
||
|
@@ -3627,6 +3836,8 @@ def test_detect_existing_job_seeker(client): | |
|
||
job_seeker = JobSeekerFactory( | ||
jobseeker_profile__nir="", | ||
jobseeker_profile__birthdate=datetime.date(1997, 1, 1), | ||
title="M", | ||
first_name="Jérémy", | ||
email="[email protected]", | ||
) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Je verrais bien des erreurs plus spécifique plutôt que de laisser l'utilisateur essayer de deviner.
Peut-être en mettant d'ailleurs l'erreur sur le champs fautif via un
self.add_error("birthdate", ...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Des erreurs plus spécifiques d'accord, mais vu que ça concerne des paires de champs, on ne sait pas vraiment quel champ est fautif.
Certes, on a la vérification du NIR avec sa clé normalement, mais d'un point de vue UX je ne sais pas ce qui est le mieux. Je vais demander à Marion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
J'ai eu le retour de Marion. Elle propose ces messages (pas la peine d'expliquer la structure du NIR, trop complexe).
J'ai utilisé l'opérateur
%
pour inclure le NIR dans le message d'erreur quand il y a besoin, mais je ne suis pas sûr que ce soit une bonne pratique.