From 689aeda8e39586281f3cb70acc72fe715f1961bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20S=C3=A9bille?= Date: Thu, 12 Dec 2024 18:00:29 +0100 Subject: [PATCH] tests.employee_record: Fix a flaky test introduced in e8c10443d --- tests/users/factories.py | 7 ++++++- tests/www/employee_record_views/test_create.py | 14 +++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/users/factories.py b/tests/users/factories.py index 7b40c2ca91..fa487a64a2 100644 --- a/tests/users/factories.py +++ b/tests/users/factories.py @@ -8,7 +8,7 @@ from django.contrib.auth.hashers import make_password from django.utils.text import slugify -from itou.asp.models import AllocationDuration, EducationLevel, LaneType +from itou.asp.models import AllocationDuration, EducationLevel, EITIContributions, LaneType from itou.cities.models import City from itou.common_apps.address.departments import DEPARTMENTS from itou.communications.models import NotificationRecord, NotificationSettings @@ -327,6 +327,11 @@ class Params: hexa_post_code=factory.Faker("postalcode"), hexa_commune=factory.SubFactory(CommuneFactory), ) + with_required_eiti_fields = factory.Trait( + actor_met_for_business_creation=factory.Faker("word", locale="en_GB"), # To match validator + mean_monthly_income_before_process=factory.Faker("pydecimal", left_digits=5, right_digits=2), + eiti_contributions=factory.fuzzy.FuzzyChoice(EITIContributions.values), + ) for_snapshot = factory.Trait( birthdate=datetime.date(1990, 1, 1), nir="290010101010125", diff --git a/tests/www/employee_record_views/test_create.py b/tests/www/employee_record_views/test_create.py index af8f780503..e10d66755e 100644 --- a/tests/www/employee_record_views/test_create.py +++ b/tests/www/employee_record_views/test_create.py @@ -807,11 +807,23 @@ class TestUpdateRejectedEmployeeRecord(CreateEmployeeRecordTestMixin): Check if update and resubmission is possible after employee record rejection """ + def _default_step_3_data(self): + data = super()._default_step_3_data() + if self.company.kind == CompanyKind.EITI: + data.update( + actor_met_for_business_creation=self.job_application.job_seeker.jobseeker_profile.actor_met_for_business_creation, + mean_monthly_income_before_process=self.job_application.job_seeker.jobseeker_profile.mean_monthly_income_before_process, + eiti_contributions=self.job_application.job_seeker.jobseeker_profile.eiti_contributions, + ) + return data + @pytest.fixture(autouse=True) def setup_method(self, client): self.job_application = JobApplicationWithApprovalNotCancellableFactory( to_company=self.company, - job_seeker=JobSeekerFactory(born_in_france=True, with_mocked_address=True), + job_seeker=JobSeekerFactory( + born_in_france=True, with_mocked_address=True, jobseeker_profile__with_required_eiti_fields=True + ), ) self.job_seeker = self.job_application.job_seeker self.url = reverse("employee_record_views:create_step_5", args=(self.job_application.id,))