toulouse-maelis: endpoint pour faire la recherche d'usagers depuis le portail agent (#72310) #88

Merged
nroche merged 2 commits from wip/72310-parsifal-search-endpoints into main 2023-02-15 16:32:42 +01:00
4 changed files with 330 additions and 0 deletions

View File

@ -860,6 +860,42 @@ class ToulouseMaelis(BaseResource, HTTPResource):
link.delete()
return {'data': 'ok'}
@endpoint(
display_category='Famille',
description="Rechercher un dossier famille",
name='search-family',
perm='can_access',
parameters={
'q': {'description': 'Recherche en texte intégral'},
},
)
def search_family(self, request, q=None):
data = []
if q and len(q) >= 4: # speedup maelis reply

Quel est l'enjeu de ce minimum de 4 caractères ? ça ne risque pas d'être très pénible pour des recherches à 3 caractères ou moins, par exemple sur un nom de famille court ?

Quel est l'enjeu de ce minimum de 4 caractères ? ça ne risque pas d'être très pénible pour des recherches à 3 caractères ou moins, par exemple sur un nom de famille court ?
response = self.call('Family', 'readFamilyListFromFullName', fullname=q)
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

@ -0,0 +1,133 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:readFamilyListFromFullNameResponse 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:readFamilyListFromFullNameResponse>
</soap:Body>
</soap:Envelope>

View File

@ -942,6 +942,34 @@ def test_read_child_person_list_not_exists_error(family_service, con, app):
assert resp.json['err_desc'] == "no '42' child on '1312' family"
def test_search_family(family_service, con, app):
family_service.add_soap_response(
'readFamilyListFromFullName', get_xml_file('R_read_family_list_from_full_name.xml')
)
url = get_endpoint('search-family')
resp = app.get(url + '?q=marge%20simpson')
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'] == []
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']
)