-
Notifications
You must be signed in to change notification settings - Fork 25
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
Demandeur d’emploi : Correction de la sélection de la commune de naissance pour les personnes nées le dernier jour de validité de la commune #5227
Conversation
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.
❤️
@@ -371,7 +371,7 @@ def by_insee_code_and_period(self, insee_code, period): | |||
"Lookup a Commune object by INSEE code and valid at the given period" | |||
return ( | |||
self.filter(code=insee_code, start_date__lte=period) | |||
.filter(Q(end_date=None) | Q(end_date__gt=period)) |
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.
À quand l’utilisation de InclusiveDateRange
?
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.
Un jour. Peut-être. 😁
tests/asp/test_communes.py
Outdated
|
||
result = Commune.objects.by_insee_code_and_period(99999, datetime.datetime(2022, 11, 28)) | ||
assert new_commune == result | ||
for period in [new_commune.start_date, datetime.date(2022, 11, 28), timezone.now()]: |
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.
for period in [new_commune.start_date, datetime.date(2022, 11, 28), timezone.now()]: | |
for period in [new_commune.start_date, datetime.date(2022, 11, 28), timezone.localdate()]: |
d4b2993
to
89478a6
Compare
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.
@francoisfreitag La correction pour le test en échec au moment de ta relecture est assez velue donc je veux bien un zieutage pour être sûr que c'est compréhensible :).
@@ -371,7 +371,7 @@ def by_insee_code_and_period(self, insee_code, period): | |||
"Lookup a Commune object by INSEE code and valid at the given period" | |||
return ( | |||
self.filter(code=insee_code, start_date__lte=period) | |||
.filter(Q(end_date=None) | Q(end_date__gt=period)) |
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.
Un jour. Peut-être. 😁
Je n’étais pas satisfait par ta proposition, je viens de pousser un fixup pour clarifier. Effectivement c’est velu. |
9b0aebe
to
e9e2350
Compare
e9e2350
to
36a63b5
Compare
Romain, je te laisse merger si ça te convient ? |
Ça mériterait peut-être un changelog au final: https://itou-inclusion.slack.com/archives/C01181Y04LT/p1733996418452109 🙈 |
0f24b23
to
645b129
Compare
J’ai l’impression qu’on s’est télescopé ? |
Je pense pas, j'ai rien push en tout cas. |
C’est moi qui utilisait une remote pas à jour dont la branche master avait déviée. |
@@ -371,29 +371,3 @@ def test_submit_valid(self): | |||
data=form_data, birthdate=valid_birthdate, with_birthdate_field=False | |||
) | |||
assert form.is_valid() | |||
|
|||
def test_submit_commune_invalid_commune_lookup(self): |
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.
Ce test avait le même problème et c’est un doublon moins bien intégré de test_accept_updated_birthdate_invalidating_birth_place
. => 🗑️
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 préférerais presque garder celui-ci et virer sa logique de l'autre mais oui 1 seul est suffisant ;).
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 préfère garder les tests d’intégration, qui couvrent mieux la façon dont les données arrivent au formulaire et limitent le risque de couvrir des cas impossible en réalité. 🤷
code | start_date | end_date -------+------------+------------ 01001 | 1900-01-01 | 1999-12-31 01001 | 2000-01-01 | [NULL]
The content is already verified in the accept views integration, and getting the data right is tricky: ``` birth_place = ( Commune.objects.filter( # The birthdate must be >= 1900-01-01, and we’re removing 1 day from start_date. Q(start_date__gt=datetime.date(1900, 1, 2)), # Must be a valid choice for the user current birthdate. Q(start_date__lte=birthdate), Q(end_date__gte=birthdate) | Q(end_date=None), ) .exclude( Exists( # The same code must not exists at the early_date. Commune.objects.exclude(pk=OuterRef("pk")).filter( code=OuterRef("code"), start_date__lt=OuterRef("start_date"), ) ) ) .first() ) ```
5a4e6af
to
5d85773
Compare
🤔 Pourquoi ?
Test bagottant : https://github.com/gip-inclusion/les-emplois/actions/runs/12235030153/attempts/1
Reproductible avec
pytest --randomly-seed=3864335593 -vv tests/www/employee_record_views/test_create.py::TestCreateEmployeeRecordStep2::test_access_granted
Les valeurs choisies était "1999-12-31" pour la date de naissance alors que la ville était :