caluire-axel: allow individual with no family (#55684)

This commit is contained in:
Nicolas Roche 2021-07-20 09:27:18 +02:00
parent bdda53e495
commit 1bcc9cf07d
2 changed files with 25 additions and 1 deletions

View File

@ -74,7 +74,7 @@ class CaluireAxel(BaseResource):
)
data = result.json_response['DATA']['PORTAIL']['FINDINDIVIDUS']
for individu in data.get('INDIVIDU') or []:
for famille in individu['FAMILLE']:
for famille in individu.get('FAMILLE') or []:
if famille['IDENTFAMILLE'] == family_id:
place = famille['PLACE']
if place not in ['1', '2']:

View File

@ -443,6 +443,30 @@ def test_link_endpoint(app, resource, link_params, place):
assert 'xml_response' in resp.json['data']
def test_link_endpoint_having_homonyme_with_empty_familly(app, resource, link_params):
content = """<PORTAIL><FINDINDIVIDUS>
<CODE>42</CODE>
<INDIVIDU>
<IDENT>123</IDENT>
<CIVILITE/><NOM>A</NOM><PRENOM/><NAISSANCE/><SEXE/><NOMJF/><TELFIXE/><TELPORTABLE/><MAIL/><CSP/><EMPLOYEUR/><VILLEEMP/><PAI>N</PAI><GARDEALTERNEE/>
</INDIVIDU>
<INDIVIDU>
<IDENT>456</IDENT>
<CIVILITE/><NOM>A</NOM><PRENOM/><NAISSANCE/><SEXE/><NOMJF/><TELFIXE/><TELPORTABLE/><MAIL/><CSP/><EMPLOYEUR/><VILLEEMP/><PAI>N</PAI><GARDEALTERNEE/>
<FAMILLE>
<IDENTFAMILLE>12345</IDENTFAMILLE>
<PLACE>2</PLACE>
<SITUATION/>
</FAMILLE>
</INDIVIDU>
</FINDINDIVIDUS></PORTAIL>"""
with mock_data(content, 'FindIndividus'):
resp = app.post_json('/caluire-axel/test/link?NameID=yyy', params=link_params)
assert resp.json['err'] == 0
assert resp.json['family_id'] == '12345'
assert resp.json['created'] is True
def test_unlink_endpoint_no_result(app, resource):
resp = app.post('/caluire-axel/test/unlink?NameID=yyy')
assert resp.json['err_desc'] == "Person not found"