Projet

Général

Profil

0001-toulouse_axel-fix-pre-process-when-IDPERSONNE-key-is.patch

Lauréline Guérin, 23 janvier 2020 09:50

Télécharger (1,93 ko)

Voir les différences:

Subject: [PATCH] toulouse_axel: fix pre process when IDPERSONNE key is missing
 (#39192)

 passerelle/contrib/toulouse_axel/models.py | 2 +-
 tests/test_toulouse_axel.py                | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)
passerelle/contrib/toulouse_axel/models.py
567 567
        children_by_index = {}
568 568
        for i, child in enumerate(post_data.get('ENFANT', [])):
569 569
            # check if IDPERSONNE is filled
570
            if child['IDPERSONNE']:
570
            if child.get('IDPERSONNE'):
571 571
                children[child['IDPERSONNE']] = child
572 572
                children_by_index[str(i)] = child['IDPERSONNE']
573 573
        post_data['ENFANT'] = children
tests/test_toulouse_axel.py
886 886
    resource.pre_sanitize_update_family_data(post_data=partial_update_params)
887 887
    assert len(partial_update_params['ENFANT']) == 2
888 888

  
889
    # missing IDPERSONNE
890
    partial_update_params = copy.deepcopy(update_params)
891
    partial_update_params['ENFANT'][0].pop('IDPERSONNE')
892
    resource.pre_sanitize_update_family_data(post_data=partial_update_params)
893
    assert len(partial_update_params['ENFANT']) == 1
894

  
889 895

  
890 896
def test_pre_sanitize_update_family_data_enfant_n_assurance(app, resource, update_params):
891 897
    Link.objects.create(resource=resource, name_id='yyy', dui='XXX', person_id='42')
892
-