toulouse-maelis: add endpoint to search family by id (#72310)
gitea/passerelle/pipeline/pr-main This commit looks good Details
gitea/passerelle/pipeline/head Something is wrong with the build of this commit Details

This commit is contained in:
Nicolas Roche 2023-02-04 19:00:02 +01:00 committed by Gitea
parent a3e9a8c4e7
commit ab55213ed7
3 changed files with 166 additions and 0 deletions

View File

@ -876,6 +876,26 @@ class ToulouseMaelis(BaseResource, HTTPResource):
data = serialize_object(response)
return {'data': data}
@endpoint(
display_category='Famille',
description="Rechercher un dossier famille par son numéro de DUI",
name='search-family-dui',
perm='can_access',
parameters={
'q': {'description': 'Numéro de DUI'},
},
)
def search_family_dui(self, request, q=None):
data = []
if q:
try:
response = self.call('Family', 'readFamilyList', dossierNumber=q)
except APIError:
pass
else:
data = serialize_object(response)
return {'data': data}
@endpoint(
display_category='Famille',
description='Obtenir les informations sur la famille',

View File

@ -0,0 +1,133 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:readFamilyListResponse xmlns:ns2="family.ws.maelis.sigec.com">
<familyBeanList>
<number>322411</number>
<category>BI</category>
<situation>MARI</situation>
<flagCom>true</flagCom>
<RL1>
<num>261483</num>
<firstname>MARGE</firstname>
<lastname>SIMPSON</lastname>
<maidenName>BOUVIER</maidenName>
<quality>MERE</quality>
<civility>MME</civility>
<birth>
<dateBirth>1950-10-01T00:00:00+01:00</dateBirth>
</birth>
<adresse>
<idStreet>2317</idStreet>
<num>4</num>
<street1>RUE ACHILLE VIADIEU</street1>
<town>Springfield</town>
<zipcode>62701</zipcode>
</adresse>
<contact>
<isContactMail>false</isContactMail>
<isContactSms>false</isContactSms>
<isInvoicePdf>false</isInvoicePdf>
</contact>
</RL1>
<RL2>
<num>261484</num>
<firstname>HOMER</firstname>
<lastname>SIMPSON</lastname>
<quality>PERE</quality>
<civility>MR</civility>
<birth>
<dateBirth>1956-05-12T00:00:00+01:00</dateBirth>
</birth>
<adresse>
<idStreet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<num>742</num>
<street1>Evergreen Terrace</street1>
<town>Springfield</town>
<zipcode>90701</zipcode>
</adresse>
<contact>
<phone>0122222222</phone>
<mobile>0622222222</mobile>
<mail>homer.simpson@example.org.com</mail>
<isContactMail>true</isContactMail>
<isContactSms>true</isContactSms>
<isInvoicePdf>true</isInvoicePdf>
</contact>
<profession>
<codeCSP>46</codeCSP>
<profession>Inspecteur de sécurité</profession>
<employerName>Burns</employerName>
<phone>0133333333</phone>
<addressPro>
<zipcode>90701</zipcode>
<town>Springfield</town>
</addressPro>
</profession>
<CAFInfo>
<number>123</number>
<organ>GENE</organ>
</CAFInfo>
</RL2>
<childList>
<num>261485</num>
<lastname>SIMPSON</lastname>
<firstname>BART</firstname>
<sexe>M</sexe>
<birth>
<dateBirth>2014-04-01T00:00:00+02:00</dateBirth>
</birth>
<bPhoto>true</bPhoto>
<bLeaveAlone>true</bLeaveAlone>
<paiInfoBean>
<code>PAI_01</code>
<dateDeb>2022-09-01T00:00:00+02:00</dateDeb>
<dateFin>2023-07-01T00:00:00+02:00</dateFin>
<description>mischievous, rebellious, misunderstood, disruptive</description>
</paiInfoBean>
</childList>
<childList>
<num>261488</num>
<lastname>SIMPSON</lastname>
<firstname>LISA</firstname>
<sexe>F</sexe>
<birth>
<dateBirth>2016-05-09T00:00:00+02:00</dateBirth>
</birth>
<bPhoto>false</bPhoto>
<bLeaveAlone>false</bLeaveAlone>
<paiInfoBean>
<code>PAI_02</code>
</paiInfoBean>
</childList>
<childList>
<num>261489</num>
<lastname>SIMPSON</lastname>
<firstname>MAGGIE</firstname>
<sexe>F</sexe>
<birth>
<dateBirth>2018-12-17T00:00:00+01:00</dateBirth>
</birth>
<bPhoto>false</bPhoto>
<bLeaveAlone>false</bLeaveAlone>
<paiInfoBean>
<code>PAI_02</code>
</paiInfoBean>
</childList>
<childList>
<num>261490</num>
<lastname>SIMPSON</lastname>
<firstname>HUGO</firstname>
<sexe>M</sexe>
<birth>
<dateBirth>2018-04-01T00:00:00+02:00</dateBirth>
</birth>
<bPhoto>false</bPhoto>
<bLeaveAlone>false</bLeaveAlone>
<paiInfoBean>
<code>PAI_01</code>
</paiInfoBean>
</childList>
</familyBeanList>
</ns2:readFamilyListResponse>
</soap:Body>
</soap:Envelope>

View File

@ -957,6 +957,19 @@ def test_search_family(family_service, con, app):
assert resp.json['data'] == []
def test_search_family_dui(family_service, con, app):
family_service.add_soap_response('readFamilyList', get_xml_file('R_read_family_list.xml'))
url = get_endpoint('search-family-dui')
resp = app.get(url + '?q=1312')
assert resp.json['err'] == 0
assert len(resp.json['data']) == 1
resp = app.get(url + '?q=')
assert resp.json['err'] == 0
assert resp.json['data'] == []
@pytest.mark.parametrize(
"xml", ['R_read_family.xml', 'R_read_family_relax.xml', 'R_read_family_reordered.xml']
)