toulouse_axel: add id, text to each contact (#39799)
This commit is contained in:
parent
6c4f8ae999
commit
3338accbfe
|
@ -483,6 +483,9 @@ class ToulouseAxel(BaseResource):
|
|||
for child in family_data.get('ENFANT', []):
|
||||
child['id'] = child['IDPERSONNE']
|
||||
child['text'] = '{} {}'.format(child['PRENOM'], child['NOM']).strip()
|
||||
for i, contact in enumerate(child.get('CONTACT', [])):
|
||||
contact['id'] = i
|
||||
contact['text'] = '{} {}'.format(contact['PRENOM'], contact['NOM']).strip()
|
||||
return family_data
|
||||
|
||||
@endpoint(
|
||||
|
|
|
@ -665,6 +665,12 @@ def test_family_info_endpoint(app, resource):
|
|||
])
|
||||
assert resp.json['data']['ENFANT'][0]['id'] == '4242'
|
||||
assert resp.json['data']['ENFANT'][0]['text'] == 'foo foo'
|
||||
assert resp.json['data']['ENFANT'][0]['CONTACT'][0]['id'] == 0
|
||||
assert resp.json['data']['ENFANT'][0]['CONTACT'][0]['text'] == 'foo foo'
|
||||
assert resp.json['data']['ENFANT'][0]['CONTACT'][1]['id'] == 1
|
||||
assert resp.json['data']['ENFANT'][0]['CONTACT'][1]['text'] == 'foo foo'
|
||||
assert resp.json['data']['ENFANT'][0]['CONTACT'][2]['id'] == 2
|
||||
assert resp.json['data']['ENFANT'][0]['CONTACT'][2]['text'] == 'foo foo'
|
||||
assert resp.json['data']['ENFANT'][1]['id'] == '3535'
|
||||
assert resp.json['data']['ENFANT'][1]['text'] == 'foo foo'
|
||||
|
||||
|
@ -715,6 +721,12 @@ def test_children_info_endpoint(app, resource):
|
|||
assert len(resp.json['data']) == 2
|
||||
assert resp.json['data'][0]['id'] == '4242'
|
||||
assert resp.json['data'][0]['text'] == 'foo foo'
|
||||
assert resp.json['data'][0]['CONTACT'][0]['id'] == 0
|
||||
assert resp.json['data'][0]['CONTACT'][0]['text'] == 'foo foo'
|
||||
assert resp.json['data'][0]['CONTACT'][1]['id'] == 1
|
||||
assert resp.json['data'][0]['CONTACT'][1]['text'] == 'foo foo'
|
||||
assert resp.json['data'][0]['CONTACT'][2]['id'] == 2
|
||||
assert resp.json['data'][0]['CONTACT'][2]['text'] == 'foo foo'
|
||||
assert resp.json['data'][1]['id'] == '3535'
|
||||
assert resp.json['data'][1]['text'] == 'foo foo'
|
||||
|
||||
|
@ -772,6 +784,12 @@ def test_child_info_endpoint(app, resource):
|
|||
])
|
||||
assert resp.json['data']['id'] == '4242'
|
||||
assert resp.json['data']['text'] == 'foo foo'
|
||||
assert resp.json['data']['CONTACT'][0]['id'] == 0
|
||||
assert resp.json['data']['CONTACT'][0]['text'] == 'foo foo'
|
||||
assert resp.json['data']['CONTACT'][1]['id'] == 1
|
||||
assert resp.json['data']['CONTACT'][1]['text'] == 'foo foo'
|
||||
assert resp.json['data']['CONTACT'][2]['id'] == 2
|
||||
assert resp.json['data']['CONTACT'][2]['text'] == 'foo foo'
|
||||
|
||||
with mock.patch('passerelle.contrib.toulouse_axel.models.ToulouseAxel.are_children_registered') as registered:
|
||||
registered.side_effect = [{'4242': True}, {}]
|
||||
|
|
Loading…
Reference in New Issue