api_particulier: normalize birth dates (#77306) #263

Merged
tnoel merged 1 commits from wip/77306-api-particulier-normalize-birth-date into main 2023-05-26 16:53:16 +02:00
2 changed files with 9 additions and 0 deletions

View File

@ -363,6 +363,11 @@ class APIParticulier(BaseResource):
)
data['data']['numero_allocataire'] = numero_allocataire
data['data']['code_postal'] = code_postal
for kind in 'allocataires', 'enfants':
Review

C'est pas très python 2.4 ça :)

C'est pas très python 2.4 ça :)
for person in data['data'].get(kind) or []:
if len(person.get('dateDeNaissance') or '') == 8:
birthdate = person['dateDeNaissance']
person['dateDeNaissance_iso'] = birthdate[4:] + '-' + birthdate[2:4] + '-' + birthdate[:2]
return data
category = _('Business Process Connectors')

View File

@ -319,6 +319,10 @@ def test_situation_familiale(app, resource, mock_api_particulier):
'/api-particulier/test/situation-familiale', app, resource, 'situation-familiale', params=params
)
assert resp.json['data']['adresse']['codePostalVille'] == '12345 CONDAT'
assert resp.json['data']['enfants'][0]['dateDeNaissance'] == '11122016'
assert resp.json['data']['enfants'][0]['dateDeNaissance_iso'] == '2016-12-11'
assert resp.json['data']['allocataires'][1]['dateDeNaissance'] == '18101969'
assert resp.json['data']['allocataires'][1]['dateDeNaissance_iso'] == '1969-10-18'
params['numero_allocataire'] = '11'
resp = endpoint_get(