diff --git a/tests/gps/test_create_beneficiary.py b/tests/gps/test_create_beneficiary.py index 5322dcecb1b..9faf65e78c0 100644 --- a/tests/gps/test_create_beneficiary.py +++ b/tests/gps/test_create_beneficiary.py @@ -263,7 +263,6 @@ def test_existing_user_with_email(client): }, } - assert response.url == next_url assert client.session[job_seeker_session_name] == expected_job_seeker_session assertRedirects(response, next_url) diff --git a/tests/www/apply/test_submit.py b/tests/www/apply/test_submit.py index 44d648c2aa9..6bada226f06 100644 --- a/tests/www/apply/test_submit.py +++ b/tests/www/apply/test_submit.py @@ -305,11 +305,10 @@ def test_check_nir_job_seeker_with_lack_of_nir_reason(client): # ---------------------------------------------------------------------- response = client.get(reverse("apply:start", kwargs={"company_pk": company.pk})) - assert response.status_code == 302 [job_seeker_session_name] = [k for k in client.session.keys() if k not in KNOWN_SESSION_KEYS] next_url = reverse("job_seekers_views:check_nir_for_job_seeker", kwargs={"session_uuid": job_seeker_session_name}) - assert response.url == next_url + assertRedirects(response, next_url) # Step check job seeker NIR. # ---------------------------------------------------------------------- @@ -362,13 +361,12 @@ def test_apply_as_jobseeker(self, client, pdf_file): # ---------------------------------------------------------------------- response = client.get(reverse("apply:start", kwargs={"company_pk": company.pk})) - assert response.status_code == 302 [job_seeker_session_name] = [k for k in client.session.keys() if k not in KNOWN_SESSION_KEYS] next_url = reverse( "job_seekers_views:check_nir_for_job_seeker", kwargs={"session_uuid": job_seeker_session_name} ) - assert response.url == next_url + assertRedirects(response, next_url) # Step check job seeker NIR. # ---------------------------------------------------------------------- @@ -380,7 +378,6 @@ def test_apply_as_jobseeker(self, client, pdf_file): post_data = {"nir": nir, "confirm": 1} response = client.post(next_url, data=post_data) - assert response.status_code == 302 user = User.objects.get(pk=user.pk) assert user.jobseeker_profile.nir == nir @@ -389,7 +386,7 @@ def test_apply_as_jobseeker(self, client, pdf_file): "job_seekers_views:check_job_seeker_info", kwargs={"company_pk": company.pk, "job_seeker_public_id": user.public_id}, ) - assert response.url == next_url + assertRedirects(response, next_url) # Step check job seeker info. # ---------------------------------------------------------------------- @@ -400,7 +397,6 @@ def test_apply_as_jobseeker(self, client, pdf_file): post_data = {"birthdate": "20/12/1978", "phone": "0610203040", "pole_emploi_id": "1234567A"} response = client.post(next_url, data=post_data) - assert response.status_code == 302 user = User.objects.get(pk=user.pk) assert user.jobseeker_profile.birthdate.strftime("%d/%m/%Y") == post_data["birthdate"] @@ -412,18 +408,17 @@ def test_apply_as_jobseeker(self, client, pdf_file): "apply:step_check_prev_applications", kwargs={"company_pk": company.pk, "job_seeker_public_id": user.public_id}, ) - assert response.url == next_url + assertRedirects(response, next_url) # Step check previous job applications. # ---------------------------------------------------------------------- response = client.get(next_url) - assert response.status_code == 302 next_url = reverse( "apply:application_jobs", kwargs={"company_pk": company.pk, "job_seeker_public_id": user.public_id} ) - assert response.url == next_url + assertRedirects(response, next_url) # Step application's jobs. # ---------------------------------------------------------------------- @@ -436,24 +431,22 @@ def test_apply_as_jobseeker(self, client, pdf_file): "companies_views:job_description_card", kwargs={"job_description_id": selected_job.pk} ) response = client.post(next_url, data={"selected_jobs": [selected_job.pk]}) - assert response.status_code == 302 assert client.session[f"job_application-{company.pk}"] == {"selected_jobs": [selected_job.pk]} next_url = reverse( "apply:application_eligibility", kwargs={"company_pk": company.pk, "job_seeker_public_id": user.public_id} ) - assert response.url == next_url + assertRedirects(response, next_url) # Step application's eligibility. # ---------------------------------------------------------------------- response = client.get(next_url) - assert response.status_code == 302 next_url = reverse( "apply:application_resume", kwargs={"company_pk": company.pk, "job_seeker_public_id": user.public_id} ) - assert response.url == next_url + assertRedirects(response, next_url) # Step application's resume. # ---------------------------------------------------------------------- @@ -472,7 +465,6 @@ def test_apply_as_jobseeker(self, client, pdf_file): "resume": pdf_file, }, ) - assert response.status_code == 302 job_application = JobApplication.objects.get(sender=user, to_company=company) assert job_application.job_seeker == user @@ -492,7 +484,7 @@ def test_apply_as_jobseeker(self, client, pdf_file): next_url = reverse( "apply:application_end", kwargs={"company_pk": company.pk, "application_pk": job_application.pk} ) - assert response.url == next_url + assertRedirects(response, next_url) # Step application's end. # ---------------------------------------------------------------------- @@ -576,27 +568,27 @@ def test_apply_as_job_seeker_from_job_description(self, client): next_url = reverse( "job_seekers_views:check_nir_for_job_seeker", kwargs={"session_uuid": job_seeker_session_name} ) - assert response.url == next_url + assertRedirects(response, next_url) response = client.get(next_url) next_url = reverse( "job_seekers_views:check_job_seeker_info", kwargs={"company_pk": company.pk, "job_seeker_public_id": job_seeker.public_id}, ) - assert response.url == next_url + assertRedirects(response, next_url) response = client.get(next_url) next_url = reverse( "apply:step_check_prev_applications", kwargs={"company_pk": company.pk, "job_seeker_public_id": job_seeker.public_id}, ) - assert response.url == next_url + assertRedirects(response, next_url) response = client.get(next_url) next_url = reverse( "apply:application_jobs", kwargs={"company_pk": company.pk, "job_seeker_public_id": job_seeker.public_id} ) - assert response.url == next_url + assertRedirects(response, next_url) response = client.get(next_url) assertContains(response, LINK_RESET_MARKUP % reset_url_job_description) @@ -803,13 +795,12 @@ def test_apply_as_prescriber_with_pending_authorization(self, client, pdf_file): # ---------------------------------------------------------------------- response = client.get(reverse("apply:start", kwargs={"company_pk": company.pk})) - assert response.status_code == 302 next_url = reverse( "apply:pending_authorization_for_sender", kwargs={"company_pk": company.pk}, ) - assert response.url == next_url + assertRedirects(response, next_url) # Step show warning message about pending authorization. # ---------------------------------------------------------------------- @@ -842,7 +833,6 @@ def test_apply_as_prescriber_with_pending_authorization(self, client, pdf_file): assertRedirects(response, next_url) response = client.post(next_url, data={"nir": dummy_job_seeker.jobseeker_profile.nir, "confirm": 1}) - assert response.status_code == 302 next_url = reverse( "job_seekers_views:search_by_email_for_sender", @@ -859,7 +849,7 @@ def test_apply_as_prescriber_with_pending_authorization(self, client, pdf_file): "nir": dummy_job_seeker.jobseeker_profile.nir, }, } - assert response.url == next_url + assertRedirects(response, next_url) assert client.session[job_seeker_session_name] == expected_job_seeker_session # Step get job seeker e-mail. @@ -869,7 +859,6 @@ def test_apply_as_prescriber_with_pending_authorization(self, client, pdf_file): assert response.status_code == 200 response = client.post(next_url, data={"email": dummy_job_seeker.email, "confirm": "1"}) - assert response.status_code == 302 expected_job_seeker_session |= { "user": { @@ -882,7 +871,7 @@ def test_apply_as_prescriber_with_pending_authorization(self, client, pdf_file): "job_seekers_views:create_job_seeker_step_1_for_sender", kwargs={"session_uuid": job_seeker_session_name}, ) - assert response.url == next_url + assertRedirects(response, next_url) # Step create a job seeker. # ---------------------------------------------------------------------- @@ -913,7 +902,6 @@ def test_apply_as_prescriber_with_pending_authorization(self, client, pdf_file): "birth_country": Country.france_id, } response = client.post(next_url, data=post_data) - assert response.status_code == 302 expected_job_seeker_session["profile"]["birthdate"] = post_data.pop("birthdate") expected_job_seeker_session["profile"]["lack_of_nir_reason"] = post_data.pop("lack_of_nir_reason") expected_job_seeker_session["profile"]["birth_place"] = post_data.pop("birth_place") @@ -925,7 +913,7 @@ def test_apply_as_prescriber_with_pending_authorization(self, client, pdf_file): "job_seekers_views:create_job_seeker_step_2_for_sender", kwargs={"session_uuid": job_seeker_session_name}, ) - assert response.url == next_url + assertRedirects(response, next_url) response = client.get(next_url) assert response.status_code == 200 @@ -942,7 +930,6 @@ def test_apply_as_prescriber_with_pending_authorization(self, client, pdf_file): response = client.post(next_url, data=post_data) - assert response.status_code == 302 expected_job_seeker_session["user"] |= post_data | {"address_line_2": "", "address_for_autocomplete": None} assert client.session[job_seeker_session_name] == expected_job_seeker_session @@ -950,7 +937,7 @@ def test_apply_as_prescriber_with_pending_authorization(self, client, pdf_file): "job_seekers_views:create_job_seeker_step_3_for_sender", kwargs={"session_uuid": job_seeker_session_name}, ) - assert response.url == next_url + assertRedirects(response, next_url) response = client.get(next_url) assert response.status_code == 200 @@ -959,7 +946,6 @@ def test_apply_as_prescriber_with_pending_authorization(self, client, pdf_file): "education_level": dummy_job_seeker.jobseeker_profile.education_level, } response = client.post(next_url, data=post_data) - assert response.status_code == 302 expected_job_seeker_session["profile"] |= post_data | { "pole_emploi_id": "", "lack_of_pole_emploi_id_reason": LackOfPoleEmploiId.REASON_NOT_REGISTERED.value, @@ -985,14 +971,13 @@ def test_apply_as_prescriber_with_pending_authorization(self, client, pdf_file): "job_seekers_views:create_job_seeker_step_end_for_sender", kwargs={"session_uuid": job_seeker_session_name}, ) - assert response.url == next_url + assertRedirects(response, next_url) response = client.get(next_url) assertContains(response, "Créer le compte candidat") mock_advisor_list(dummy_job_seeker.jobseeker_profile.nir) response = client.post(next_url) - assert response.status_code == 302 assert job_seeker_session_name not in client.session new_job_seeker = User.objects.get(email=dummy_job_seeker.email) @@ -1004,7 +989,7 @@ def test_apply_as_prescriber_with_pending_authorization(self, client, pdf_file): "apply:application_jobs", kwargs={"company_pk": company.pk, "job_seeker_public_id": new_job_seeker.public_id}, ) - assert response.url == next_url + assertRedirects(response, next_url) # Step application's jobs. # ---------------------------------------------------------------------- @@ -1014,7 +999,6 @@ def test_apply_as_prescriber_with_pending_authorization(self, client, pdf_file): selected_job = company.job_description_through.first() response = client.post(next_url, data={"selected_jobs": [selected_job.pk]}) - assert response.status_code == 302 assert client.session[f"job_application-{company.pk}"] == {"selected_jobs": [selected_job.pk]} @@ -1022,18 +1006,17 @@ def test_apply_as_prescriber_with_pending_authorization(self, client, pdf_file): "apply:application_eligibility", kwargs={"company_pk": company.pk, "job_seeker_public_id": new_job_seeker.public_id}, ) - assert response.url == next_url + assertRedirects(response, next_url) # Step application's eligibility. # ---------------------------------------------------------------------- response = client.get(next_url) - assert response.status_code == 302 next_url = reverse( "apply:application_resume", kwargs={"company_pk": company.pk, "job_seeker_public_id": new_job_seeker.public_id}, ) - assert response.url == next_url + assertRedirects(response, next_url) # Step application's resume. # ---------------------------------------------------------------------- @@ -1051,7 +1034,6 @@ def test_apply_as_prescriber_with_pending_authorization(self, client, pdf_file): "resume": pdf_file, }, ) - assert response.status_code == 302 job_application = JobApplication.objects.get(sender=user, to_company=company) assert job_application.job_seeker == new_job_seeker @@ -1071,7 +1053,7 @@ def test_apply_as_prescriber_with_pending_authorization(self, client, pdf_file): next_url = reverse( "apply:application_end", kwargs={"company_pk": company.pk, "application_pk": job_application.pk} ) - assert response.url == next_url + assertRedirects(response, next_url) # Step application's end. # ---------------------------------------------------------------------- @@ -1101,7 +1083,6 @@ def test_apply_as_authorized_prescriber(self, client, pdf_file): # ---------------------------------------------------------------------- response = client.get(reverse("apply:start", kwargs={"company_pk": company.pk})) - assert response.status_code == 302 params = { "tunnel": "sender", @@ -1109,12 +1090,12 @@ def test_apply_as_authorized_prescriber(self, client, pdf_file): "from_url": reset_url_company, } next_url = add_url_params(reverse("job_seekers_views:get_or_create_start"), params) - assert response.url == next_url + assertRedirects(response, next_url) response = client.get(next_url) [job_seeker_session_name] = [k for k in client.session.keys() if k not in KNOWN_SESSION_KEYS] next_url = reverse("job_seekers_views:check_nir_for_sender", kwargs={"session_uuid": job_seeker_session_name}) - assert response.url == next_url + assertRedirects(response, next_url) # Step determine the job seeker with a NIR. # ---------------------------------------------------------------------- @@ -1123,13 +1104,12 @@ def test_apply_as_authorized_prescriber(self, client, pdf_file): assertContains(response, LINK_RESET_MARKUP % reset_url_company) response = client.post(next_url, data={"nir": dummy_job_seeker.jobseeker_profile.nir, "confirm": 1}) - assert response.status_code == 302 next_url = reverse( "job_seekers_views:search_by_email_for_sender", kwargs={"session_uuid": job_seeker_session_name}, ) - assert response.url == next_url + assertRedirects(response, next_url) # Step get job seeker e-mail. # ---------------------------------------------------------------------- @@ -1138,7 +1118,6 @@ def test_apply_as_authorized_prescriber(self, client, pdf_file): assertContains(response, CONFIRM_RESET_MARKUP % reset_url_company) response = client.post(next_url, data={"email": dummy_job_seeker.email, "confirm": "1"}) - assert response.status_code == 302 expected_job_seeker_session = { "config": { @@ -1160,7 +1139,7 @@ def test_apply_as_authorized_prescriber(self, client, pdf_file): "job_seekers_views:create_job_seeker_step_1_for_sender", kwargs={"session_uuid": job_seeker_session_name}, ) - assert response.url == next_url + assertRedirects(response, next_url) # Step create a job seeker. # ---------------------------------------------------------------------- @@ -1191,7 +1170,6 @@ def test_apply_as_authorized_prescriber(self, client, pdf_file): "birth_country": Country.france_id, } response = client.post(next_url, data=post_data) - assert response.status_code == 302 expected_job_seeker_session["profile"]["birthdate"] = post_data.pop("birthdate") expected_job_seeker_session["profile"]["lack_of_nir_reason"] = post_data.pop("lack_of_nir_reason") expected_job_seeker_session["profile"]["birth_place"] = post_data.pop("birth_place") @@ -1204,7 +1182,7 @@ def test_apply_as_authorized_prescriber(self, client, pdf_file): "job_seekers_views:create_job_seeker_step_2_for_sender", kwargs={"session_uuid": job_seeker_session_name}, ) - assert response.url == next_url + assertRedirects(response, next_url) response = client.get(next_url) assertContains(response, CONFIRM_RESET_MARKUP % reset_url_company) @@ -1220,7 +1198,6 @@ def test_apply_as_authorized_prescriber(self, client, pdf_file): } response = client.post(next_url, data=post_data) - assert response.status_code == 302 expected_job_seeker_session["user"] |= post_data | {"address_for_autocomplete": None, "address_line_2": ""} assert client.session[job_seeker_session_name] == expected_job_seeker_session @@ -1228,7 +1205,7 @@ def test_apply_as_authorized_prescriber(self, client, pdf_file): "job_seekers_views:create_job_seeker_step_3_for_sender", kwargs={"session_uuid": job_seeker_session_name}, ) - assert response.url == next_url + assertRedirects(response, next_url) response = client.get(next_url) assertContains(response, CONFIRM_RESET_MARKUP % reset_url_company) @@ -1237,7 +1214,6 @@ def test_apply_as_authorized_prescriber(self, client, pdf_file): "education_level": dummy_job_seeker.jobseeker_profile.education_level, } response = client.post(next_url, data=post_data) - assert response.status_code == 302 expected_job_seeker_session["profile"] |= post_data | { "pole_emploi_id": "", "lack_of_pole_emploi_id_reason": LackOfPoleEmploiId.REASON_NOT_REGISTERED.value, @@ -1263,13 +1239,12 @@ def test_apply_as_authorized_prescriber(self, client, pdf_file): "job_seekers_views:create_job_seeker_step_end_for_sender", kwargs={"session_uuid": job_seeker_session_name}, ) - assert response.url == next_url + assertRedirects(response, next_url) response = client.get(next_url) assertContains(response, "Créer le compte candidat") response = client.post(next_url) - assert response.status_code == 302 assert job_seeker_session_name not in client.session new_job_seeker = User.objects.get(email=dummy_job_seeker.email) @@ -1278,7 +1253,7 @@ def test_apply_as_authorized_prescriber(self, client, pdf_file): "apply:application_jobs", kwargs={"company_pk": company.pk, "job_seeker_public_id": new_job_seeker.public_id}, ) - assert response.url == next_url + assertRedirects(response, next_url) # Step application's jobs. # ---------------------------------------------------------------------- @@ -1291,7 +1266,6 @@ def test_apply_as_authorized_prescriber(self, client, pdf_file): "companies_views:job_description_card", kwargs={"job_description_id": selected_job.pk} ) response = client.post(next_url, data={"selected_jobs": [selected_job.pk]}) - assert response.status_code == 302 assert client.session[f"job_application-{company.pk}"] == {"selected_jobs": [selected_job.pk]} @@ -1299,7 +1273,7 @@ def test_apply_as_authorized_prescriber(self, client, pdf_file): "apply:application_eligibility", kwargs={"company_pk": company.pk, "job_seeker_public_id": new_job_seeker.public_id}, ) - assert response.url == next_url + assertRedirects(response, next_url) # Step application's eligibility. # ---------------------------------------------------------------------- @@ -1316,7 +1290,6 @@ def test_apply_as_authorized_prescriber(self, client, pdf_file): assertTemplateUsed(response, "apply/includes/known_criteria.html", count=1) response = client.post(next_url, {"level_1_1": True}) - assert response.status_code == 302 diag = EligibilityDiagnosis.objects.last_considered_valid(job_seeker=new_job_seeker, for_siae=company) assert diag.is_valid is True assert diag.expires_at == timezone.localdate() + relativedelta(months=6) @@ -1325,7 +1298,7 @@ def test_apply_as_authorized_prescriber(self, client, pdf_file): "apply:application_resume", kwargs={"company_pk": company.pk, "job_seeker_public_id": new_job_seeker.public_id}, ) - assert response.url == next_url + assertRedirects(response, next_url) # Step application's resume. # ---------------------------------------------------------------------- @@ -1344,7 +1317,6 @@ def test_apply_as_authorized_prescriber(self, client, pdf_file): "resume": pdf_file, }, ) - assert response.status_code == 302 job_application = JobApplication.objects.get(sender=user, to_company=company) assert job_application.job_seeker == new_job_seeker @@ -1364,7 +1336,7 @@ def test_apply_as_authorized_prescriber(self, client, pdf_file): next_url = reverse( "apply:application_end", kwargs={"company_pk": company.pk, "application_pk": job_application.pk} ) - assert response.url == next_url + assertRedirects(response, next_url) # Step application's end. # ---------------------------------------------------------------------- @@ -1395,13 +1367,12 @@ def test_cannot_create_job_seeker_with_pole_emploi_email(self, client): assert response.status_code == 200 response = client.post(nir_url, data={"nir": JobSeekerProfileFactory.build().nir, "confirm": 1}) - assert response.status_code == 302 email_url = reverse( "job_seekers_views:search_by_email_for_sender", kwargs={"session_uuid": job_seeker_session_name}, ) - assert response.url == email_url + assertRedirects(response, email_url) # Step get job seeker e-mail. # ---------------------------------------------------------------------- @@ -1444,7 +1415,6 @@ def test_apply_with_temporary_nir(self, client): client.force_login(user) response = client.get(reverse("apply:start", kwargs={"company_pk": company.pk})) - assert response.status_code == 302 params = { "tunnel": "sender", @@ -1452,7 +1422,7 @@ def test_apply_with_temporary_nir(self, client): "from_url": reverse("companies_views:card", kwargs={"siae_id": company.pk}), } next_url = add_url_params(reverse("job_seekers_views:get_or_create_start"), params) - assert response.url == next_url + assertRedirects(response, next_url) response = client.get(next_url) [job_seeker_session_name] = [k for k in client.session.keys() if k not in KNOWN_SESSION_KEYS] @@ -1537,19 +1507,18 @@ def test_apply_as_prescriber(self, client, pdf_file): # ---------------------------------------------------------------------- response = client.get(reverse("apply:start", kwargs={"company_pk": company.pk})) - assert response.status_code == 302 params = { "tunnel": "sender", "company": company.pk, "from_url": reset_url_company, } next_url = add_url_params(reverse("job_seekers_views:get_or_create_start"), params) - assert response.url == next_url + assertRedirects(response, next_url) response = client.get(next_url) [job_seeker_session_name] = [k for k in client.session.keys() if k not in KNOWN_SESSION_KEYS] next_url = reverse("job_seekers_views:check_nir_for_sender", kwargs={"session_uuid": job_seeker_session_name}) - assert response.url == next_url + assertRedirects(response, next_url) # Step determine the job seeker with a NIR. # ---------------------------------------------------------------------- @@ -1558,13 +1527,12 @@ def test_apply_as_prescriber(self, client, pdf_file): assertContains(response, LINK_RESET_MARKUP % reset_url_company) response = client.post(next_url, data={"nir": dummy_job_seeker.jobseeker_profile.nir, "confirm": 1}) - assert response.status_code == 302 next_url = reverse( "job_seekers_views:search_by_email_for_sender", kwargs={"session_uuid": job_seeker_session_name}, ) - assert response.url == next_url + assertRedirects(response, next_url) expected_job_seeker_session = { "config": { @@ -1585,7 +1553,6 @@ def test_apply_as_prescriber(self, client, pdf_file): assertContains(response, CONFIRM_RESET_MARKUP % reset_url_company) response = client.post(next_url, data={"email": dummy_job_seeker.email, "confirm": "1"}) - assert response.status_code == 302 expected_job_seeker_session |= { "user": { @@ -1598,7 +1565,7 @@ def test_apply_as_prescriber(self, client, pdf_file): "job_seekers_views:create_job_seeker_step_1_for_sender", kwargs={"session_uuid": job_seeker_session_name}, ) - assert response.url == next_url + assertRedirects(response, next_url) # Step create a job seeker. # ---------------------------------------------------------------------- @@ -1658,7 +1625,6 @@ def test_apply_as_prescriber(self, client, pdf_file): "birth_country": Country.france_id, } response = client.post(next_url, data=post_data) - assert response.status_code == 302 expected_job_seeker_session["profile"]["birthdate"] = post_data.pop("birthdate") expected_job_seeker_session["profile"]["lack_of_nir_reason"] = post_data.pop("lack_of_nir_reason") expected_job_seeker_session["profile"]["birth_place"] = post_data.pop("birth_place") @@ -1670,7 +1636,7 @@ def test_apply_as_prescriber(self, client, pdf_file): "job_seekers_views:create_job_seeker_step_2_for_sender", kwargs={"session_uuid": job_seeker_session_name}, ) - assert response.url == next_url + assertRedirects(response, next_url) response = client.get(next_url) assertContains(response, CONFIRM_RESET_MARKUP % reset_url_company) @@ -1685,7 +1651,6 @@ def test_apply_as_prescriber(self, client, pdf_file): "fill_mode": "ban_api", } response = client.post(next_url, data=post_data) - assert response.status_code == 302 expected_job_seeker_session["user"] |= post_data | {"address_line_2": "", "address_for_autocomplete": None} assert client.session[job_seeker_session_name] == expected_job_seeker_session @@ -1693,7 +1658,7 @@ def test_apply_as_prescriber(self, client, pdf_file): "job_seekers_views:create_job_seeker_step_3_for_sender", kwargs={"session_uuid": job_seeker_session_name}, ) - assert response.url == next_url + assertRedirects(response, next_url) response = client.get(next_url) assertContains(response, CONFIRM_RESET_MARKUP % reset_url_company) @@ -1702,7 +1667,6 @@ def test_apply_as_prescriber(self, client, pdf_file): "education_level": dummy_job_seeker.jobseeker_profile.education_level, } response = client.post(next_url, data=post_data) - assert response.status_code == 302 expected_job_seeker_session["profile"] |= post_data | { "pole_emploi_id": "", "lack_of_pole_emploi_id_reason": LackOfPoleEmploiId.REASON_NOT_REGISTERED.value, @@ -1728,7 +1692,7 @@ def test_apply_as_prescriber(self, client, pdf_file): "job_seekers_views:create_job_seeker_step_end_for_sender", kwargs={"session_uuid": job_seeker_session_name}, ) - assert response.url == next_url + assertRedirects(response, next_url) response = client.get(next_url) assertContains(response, "Créer le compte candidat") @@ -1753,7 +1717,6 @@ def test_apply_as_prescriber(self, client, pdf_file): other_job_seeker.delete() response = client.post(next_url) - assert response.status_code == 302 assert job_seeker_session_name not in client.session new_job_seeker = User.objects.get(email=dummy_job_seeker.email) @@ -1762,7 +1725,7 @@ def test_apply_as_prescriber(self, client, pdf_file): "apply:application_jobs", kwargs={"company_pk": company.pk, "job_seeker_public_id": new_job_seeker.public_id}, ) - assert response.url == next_url + assertRedirects(response, next_url) # Step application's jobs. # ---------------------------------------------------------------------- @@ -1775,7 +1738,6 @@ def test_apply_as_prescriber(self, client, pdf_file): "companies_views:job_description_card", kwargs={"job_description_id": selected_job.pk} ) response = client.post(next_url, data={"selected_jobs": [selected_job.pk]}) - assert response.status_code == 302 assert client.session[f"job_application-{company.pk}"] == {"selected_jobs": [selected_job.pk]} @@ -1783,18 +1745,17 @@ def test_apply_as_prescriber(self, client, pdf_file): "apply:application_eligibility", kwargs={"company_pk": company.pk, "job_seeker_public_id": new_job_seeker.public_id}, ) - assert response.url == next_url + assertRedirects(response, next_url) # Step application's eligibility. # ---------------------------------------------------------------------- response = client.get(next_url) - assert response.status_code == 302 next_url = reverse( "apply:application_resume", kwargs={"company_pk": company.pk, "job_seeker_public_id": new_job_seeker.public_id}, ) - assert response.url == next_url + assertRedirects(response, next_url) # Step application's resume. # ---------------------------------------------------------------------- @@ -1813,7 +1774,6 @@ def test_apply_as_prescriber(self, client, pdf_file): "resume": pdf_file, }, ) - assert response.status_code == 302 job_application = JobApplication.objects.get(sender=user, to_company=company) assert job_application.job_seeker == new_job_seeker @@ -1834,7 +1794,7 @@ def test_apply_as_prescriber(self, client, pdf_file): next_url = reverse( "apply:application_end", kwargs={"company_pk": company.pk, "application_pk": job_application.pk} ) - assert response.url == next_url + assertRedirects(response, next_url) # Step application's end. # ---------------------------------------------------------------------- @@ -1949,7 +1909,7 @@ def test_one_account_no_nir(self, client): }, } - assert response.url == next_url + assertRedirects(response, next_url) assert client.session[job_seeker_session_name] == expected_job_seeker_session assertRedirects(response, next_url) @@ -2035,7 +1995,7 @@ def test_one_account_lack_of_nir_reason(self, client): "nir": nir, }, } - assert response.url == next_url + assertRedirects(response, next_url) assert client.session[job_seeker_session_name] == expected_job_seeker_session assertRedirects(response, next_url) @@ -2120,7 +2080,6 @@ def _test_apply_as_company(self, client, user, company, dummy_job_seeker, pdf_fi # ---------------------------------------------------------------------- response = client.get(reverse("apply:start", kwargs={"company_pk": company.pk})) - assert response.status_code == 302 params = { "tunnel": "sender", @@ -2128,12 +2087,12 @@ def _test_apply_as_company(self, client, user, company, dummy_job_seeker, pdf_fi "from_url": reset_url, } next_url = add_url_params(reverse("job_seekers_views:get_or_create_start"), params) - assert response.url == next_url + assertRedirects(response, next_url) response = client.get(next_url) [job_seeker_session_name] = [k for k in client.session.keys() if k not in KNOWN_SESSION_KEYS] next_url = reverse("job_seekers_views:check_nir_for_sender", kwargs={"session_uuid": job_seeker_session_name}) - assert response.url == next_url + assertRedirects(response, next_url) # Step determine the job seeker with a NIR. # ---------------------------------------------------------------------- @@ -2142,7 +2101,6 @@ def _test_apply_as_company(self, client, user, company, dummy_job_seeker, pdf_fi assertContains(response, LINK_RESET_MARKUP % reset_url) response = client.post(next_url, data={"nir": dummy_job_seeker.jobseeker_profile.nir, "confirm": 1}) - assert response.status_code == 302 next_url = reverse( "job_seekers_views:search_by_email_for_sender", @@ -2155,7 +2113,7 @@ def _test_apply_as_company(self, client, user, company, dummy_job_seeker, pdf_fi "nir": dummy_job_seeker.jobseeker_profile.nir, }, } - assert response.url == next_url + assertRedirects(response, next_url) assert client.session[job_seeker_session_name] == expected_job_seeker_session # Step get job seeker e-mail. @@ -2165,7 +2123,6 @@ def _test_apply_as_company(self, client, user, company, dummy_job_seeker, pdf_fi assertContains(response, CONFIRM_RESET_MARKUP % reset_url) response = client.post(next_url, data={"email": dummy_job_seeker.email, "confirm": "1"}) - assert response.status_code == 302 expected_job_seeker_session |= { "user": { @@ -2178,7 +2135,7 @@ def _test_apply_as_company(self, client, user, company, dummy_job_seeker, pdf_fi "job_seekers_views:create_job_seeker_step_1_for_sender", kwargs={"session_uuid": job_seeker_session_name}, ) - assert response.url == next_url + assertRedirects(response, next_url) # Step create a job seeker. # ---------------------------------------------------------------------- @@ -2238,7 +2195,6 @@ def _test_apply_as_company(self, client, user, company, dummy_job_seeker, pdf_fi "birth_country": Country.france_id, } response = client.post(next_url, data=post_data) - assert response.status_code == 302 expected_job_seeker_session["profile"]["birthdate"] = post_data.pop("birthdate") expected_job_seeker_session["profile"]["lack_of_nir_reason"] = post_data.pop("lack_of_nir_reason") expected_job_seeker_session["profile"]["birth_place"] = post_data.pop("birth_place") @@ -2250,7 +2206,7 @@ def _test_apply_as_company(self, client, user, company, dummy_job_seeker, pdf_fi "job_seekers_views:create_job_seeker_step_2_for_sender", kwargs={"session_uuid": job_seeker_session_name}, ) - assert response.url == next_url + assertRedirects(response, next_url) response = client.get(next_url) assertContains(response, CONFIRM_RESET_MARKUP % reset_url) @@ -2266,7 +2222,6 @@ def _test_apply_as_company(self, client, user, company, dummy_job_seeker, pdf_fi } response = client.post(next_url, data=post_data) - assert response.status_code == 302 expected_job_seeker_session["user"] |= post_data | {"address_line_2": "", "address_for_autocomplete": None} assert client.session[job_seeker_session_name] == expected_job_seeker_session @@ -2274,7 +2229,7 @@ def _test_apply_as_company(self, client, user, company, dummy_job_seeker, pdf_fi "job_seekers_views:create_job_seeker_step_3_for_sender", kwargs={"session_uuid": job_seeker_session_name}, ) - assert response.url == next_url + assertRedirects(response, next_url) response = client.get(next_url) assertContains(response, CONFIRM_RESET_MARKUP % reset_url) @@ -2283,7 +2238,6 @@ def _test_apply_as_company(self, client, user, company, dummy_job_seeker, pdf_fi "education_level": dummy_job_seeker.jobseeker_profile.education_level, } response = client.post(next_url, data=post_data) - assert response.status_code == 302 expected_job_seeker_session["profile"] |= post_data | { "pole_emploi_id": "", "lack_of_pole_emploi_id_reason": LackOfPoleEmploiId.REASON_NOT_REGISTERED, @@ -2309,13 +2263,12 @@ def _test_apply_as_company(self, client, user, company, dummy_job_seeker, pdf_fi "job_seekers_views:create_job_seeker_step_end_for_sender", kwargs={"session_uuid": job_seeker_session_name}, ) - assert response.url == next_url + assertRedirects(response, next_url) response = client.get(next_url) assertContains(response, "Créer le compte candidat") response = client.post(next_url) - assert response.status_code == 302 assert job_seeker_session_name not in client.session new_job_seeker = User.objects.get(email=dummy_job_seeker.email) @@ -2324,7 +2277,7 @@ def _test_apply_as_company(self, client, user, company, dummy_job_seeker, pdf_fi "apply:application_jobs", kwargs={"company_pk": company.pk, "job_seeker_public_id": new_job_seeker.public_id}, ) - assert response.url == next_url + assertRedirects(response, next_url) # Step application's jobs. # ---------------------------------------------------------------------- @@ -2341,7 +2294,6 @@ def _test_apply_as_company(self, client, user, company, dummy_job_seeker, pdf_fi else reverse("companies_views:job_description_card", kwargs={"job_description_id": selected_job.pk}) ) response = client.post(next_url, data={"selected_jobs": [selected_job.pk]}) - assert response.status_code == 302 assert client.session[f"job_application-{company.pk}"] == {"selected_jobs": [selected_job.pk]} @@ -2349,18 +2301,17 @@ def _test_apply_as_company(self, client, user, company, dummy_job_seeker, pdf_fi "apply:application_eligibility", kwargs={"company_pk": company.pk, "job_seeker_public_id": new_job_seeker.public_id}, ) - assert response.url == next_url + assertRedirects(response, next_url) # Step application's eligibility. # ---------------------------------------------------------------------- response = client.get(next_url) - assert response.status_code == 302 next_url = reverse( "apply:application_resume", kwargs={"company_pk": company.pk, "job_seeker_public_id": new_job_seeker.public_id}, ) - assert response.url == next_url + assertRedirects(response, next_url) # Step application's resume. # ---------------------------------------------------------------------- @@ -2379,7 +2330,6 @@ def _test_apply_as_company(self, client, user, company, dummy_job_seeker, pdf_fi "resume": pdf_file, }, ) - assert response.status_code == 302 job_application = JobApplication.objects.get(sender=user, to_company=company) assert job_application.job_seeker == new_job_seeker @@ -2400,7 +2350,7 @@ def _test_apply_as_company(self, client, user, company, dummy_job_seeker, pdf_fi next_url = reverse( "apply:application_end", kwargs={"company_pk": company.pk, "application_pk": job_application.pk} ) - assert response.url == next_url + assertRedirects(response, next_url) # Step application's end. # ---------------------------------------------------------------------- @@ -2498,13 +2448,12 @@ def test_cannot_create_job_seeker_with_pole_emploi_email(self, client): assert response.status_code == 200 response = client.post(nir_url, data={"nir": JobSeekerProfileFactory.build().nir, "confirm": 1}) - assert response.status_code == 302 email_url = reverse( "job_seekers_views:search_by_email_for_sender", kwargs={"session_uuid": job_seeker_session_name}, ) - assert response.url == email_url + assertRedirects(response, email_url) # Step get job seeker e-mail. # ---------------------------------------------------------------------- @@ -2598,13 +2547,12 @@ def test_hire_as_company(self, client): assertContains(response, LINK_RESET_MARKUP % reset_url_dashboard) response = client.post(check_nir_url, data={"nir": dummy_job_seeker.jobseeker_profile.nir, "preview": 1}) - assert response.status_code == 302 next_url = reverse( "job_seekers_views:search_by_email_for_hire", kwargs={"session_uuid": job_seeker_session_name}, ) - assert response.url == next_url + assertRedirects(response, next_url) # Step get job seeker e-mail. # ---------------------------------------------------------------------- @@ -2613,7 +2561,6 @@ def test_hire_as_company(self, client): assertContains(response, CONFIRM_RESET_MARKUP % reset_url_dashboard) response = client.post(next_url, data={"email": dummy_job_seeker.email, "confirm": "1"}) - assert response.status_code == 302 expected_job_seeker_session = { "config": { @@ -2635,7 +2582,7 @@ def test_hire_as_company(self, client): "job_seekers_views:create_job_seeker_step_1_for_hire", kwargs={"session_uuid": job_seeker_session_name}, ) - assert response.url == next_url + assertRedirects(response, next_url) # Step create a job seeker. # ---------------------------------------------------------------------- @@ -2696,7 +2643,6 @@ def test_hire_as_company(self, client): "birth_country": Country.france_id, } response = client.post(next_url, data=post_data) - assert response.status_code == 302 expected_job_seeker_session["profile"]["birthdate"] = post_data.pop("birthdate") expected_job_seeker_session["profile"]["lack_of_nir_reason"] = post_data.pop("lack_of_nir_reason") expected_job_seeker_session["profile"]["birth_place"] = post_data.pop("birth_place") @@ -2708,7 +2654,7 @@ def test_hire_as_company(self, client): "job_seekers_views:create_job_seeker_step_2_for_hire", kwargs={"session_uuid": job_seeker_session_name}, ) - assert response.url == next_url + assertRedirects(response, next_url) response = client.get(next_url) assertContains(response, CONFIRM_RESET_MARKUP % reset_url_dashboard) @@ -2725,7 +2671,6 @@ def test_hire_as_company(self, client): response = client.post(next_url, data=post_data) - assert response.status_code == 302 expected_job_seeker_session["user"] |= post_data | {"address_line_2": "", "address_for_autocomplete": None} assert client.session[job_seeker_session_name] == expected_job_seeker_session @@ -2733,7 +2678,7 @@ def test_hire_as_company(self, client): "job_seekers_views:create_job_seeker_step_3_for_hire", kwargs={"session_uuid": job_seeker_session_name}, ) - assert response.url == next_url + assertRedirects(response, next_url) response = client.get(next_url) assertContains(response, CONFIRM_RESET_MARKUP % reset_url_dashboard) @@ -2742,7 +2687,6 @@ def test_hire_as_company(self, client): "education_level": dummy_job_seeker.jobseeker_profile.education_level, } response = client.post(next_url, data=post_data) - assert response.status_code == 302 expected_job_seeker_session["profile"] |= post_data | { "pole_emploi_id": "", "lack_of_pole_emploi_id_reason": LackOfPoleEmploiId.REASON_NOT_REGISTERED.value, @@ -2768,13 +2712,12 @@ def test_hire_as_company(self, client): "job_seekers_views:create_job_seeker_step_end_for_hire", kwargs={"session_uuid": job_seeker_session_name}, ) - assert response.url == next_url + assertRedirects(response, next_url) response = client.get(next_url) assertContains(response, CONFIRM_RESET_MARKUP % reset_url_dashboard) response = client.post(next_url) - assert response.status_code == 302 assert job_seeker_session_name not in client.session new_job_seeker = User.objects.get(email=dummy_job_seeker.email) @@ -2784,7 +2727,7 @@ def test_hire_as_company(self, client): "apply:eligibility_for_hire", kwargs={"company_pk": company.pk, "job_seeker_public_id": new_job_seeker.public_id}, ) - assert response.url == next_url + assertRedirects(response, next_url) # Step eligibility diagnosis # ---------------------------------------------------------------------- @@ -2808,13 +2751,12 @@ def test_hire_as_company(self, client): f"{criterion3.key}": "on", }, ) - assert response.status_code == 302 next_url = reverse( "apply:hire_confirmation", kwargs={"company_pk": company.pk, "job_seeker_public_id": new_job_seeker.public_id}, ) - assert response.url == next_url + assertRedirects(response, next_url) diag = EligibilityDiagnosis.objects.last_considered_valid(job_seeker=new_job_seeker, for_siae=company) assert diag.expires_at == timezone.localdate() + EligibilityDiagnosis.EMPLOYER_DIAGNOSIS_VALIDITY_TIMEDELTA @@ -4105,7 +4047,6 @@ def test_detect_existing_job_seeker(client): # ---------------------------------------------------------------------- response = client.get(reverse("apply:start", kwargs={"company_pk": company.pk})) - assert response.status_code == 302 params = { "tunnel": "sender", @@ -4113,7 +4054,7 @@ def test_detect_existing_job_seeker(client): "from_url": reverse("companies_views:card", kwargs={"siae_id": company.pk}), } next_url = add_url_params(reverse("job_seekers_views:get_or_create_start"), params) - assert response.url == next_url + assertRedirects(response, next_url) # Step determine the job seeker with a NIR. # ---------------------------------------------------------------------- @@ -4127,7 +4068,6 @@ def test_detect_existing_job_seeker(client): NEW_NIR = "197013625838386" response = client.post(next_url, data={"nir": NEW_NIR, "confirm": 1}) - assert response.status_code == 302 next_url = reverse( "job_seekers_views:search_by_email_for_sender", kwargs={"session_uuid": job_seeker_session_name}, @@ -4143,7 +4083,7 @@ def test_detect_existing_job_seeker(client): "nir": NEW_NIR, }, } - assert response.url == next_url + assertRedirects(response, next_url) assert client.session[job_seeker_session_name] == expected_job_seeker_session # Step get job seeker e-mail. @@ -4153,7 +4093,6 @@ def test_detect_existing_job_seeker(client): assert response.status_code == 200 response = client.post(next_url, data={"email": "wrong-email@example.com", "confirm": "1"}) - assert response.status_code == 302 expected_job_seeker_session |= { "user": { @@ -4166,7 +4105,7 @@ def test_detect_existing_job_seeker(client): "job_seekers_views:create_job_seeker_step_1_for_sender", kwargs={"session_uuid": job_seeker_session_name}, ) - assert response.url == next_url + assertRedirects(response, next_url) # Step to create a job seeker. # ---------------------------------------------------------------------- @@ -4229,7 +4168,7 @@ def test_detect_existing_job_seeker(client): "job_seekers_views:create_job_seeker_step_2_for_sender", kwargs={"session_uuid": job_seeker_session_name}, ) - assert response.url == next_url + assertRedirects(response, next_url) # If we chose to cancel & go back, we should find our old wrong email in the page response = client.get(check_email_url) @@ -4801,14 +4740,13 @@ def test_no_job_seeker_redirect_to_create(self, client): assertContains(response, "Déclarer une embauche") response = client.post(check_nir_url, data={"nir": dummy_job_seeker.jobseeker_profile.nir, "preview": 1}) - assert response.status_code == 302 job_seeker_session_name = str(resolve(response.url).kwargs["session_uuid"]) search_by_email_url = reverse( "job_seekers_views:search_by_email_for_hire", kwargs={"session_uuid": job_seeker_session_name}, ) - assert response.url == search_by_email_url + assertRedirects(response, search_by_email_url) response = client.get(search_by_email_url) assertContains(response, "Déclarer une embauche") # Check page title