toulouse_axel: fix pre process when IDPERSONNE key is missing (#39192)

This commit is contained in:
Lauréline Guérin 2020-01-23 09:49:29 +01:00
parent 75e3f6407e
commit c23895a898
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 7 additions and 1 deletions

View File

@ -567,7 +567,7 @@ class ToulouseAxel(BaseResource):
children_by_index = {}
for i, child in enumerate(post_data.get('ENFANT', [])):
# check if IDPERSONNE is filled
if child['IDPERSONNE']:
if child.get('IDPERSONNE'):
children[child['IDPERSONNE']] = child
children_by_index[str(i)] = child['IDPERSONNE']
post_data['ENFANT'] = children

View File

@ -886,6 +886,12 @@ def test_pre_sanitize_update_family_data_enfant_n(app, resource, update_params):
resource.pre_sanitize_update_family_data(post_data=partial_update_params)
assert len(partial_update_params['ENFANT']) == 2
# missing IDPERSONNE
partial_update_params = copy.deepcopy(update_params)
partial_update_params['ENFANT'][0].pop('IDPERSONNE')
resource.pre_sanitize_update_family_data(post_data=partial_update_params)
assert len(partial_update_params['ENFANT']) == 1
def test_pre_sanitize_update_family_data_enfant_n_assurance(app, resource, update_params):
Link.objects.create(resource=resource, name_id='yyy', dui='XXX', person_id='42')