Skip to content

Commit

Permalink
tests.employee_record: Fix a flaky test introduced in e8c1044
Browse files Browse the repository at this point in the history
  • Loading branch information
rsebille committed Dec 16, 2024
1 parent 0577354 commit 689aeda
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
7 changes: 6 additions & 1 deletion tests/users/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down
14 changes: 13 additions & 1 deletion tests/www/employee_record_views/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,))
Expand Down

0 comments on commit 689aeda

Please sign in to comment.