From ad83ddba515f00235c78ac852016eee9f3e3838c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Freitag?= Date: Wed, 8 May 2024 18:03:57 +0200 Subject: [PATCH] Fix typo in latest_common_approval MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hopefully, this code is no longer in use and the typo did not affect too many users. 🙈 --- itou/users/models.py | 2 +- tests/users/test_models.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/itou/users/models.py b/itou/users/models.py index f2f646b991..c74f897982 100644 --- a/itou/users/models.py +++ b/itou/users/models.py @@ -472,7 +472,7 @@ def latest_common_approval(self): self.latest_approval and self.latest_approval.is_in_waiting_period and self.latest_pe_approval - and self.latest_pe_approval.is_valid + and self.latest_pe_approval.is_valid() ): return self.latest_pe_approval diff --git a/tests/users/test_models.py b/tests/users/test_models.py index 92a4794162..215624bdb2 100644 --- a/tests/users/test_models.py +++ b/tests/users/test_models.py @@ -1122,6 +1122,21 @@ def test_latest_common_approval_when_only_pe_approval(self): pe_approval = PoleEmploiApprovalFactory(nir=user.jobseeker_profile.nir) assert user.latest_common_approval == pe_approval + def test_latest_common_approval_with_expired_pe_approval(self): + user = JobSeekerFactory() + today = timezone.localdate() + PoleEmploiApprovalFactory( + nir=user.jobseeker_profile.nir, + start_at=today - datetime.timedelta(days=30), + end_at=today - datetime.timedelta(days=1), + ) + approval = ApprovalFactory( + user=user, + start_at=today - datetime.timedelta(days=10), + end_at=today - datetime.timedelta(days=7), + ) + assert user.latest_common_approval == approval + def test_latest_common_approval_is_approval_if_valid(self): user = JobSeekerFactory() approval = ApprovalFactory(user=user)