toulouse-maelis: add get-family-id endpoint (#87561)
gitea/passerelle/pipeline/head This commit looks good
Details
gitea/passerelle/pipeline/head This commit looks good
Details
This commit is contained in:
parent
47f925d62c
commit
5f86102711
|
@ -1351,6 +1351,24 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
)
|
||||
return {'data': data}
|
||||
|
||||
@endpoint(
|
||||
display_category='Famille',
|
||||
description='Obtenir un numéro de dossier famille',
|
||||
name='get-family-id',
|
||||
parameters={
|
||||
'NameID': {'description': 'Publik NameID'},
|
||||
'family_id': {'description': 'Numéro de DUI'},
|
||||
},
|
||||
)
|
||||
def get_family_id(self, request, NameID=None, family_id=None):
|
||||
if NameID and family_id:
|
||||
raise APIError('NameID and family_id both provided')
|
||||
try:
|
||||
family_id = family_id or self.get_link(NameID).family_id
|
||||
except APIError:
|
||||
return {'data': None}
|
||||
return {'data': family_id}
|
||||
|
||||
@endpoint(
|
||||
display_category='Famille',
|
||||
description='Rechercher un dossier famille',
|
||||
|
|
|
@ -895,6 +895,32 @@ def test_get_link_list_service_error(con, app, freezer):
|
|||
]
|
||||
|
||||
|
||||
def test_get_family_id(con, app):
|
||||
url = get_endpoint('get-family-id')
|
||||
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
||||
|
||||
# NameID is provided on front-office acces
|
||||
resp = app.get(url + '?NameID=local')
|
||||
assert resp.json['err'] == 0
|
||||
assert resp.json['data'] == '1312'
|
||||
|
||||
# family_id is provided on back-office acces
|
||||
resp = app.get(url + '?family_id=1312')
|
||||
assert resp.json['err'] == 0
|
||||
assert resp.json['data'] == '1312'
|
||||
|
||||
# error from front-office
|
||||
resp = app.get(url + '?NameID=plop')
|
||||
assert resp.json['err'] == 0
|
||||
assert resp.json['data'] is None
|
||||
|
||||
# error by providing the 2 parameters :
|
||||
# we cannot stat from which portal the call come from
|
||||
resp = app.get(url + '?NameID=local&family_id=42')
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['err_desc'] == 'NameID and family_id both provided'
|
||||
|
||||
|
||||
def test_get_referential(con):
|
||||
assert con.get_referential('Category') == [
|
||||
{'code': 'BI', 'id': 'BI', 'libelle': 'BIPARENTALE', 'text': 'BIPARENTALE'},
|
||||
|
|
Loading…
Reference in New Issue