caluire-axel: fix family_date with a None first name (#81673)
gitea/passerelle/pipeline/head This commit looks good Details

This commit is contained in:
Lauréline Guérin 2023-09-28 09:51:08 +02:00 committed by Lauréline Guérin
parent 49226aca44
commit 117743e0a6
3 changed files with 5 additions and 3 deletions

View File

@ -172,7 +172,9 @@ class CaluireAxel(BaseResource):
for child in family_data.get('MEMBRE', []):
child['id'] = child['IDENT']
child['text'] = '{} {}'.format(child['PRENOM'].strip(), child['NOM'].strip()).strip()
child['text'] = '{} {}'.format(
(child['PRENOM'] or '').strip(), (child['NOM'] or '').strip()
).strip()
cache.set(cache_key, family_data, 30) # 30 seconds
return family_data

View File

@ -5,7 +5,7 @@
<IDENT>11111</IDENT>
<CIVILITE />
<NOM>CALUIRE TEST</NOM>
<PRENOM>Enfant 1 </PRENOM>
<PRENOM />
<NAISSANCE>10/10/2013</NAISSANCE>
<SEXE>M</SEXE>
<NOMJF />

View File

@ -561,7 +561,7 @@ def test_family_info_endpoint(app, resource):
assert set(resp.json['data'].keys()) == {'family_id', 'CODE', 'MEMBRE', 'RESPONSABLE1', 'RESPONSABLE2'}
assert resp.json['data']['family_id'] == 'YYY'
assert resp.json['data']['MEMBRE'][0]['id'] == '11111'
assert resp.json['data']['MEMBRE'][0]['text'] == 'Enfant 1 CALUIRE TEST'
assert resp.json['data']['MEMBRE'][0]['text'] == 'CALUIRE TEST'
assert resp.json['data']['MEMBRE'][1]['id'] == '22222'
assert resp.json['data']['MEMBRE'][1]['text'] == 'Enfant 2 CALUIRE TEST'