toulouse-maelis: add limit paramter to search family endpoint (#76461) #194
|
@ -1047,13 +1047,21 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
perm='can_access',
|
||||
parameters={
|
||||
'q': {'description': 'Recherche en texte intégral'},
|
||||
'limit': {'description': 'Nombre maximal de résultats.'},
|
||||
},
|
||||
)
|
||||
def search_family(self, request, q=None):
|
||||
def search_family(self, request, q=None, limit=None):
|
||||
data = []
|
||||
if limit:
|
||||
try:
|
||||
limit = int(limit)
|
||||
except ValueError:
|
||||
raise APIError('invalid limit parameter')
|
||||
if q and len(q) >= 4: # speedup maelis reply
|
||||
response = self.call('Family', 'readFamilyListFromFullName', fullname=q)
|
||||
data = serialize_object(response)
|
||||
if limit:
|
||||
data = data[:limit]
|
||||
return {'data': data}
|
||||
|
||||
@endpoint(
|
||||
|
|
|
@ -128,6 +128,133 @@
|
|||
</paiInfoBean>
|
||||
</childList>
|
||||
</familyBeanList>
|
||||
<familyBeanList>
|
||||
<number>322411</number>
|
||||
<category>BI</category>
|
||||
<situation>MARI</situation>
|
||||
<flagCom>true</flagCom>
|
||||
<RL1>
|
||||
<num>261484</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>
|
||||
|
|
|
@ -1305,12 +1305,19 @@ def test_search_family(family_service, con, app):
|
|||
|
||||
resp = app.get(url + '?q=marge%20simpson')
|
||||
assert resp.json['err'] == 0
|
||||
assert len(resp.json['data']) == 2
|
||||
|
||||
resp = app.get(url + '?q=marge%20simpson&limit=1')
|
||||
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'] == []
|
||||
|
||||
resp = app.get(url + '?q=marge%20simpson&limit=xxx')
|
||||
assert resp.json['err'] == 1
|
||||
|
||||
|
||||
def test_search_family_dui(family_service, con, app):
|
||||
family_service.add_soap_response('readFamilyList', get_xml_file('R_read_family_list.xml'))
|
||||
|
|
Loading…
Reference in New Issue