0001-toulouse_maelis-adapt-updateFamily-error-format-6779.patch
passerelle/contrib/toulouse_maelis/models.py | ||
---|---|---|
450 | 450 |
) |
451 | 451 |
def update_family(self, request, NameID, post_data): |
452 | 452 |
family_id = self.get_link(NameID).family_id |
453 | 453 |
self.replace_null_values(post_data) |
454 | 454 | |
455 | 455 |
response = self.call('Family', 'updateFamily', dossierNumber=family_id, **post_data) |
456 | 456 |
data = serialize_object(response) |
457 | 457 |
family_id = data.get('number') |
458 |
if not family_id:
|
|
459 |
errors = data.get('rl1ErrorList') + data.get('childErrorList')
|
|
458 |
errors = data.get('childErrorList')
|
|
459 |
if errors:
|
|
460 | 460 |
err_codes = [x.split(':')[0][:4] for x in errors] |
461 | 461 |
raise APIError(' ; '.join(errors), err_code=', '.join(err_codes)) |
462 | 462 |
return {'data': data} |
463 | 463 | |
464 | 464 |
@endpoint( |
465 | 465 |
display_category='Famille', |
466 | 466 |
description="Mise à jour des coordonnées d'une personne", |
467 | 467 |
name='update-coordinate', |
tests/data/toulouse_maelis/R_update_family_error.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?>
|
|
1 |
<?xml version="1.0" encoding="utf8"?> |
|
2 | 2 |
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> |
3 | 3 |
<soap:Body> |
4 | 4 |
<ns2:updateFamilyResponse xmlns:ns2="family.ws.maelis.sigec.com"> |
5 | 5 |
<familyResult> |
6 |
<number>0</number> |
|
6 |
<number>196569</number> |
|
7 |
<category>BI</category> |
|
8 |
<situation>C</situation> |
|
9 |
<flagCom>true</flagCom> |
|
7 | 10 |
<RL1> |
11 |
<num>614061</num> |
|
12 |
<lastname>DOEE</lastname> |
|
13 |
<firstname>JHON</firstname> |
|
14 |
<quality>AU</quality> |
|
15 |
<civility>MR</civility> |
|
16 |
<dateBirth>1938-07-26T00:00:00+01:00</dateBirth> |
|
8 | 17 |
<adresse> |
9 | 18 |
<idStreet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> |
19 |
<num>0</num> |
|
20 |
<street1>Chateau</street1> |
|
21 |
<town>Paris</town> |
|
22 |
<zipcode>75014</zipcode> |
|
10 | 23 |
</adresse> |
24 |
<contact> |
|
25 |
<isContactMail>false</isContactMail> |
|
26 |
<isContactSms>false</isContactSms> |
|
27 |
<isInvoicePdf>false</isInvoicePdf> |
|
28 |
</contact> |
|
11 | 29 |
</RL1> |
30 |
<RL2> |
|
31 |
<num>614062</num> |
|
32 |
<lastname>DOE</lastname> |
|
33 |
<firstname>JANNETTE</firstname> |
|
34 |
<quality>MERE</quality> |
|
35 |
<civility>MR</civility> |
|
36 |
<dateBirth>1940-06-22T00:00:00+02:00</dateBirth> |
|
37 |
<adresse> |
|
38 |
<idStreet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> |
|
39 |
<num>0</num> |
|
40 |
<street1>Chateau</street1> |
|
41 |
<town>Paris</town> |
|
42 |
<zipcode>75014</zipcode> |
|
43 |
</adresse> |
|
44 |
<contact> |
|
45 |
<isContactMail>false</isContactMail> |
|
46 |
<isContactSms>false</isContactSms> |
|
47 |
<isInvoicePdf>false</isInvoicePdf> |
|
48 |
</contact> |
|
49 |
</RL2> |
|
12 | 50 |
<childErrorList>E65a : Il existe déjà un enfant correspondant au nom [ZIMMERMAN], prénom [ROBERT], date de naissance [24/05/1941] - Personne n°[614051] - Famille n°[196544]</childErrorList> |
13 | 51 |
</familyResult> |
14 | 52 |
</ns2:updateFamilyResponse> |
15 | 53 |
</soap:Body> |
16 | 54 |
</soap:Envelope> |
tests/test_toulouse_maelis.py | ||
---|---|---|
956 | 956 |
'childList/0/lastname': 'Zimmerman', |
957 | 957 |
'childList/0/firstname': 'Robert', |
958 | 958 |
'childList/0/sexe': 'M', |
959 | 959 |
'childList/0/birth/dateBirth': '1941-05-24', |
960 | 960 |
'childList/0/birth/place': 'Duluth', |
961 | 961 |
} |
962 | 962 | |
963 | 963 |
Link.objects.create(resource=con, family_id='1312', name_id='local') |
964 |
# get 500 because error repsonse is wrongly formatted |
|
965 |
resp = app.post_json(url + '?NameID=local', params=params, status=500) |
|
966 |
assert resp.json == { |
|
967 |
'err': 1, |
|
968 |
'err_class': 'zeep.exceptions.XMLParseError', |
|
969 |
'err_desc': "Unexpected element 'adresse', expected 'lastname'", |
|
970 |
'data': None, |
|
971 |
} |
|
964 |
resp = app.post_json(url + '?NameID=local', params=params) |
|
965 |
assert resp.json['err'] == 'E65a' |
|
966 |
assert "E65a : Il existe déjà un enfant" in resp.json['err_desc'] |
|
972 | 967 | |
973 | 968 | |
974 | 969 |
@mock.patch('passerelle.utils.Request.get') |
975 | 970 |
@mock.patch('passerelle.utils.Request.post') |
976 | 971 |
def test_update_family_soap_error(mocked_post, mocked_get, con, app): |
977 | 972 |
mocked_get.return_value = FAMILY_SERVICE_WSDL |
978 | 973 |
mocked_post.return_value = UPDATE_FAMILY_500 |
979 | 974 |
url = get_endpoint('update-family') |
980 |
- |