caluire-axel: get first item of list in GETFAMILLE (#55729)

This commit is contained in:
Nicolas Roche 2021-07-21 11:21:07 +02:00
parent 46c6fbe4f6
commit bdda53e495
3 changed files with 9 additions and 1 deletions

View File

@ -167,6 +167,12 @@ class CaluireAxel(BaseResource):
family_data = result.json_response['DATA']['PORTAIL']['GETFAMILLE']
family_data['CODE'] = family_data['CODE'][0]
if family_data.get('RESPONSABLE1'):
family_data['RESPONSABLE1'] = family_data['RESPONSABLE1'][0]
if family_data.get('RESPONSABLE2'):
family_data['RESPONSABLE2'] = family_data['RESPONSABLE2'][0]
for child in family_data.get('MEMBRE', []):
child['id'] = child['IDENT']
child['text'] = '{} {}'.format(child['PRENOM'].strip(), child['NOM'].strip()).strip()

View File

@ -22,7 +22,7 @@
</xsd:complexType>
</xsd:redefine>
<xsd:complexType name="GETFAMILLEType">
<xsd:complexType name="GETFAMILLEType"><!-- CUSTOM -->
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element ref="CODE" />
<xsd:element ref="RESPONSABLE1" />

View File

@ -485,6 +485,7 @@ def test_family_info_endpoint(app, resource):
assert set(resp.json['data'].keys()) == set(
['family_id', 'CODE', 'MEMBRE', 'RESPONSABLE1', 'RESPONSABLE2']
)
assert resp.json['data']['CODE'] == 0
assert resp.json['data']['family_id'] == 'XXX'
assert resp.json['data']['MEMBRE'][0]['id'] == '50632'
assert resp.json['data']['MEMBRE'][0]['text'] == 'Enfant 1 CALUIRE TEST'
@ -494,6 +495,7 @@ def test_family_info_endpoint(app, resource):
assert resp.json['data']['MEMBRE'][2]['text'] == 'Enfant 3 CALUIRE TEST'
assert resp.json['data']['MEMBRE'][3]['id'] == '59509'
assert resp.json['data']['MEMBRE'][3]['text'] == 'Enfant 5 CALUIRE TEST'
assert resp.json['data']['RESPONSABLE1']['IDENT'] == '50630'
# again - data are in cache
resp = app.get('/caluire-axel/test/family_info?NameID=yyy')