0001-toulouse-maelis-add-endpoint-to-create-or-update-quo.patch
functests/toulouse_maelis/conftest.py | ||
---|---|---|
284 | 284 |
remove_id_on_child(child) |
285 | 285 |
if not key: |
286 | 286 |
assert diff(child, expected_file) |
287 | 287 |
else: |
288 | 288 |
assert diff(child[key], expected_file) |
289 | 289 |
return data |
290 | 290 | |
291 | 291 | |
292 |
def diff_rlg(conn, name_id, index, expected_file): |
|
292 |
def diff_rlg(conn, name_id, index, expected_file, key=None):
|
|
293 | 293 |
data = read_family(conn, name_id) |
294 | 294 |
rlg = copy.deepcopy(data['RL%s' % index]) |
295 | 295 |
remove_id_on_rlg(rlg) |
296 |
assert diff(rlg, expected_file) |
|
296 |
if not key: |
|
297 |
assert diff(rlg, expected_file) |
|
298 |
else: |
|
299 |
assert diff(rlg[key], expected_file) |
|
297 | 300 |
return data |
298 | 301 | |
299 | 302 | |
300 | 303 |
def diff_family(conn, name_id, expected_file, key=None): |
301 | 304 |
data = read_family(conn, name_id) |
302 | 305 |
family = copy.deepcopy(data) |
303 | 306 |
remove_id_on_family(family) |
304 | 307 |
if not key: |
... | ... | |
346 | 349 |
assert create_result['err'] == 0 |
347 | 350 |
print('\ncreate DUI: %s' % str(create_result['data']['number'])) |
348 | 351 |
data = diff_family(conn, name_id, 'test_create_family.json') |
349 | 352 | |
350 | 353 |
return { |
351 | 354 |
'name_id': name_id, # linked |
352 | 355 |
'family_id': str(create_result['data']['number']), |
353 | 356 |
'lastname': lastname, |
357 |
'rl1_num': data['RL1']['num'], |
|
354 | 358 |
'family_payload': create_family_payload, |
355 | 359 |
'data': data, |
356 | 360 |
} |
357 | 361 | |
358 | 362 | |
359 | 363 |
@pytest.fixture(scope='session') |
360 | 364 |
def update_data(request, conn, referentials): |
361 | 365 |
name_id = request.config.getoption('--nameid') |
functests/toulouse_maelis/data/test_update_quotient.json | ||
---|---|---|
1 |
[ |
|
2 |
{ |
|
3 |
"yearRev": 2021, |
|
4 |
"dateStart": "2022-01-02T00:00:00+01:00", |
|
5 |
"dateEnd": "2022-12-31T00:00:00+01:00", |
|
6 |
"mtt": 1500.33, |
|
7 |
"cdquo": "QS", |
|
8 |
"codeUti": null, |
|
9 |
"cdquo_text": "QUOTIENT SCOLAIRE" |
|
10 |
}, |
|
11 |
{ |
|
12 |
"yearRev": 2020, |
|
13 |
"dateStart": "2022-01-02T00:00:00+01:00", |
|
14 |
"dateEnd": "2022-12-31T00:00:00+01:00", |
|
15 |
"mtt": 1500.33, |
|
16 |
"cdquo": "QS", |
|
17 |
"codeUti": null, |
|
18 |
"cdquo_text": "QUOTIENT SCOLAIRE" |
|
19 |
}, |
|
20 |
{ |
|
21 |
"yearRev": 2021, |
|
22 |
"dateStart": "2022-01-01T00:00:00+01:00", |
|
23 |
"dateEnd": "2022-01-01T00:00:00+01:00", |
|
24 |
"mtt": 1500.33, |
|
25 |
"cdquo": "QS", |
|
26 |
"codeUti": null, |
|
27 |
"cdquo_text": "QUOTIENT SCOLAIRE" |
|
28 |
} |
|
29 |
] |
functests/toulouse_maelis/test_family.py | ||
---|---|---|
679 | 679 |
update_data['bart_num'], |
680 | 680 |
abi_num, |
681 | 681 |
) |
682 | 682 |
payload = update_data['family_payload']['childList'][0]['authorizedPersonList'][0] |
683 | 683 |
resp = requests.post(url, json=payload) |
684 | 684 |
resp.raise_for_status() |
685 | 685 |
assert resp.json()['err'] == 0 |
686 | 686 |
assert diff_family(conn, update_data['name_id'], 'test_update_family.json') |
687 | ||
688 | ||
689 |
def test_update_quotient(conn, create_data): |
|
690 |
unlink(conn, create_data['name_id']) |
|
691 |
link(conn, create_data) |
|
692 | ||
693 |
# add quotient |
|
694 |
url = conn + '/update-quotient?NameID=%s&rl_id=%s' % (create_data['name_id'], create_data['rl1_num']) |
|
695 |
payload = { |
|
696 |
'yearRev': '2021', |
|
697 |
'dateStart': '2022-01-01', |
|
698 |
'dateEnd': '2022-12-31', |
|
699 |
'mtt': '1500.33', |
|
700 |
'cdquo': 'QS', |
|
701 |
} |
|
702 |
resp = requests.post(url, json=payload) |
|
703 |
resp.raise_for_status() |
|
704 |
assert resp.json()['err'] == 0 |
|
705 |
data = read_family(conn, create_data['name_id']) |
|
706 |
assert data['RL1']['quotientList'] == [ |
|
707 |
{ |
|
708 |
'yearRev': 2021, |
|
709 |
'dateStart': '2022-01-01T00:00:00+01:00', |
|
710 |
'dateEnd': '2022-12-31T00:00:00+01:00', |
|
711 |
'mtt': 1500.33, |
|
712 |
'cdquo': 'QS', |
|
713 |
'codeUti': None, |
|
714 |
'cdquo_text': 'QUOTIENT SCOLAIRE', |
|
715 |
} |
|
716 |
] |
|
717 | ||
718 |
# add quotient |
|
719 |
payload['dateStart'] = '2022-01-02' |
|
720 |
resp = requests.post(url, json=payload) |
|
721 |
resp.raise_for_status() |
|
722 |
assert resp.json()['err'] == 0 |
|
723 |
data = read_family(conn, create_data['name_id']) |
|
724 |
assert len(data['RL1']['quotientList']) == 2 |
|
725 | ||
726 |
# add quotient on another income year |
|
727 |
payload['yearRev'] = '2020' |
|
728 |
resp = requests.post(url, json=payload) |
|
729 |
resp.raise_for_status() |
|
730 |
assert resp.json()['err'] == 0 |
|
731 |
data = diff_rlg(conn, create_data['name_id'], 1, 'test_update_quotient.json', 'quotientList') |
|
732 |
assert len(data['RL1']['quotientList']) == 3 |
passerelle/contrib/toulouse_maelis/models.py | ||
---|---|---|
255 | 255 |
self.add_text_value('Sex', data, ['sexe']) |
256 | 256 | |
257 | 257 |
def add_text_value_to_rl(self, data): |
258 | 258 |
self.add_text_value('Civility', data, ['civility']) |
259 | 259 |
self.add_text_value('Quality', data, ['quality']) |
260 | 260 |
self.add_text_value('Complement', data, ['adresse', 'numComp']) |
261 | 261 |
self.add_text_value('CSP', data, ['profession', 'codeCSP']) |
262 | 262 |
self.add_text_value('Organ', data, ['CAFInfo', 'organ']) |
263 |
for quotient in data['quotientList']: |
|
264 |
self.add_text_value('Quotient', quotient, ['cdquo']) |
|
263 | 265 | |
264 | 266 |
def add_text_value_to_family(self, data): |
265 | 267 |
self.add_text_value('Category', data, ['category']) |
266 | 268 |
self.add_text_value('Situation', data, ['situation']) |
267 | 269 |
for rlg in 'RL1', 'RL2': |
268 | 270 |
if data.get(rlg): |
269 | 271 |
self.add_text_value_to_rl(data[rlg]) |
270 | 272 |
for child in data['childList']: |
... | ... | |
1028 | 1030 |
def update_coordinate(self, request, NameID, rl_id, post_data): |
1029 | 1031 |
family_id = self.get_link(NameID).family_id |
1030 | 1032 |
self.assert_update_coordinate_payload_in_referential(post_data) |
1031 | 1033 |
self.replace_null_values(post_data) |
1032 | 1034 | |
1033 | 1035 |
self.call('Family', 'updateCoordinate', numDossier=family_id, numPerson=rl_id, **post_data) |
1034 | 1036 |
return {'data': 'ok'} |
1035 | 1037 | |
1038 |
@endpoint( |
|
1039 |
display_category='Famille', |
|
1040 |
description="Créer ou mettre à jour un quotient d'un responsable légal", |
|
1041 |
name='update-quotient', |
|
1042 |
perm='can_access', |
|
1043 |
parameters={ |
|
1044 |
'NameID': {'description': 'Publik NameID'}, |
|
1045 |
'rl_id': {'description': "Numéro du responsable légal"}, |
|
1046 |
}, |
|
1047 |
post={'request_body': {'schema': {'application/json': schemas.UPDATE_QUOTIENT_SCHEMA}}}, |
|
1048 |
) |
|
1049 |
def update_quotient(self, request, NameID, rl_id, post_data): |
|
1050 |
family_id = self.get_link(NameID).family_id |
|
1051 |
self.assert_post_data_in_referential('Quotient', post_data, ['cdquo']) |
|
1052 | ||
1053 |
payload = { |
|
1054 |
'dossierNumber': family_id, |
|
1055 |
'personNumber': rl_id, |
|
1056 |
'quotient': post_data, |
|
1057 |
} |
|
1058 |
self.call('Family', 'createUpdateQuotient', **payload) |
|
1059 |
return {'data': 'ok'} |
|
1060 | ||
1036 | 1061 |
@endpoint( |
1037 | 1062 |
display_category='Famille', |
1038 | 1063 |
description="Création d'une personne à prévenir en cas d'urgence", |
1039 | 1064 |
name='create-person', |
1040 | 1065 |
perm='can_access', |
1041 | 1066 |
parameters={ |
1042 | 1067 |
'NameID': {'description': 'Publik NameID'}, |
1043 | 1068 |
}, |
passerelle/contrib/toulouse_maelis/schemas.py | ||
---|---|---|
650 | 650 |
'adresse': ADDRESS_SCHEMA, |
651 | 651 |
'contact': {'oneOf': [CONTACT_SCHEMA, {'type': 'null'}]}, |
652 | 652 |
'profession': {'oneOf': [PROFESSION_SCHEMA, {'type': 'null'}]}, |
653 | 653 |
'CAFInfo': {'oneOf': [CAFINFO_SCHEMA, {'type': 'null'}]}, |
654 | 654 |
}, |
655 | 655 |
'unflatten': True, |
656 | 656 |
'additionalProperties': False, |
657 | 657 |
} |
658 | ||
659 |
UPDATE_QUOTIENT_SCHEMA = { |
|
660 |
'$schema': 'http://json-schema.org/draft-04/schema#', |
|
661 |
'title': 'Family persons', |
|
662 |
'description': "Informations sur les personnes autorisées à venir chercher l'enfant avec leur qualité", |
|
663 |
'type': 'object', |
|
664 |
'required': ['yearRev', 'dateStart', 'dateEnd', 'mtt', 'cdquo'], |
|
665 |
'properties': { |
|
666 |
'yearRev': { |
|
667 |
'description': 'Année de revenu', |
|
668 |
'type': 'string', |
|
669 |
'pattern': '^[0-9]{4}$', |
|
670 |
}, |
|
671 |
'dateStart': { |
|
672 |
'description': 'Date de début', |
|
673 |
'type': 'string', |
|
674 |
'pattern': '^[0-9]{4}-[0-9]{2}-[0-9]{2}$', |
|
675 |
}, |
|
676 |
'dateEnd': { |
|
677 |
'description': 'Date de fin', |
|
678 |
'type': 'string', |
|
679 |
'pattern': '^[0-9]{4}-[0-9]{2}-[0-9]{2}$', |
|
680 |
}, |
|
681 |
'mtt': { |
|
682 |
'description': 'Montant', |
|
683 |
'type': 'string', |
|
684 |
'pattern': r'^[0-9]+\.?[0-9]*$', |
|
685 |
}, |
|
686 |
'cdquo': { |
|
687 |
'description': 'Code du quotient (depuis référentiel)', |
|
688 |
'type': 'string', |
|
689 |
'pattern': '.+', |
|
690 |
}, |
|
691 |
}, |
|
692 |
'additionalProperties': False, |
|
693 |
} |
tests/data/toulouse_maelis/Q_create_update_quotient.xml | ||
---|---|---|
1 |
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"> |
|
2 |
<soap-env:Header> |
|
3 |
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> |
|
4 |
<wsse:UsernameToken> |
|
5 |
<wsse:Username>maelis-webservice</wsse:Username> |
|
6 |
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">maelis-password</wsse:Password> |
|
7 |
</wsse:UsernameToken> |
|
8 |
</wsse:Security> |
|
9 |
</soap-env:Header> |
|
10 |
<soap-env:Body> |
|
11 |
<ns0:createUpdateQuotient xmlns:ns0="family.ws.maelis.sigec.com"> |
|
12 |
<dossierNumber>1312</dossierNumber> |
|
13 |
<personNumber>613878</personNumber> |
|
14 |
<quotient> |
|
15 |
<yearRev>2021</yearRev> |
|
16 |
<dateStart>2022-10-01</dateStart> |
|
17 |
<dateEnd>2023-01-31</dateEnd> |
|
18 |
<mtt>1500.33</mtt> |
|
19 |
<cdquo>QS</cdquo> |
|
20 |
</quotient> |
|
21 |
</ns0:createUpdateQuotient> |
|
22 |
</soap-env:Body> |
|
23 |
</soap-env:Envelope> |
tests/data/toulouse_maelis/R_create_update_quotient.xml | ||
---|---|---|
1 |
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> |
|
2 |
<soap:Body> |
|
3 |
<ns2:createUpdateQuotientResponse xmlns:ns2="family.ws.maelis.sigec.com"/> |
|
4 |
</soap:Body> |
|
5 |
</soap:Envelope> |
tests/data/toulouse_maelis/R_create_update_quotient_soap_error.xml | ||
---|---|---|
1 |
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> |
|
2 |
<soap:Body> |
|
3 |
<soap:Fault> |
|
4 |
<faultcode>soap:Server</faultcode> |
|
5 |
<faultstring>E07 : Il existe déjà un quotient postérieur pour cette période</faultstring> |
|
6 |
<detail> |
|
7 |
<ns1:MaelisFamilyException xmlns:ns1="family.ws.maelis.sigec.com"> |
|
8 |
<message xmlns:ns2="family.ws.maelis.sigec.com">E07 : Il existe déjà un quotient postérieur pour cette période</message> |
|
9 |
</ns1:MaelisFamilyException> |
|
10 |
</detail> |
|
11 |
</soap:Fault> |
|
12 |
</soap:Body> |
|
13 |
</soap:Envelope> |
tests/data/toulouse_maelis/R_read_family.xml | ||
---|---|---|
31 | 31 |
<mail>djhon@example.org</mail> |
32 | 32 |
<isContactMail>true</isContactMail> |
33 | 33 |
<isContactSms>true</isContactSms> |
34 | 34 |
<isInvoicePdf>true</isInvoicePdf> |
35 | 35 |
</contact> |
36 | 36 |
<profession> |
37 | 37 |
<addressPro/> |
38 | 38 |
</profession> |
39 |
<quotientList> |
|
40 |
<yearRev>2020</yearRev> |
|
41 |
<dateStart>2021-01-01T00:00:00+01:00</dateStart> |
|
42 |
<dateEnd>2021-12-31T00:00:00+01:00</dateEnd> |
|
43 |
<mtt>1500.33</mtt> |
|
44 |
<cdquo>QS</cdquo> |
|
45 |
</quotientList> |
|
46 |
<quotientList> |
|
47 |
<yearRev>2021</yearRev> |
|
48 |
<dateStart>2022-01-01T00:00:00+01:00</dateStart> |
|
49 |
<dateEnd>2022-12-31T00:00:00+01:00</dateEnd> |
|
50 |
<mtt>1500.44</mtt> |
|
51 |
<cdquo>MOY ECO</cdquo> |
|
52 |
</quotientList> |
|
39 | 53 |
</RL1> |
40 | 54 |
<RL2> |
41 | 55 |
<num>613879</num> |
42 | 56 |
<lastname>DOE</lastname> |
43 | 57 |
<firstname>JANE</firstname> |
44 | 58 |
<maidenName>SMITH</maidenName> |
45 | 59 |
<quality>MERE</quality> |
46 | 60 |
<civility>MME</civility> |
tests/data/toulouse_maelis/R_read_family_relax.xml | ||
---|---|---|
31 | 31 |
<mail>djhon@example.org</mail> |
32 | 32 |
<isContactMail>true</isContactMail> |
33 | 33 |
<isContactSms>true</isContactSms> |
34 | 34 |
<isInvoicePdf>true</isInvoicePdf> |
35 | 35 |
</contact> |
36 | 36 |
<profession> |
37 | 37 |
<addressPro/> |
38 | 38 |
</profession> |
39 |
<quotientList> |
|
40 |
<yearRev>2020</yearRev> |
|
41 |
<dateStart>2021-01-01T00:00:00+01:00</dateStart> |
|
42 |
<dateEnd>2021-12-31T00:00:00+01:00</dateEnd> |
|
43 |
<mtt>1500.33</mtt> |
|
44 |
<cdquo>QS</cdquo> |
|
45 |
</quotientList> |
|
46 |
<quotientList> |
|
47 |
<yearRev>2021</yearRev> |
|
48 |
<dateStart>2022-01-01T00:00:00+01:00</dateStart> |
|
49 |
<dateEnd>2022-12-31T00:00:00+01:00</dateEnd> |
|
50 |
<mtt>1500.44</mtt> |
|
51 |
<cdquo>MOY ECO</cdquo> |
|
52 |
</quotientList> |
|
39 | 53 |
</RL1> |
40 | 54 |
<RL2> |
41 | 55 |
<num>613879</num> |
42 | 56 |
<lastname>DOE</lastname> |
43 | 57 |
<firstname>JANE</firstname> |
44 | 58 |
<civility>MME</civility> |
45 | 59 |
<birth> |
46 | 60 |
<dateBirth>1940-06-22T00:00:00+02:00</dateBirth> |
tests/data/toulouse_maelis/R_read_family_reordered.xml | ||
---|---|---|
31 | 31 |
<mail>djhon@example.org</mail> |
32 | 32 |
<isContactMail>true</isContactMail> |
33 | 33 |
<isContactSms>true</isContactSms> |
34 | 34 |
<isInvoicePdf>true</isInvoicePdf> |
35 | 35 |
</contact> |
36 | 36 |
<profession> |
37 | 37 |
<addressPro/> |
38 | 38 |
</profession> |
39 |
<quotientList> |
|
40 |
<yearRev>2020</yearRev> |
|
41 |
<dateStart>2021-01-01T00:00:00+01:00</dateStart> |
|
42 |
<dateEnd>2021-12-31T00:00:00+01:00</dateEnd> |
|
43 |
<mtt>1500.33</mtt> |
|
44 |
<cdquo>QS</cdquo> |
|
45 |
</quotientList> |
|
46 |
<quotientList> |
|
47 |
<yearRev>2021</yearRev> |
|
48 |
<dateStart>2022-01-01T00:00:00+01:00</dateStart> |
|
49 |
<dateEnd>2022-12-31T00:00:00+01:00</dateEnd> |
|
50 |
<mtt>1500.44</mtt> |
|
51 |
<cdquo>MOY ECO</cdquo> |
|
52 |
</quotientList> |
|
39 | 53 |
</RL1> |
40 | 54 |
<RL2> |
41 | 55 |
<num>613879</num> |
42 | 56 |
<lastname>DOE</lastname> |
43 | 57 |
<firstname>JANE</firstname> |
44 | 58 |
<quality>MERE</quality> |
45 | 59 |
<civility>MME</civility> |
46 | 60 |
<birth> |
tests/test_toulouse_maelis.py | ||
---|---|---|
53 | 53 |
) |
54 | 54 |
CREATE_FAMILY = FakedResponse(content=get_xml_file('R_create_family.xml'), status_code=200) |
55 | 55 |
CREATE_FAMILY_ERR = FakedResponse(content=get_xml_file('R_create_family_error.xml'), status_code=200) |
56 | 56 |
CREATE_CHILD = FakedResponse(content=get_xml_file('R_create_child.xml'), status_code=200) |
57 | 57 |
CREATE_CHILD_ERR = FakedResponse(content=get_xml_file('R_create_child_error.xml'), status_code=200) |
58 | 58 |
UPDATE_FAMILY = FakedResponse(content=get_xml_file('R_update_family.xml'), status_code=200) |
59 | 59 |
UPDATE_FAMILY_ERR = FakedResponse(content=get_xml_file('R_update_family_error.xml'), status_code=200) |
60 | 60 |
UPDATE_FAMILY_500 = FakedResponse(content=get_xml_file('R_update_family_soap_error.xml'), status_code=500) |
61 |
UPDATE_QUOTIENT = FakedResponse(content=get_xml_file('R_create_update_quotient.xml'), status_code=200) |
|
62 |
UPDATE_QUOTIENT_500 = FakedResponse( |
|
63 |
content=get_xml_file('R_create_update_quotient_soap_error.xml'), status_code=500 |
|
64 |
) |
|
61 | 65 |
UPDATE_DIETCODE = FakedResponse(content=get_xml_file('R_update_child_dietcode.xml'), status_code=200) |
62 | 66 |
UPDATE_PAI = FakedResponse(content=get_xml_file('R_update_child_pai.xml'), status_code=200) |
63 | 67 |
UPDATE_PAI_500 = FakedResponse(content=get_xml_file('R_update_child_pai_soap_error.xml'), status_code=500) |
64 | 68 |
UPDATE_MEDICAL = FakedResponse(content=get_xml_file('R_update_child_medical_record.xml'), status_code=200) |
65 | 69 |
UPDATE_MEDICAL_500 = FakedResponse( |
66 | 70 |
content=get_xml_file('R_update_child_medical_record_soap_error.xml'), status_code=500 |
67 | 71 |
) |
68 | 72 |
UPDATE_CHILD_AUTO = FakedResponse(content=get_xml_file('R_update_child_authorization.xml'), status_code=200) |
... | ... | |
698 | 702 |
'mail': 'djhon@example.org', |
699 | 703 |
'isContactMail': True, |
700 | 704 |
'isContactSms': True, |
701 | 705 |
'isInvoicePdf': True, |
702 | 706 |
}, |
703 | 707 |
'CAFInfo': None, |
704 | 708 |
'civility_text': 'Monsieur', |
705 | 709 |
'quality_text': 'PERE', |
706 |
'quotientList': [], |
|
710 |
'quotientList': [ |
|
711 |
{ |
|
712 |
'cdquo': 'QS', |
|
713 |
'cdquo_text': 'QUOTIENT SCOLAIRE', |
|
714 |
'codeUti': None, |
|
715 |
'dateEnd': '2021-12-31T00:00:00+01:00', |
|
716 |
'dateStart': '2021-01-01T00:00:00+01:00', |
|
717 |
'mtt': 1500.33, |
|
718 |
'yearRev': 2020, |
|
719 |
}, |
|
720 |
{ |
|
721 |
'cdquo': 'MOY ECO', |
|
722 |
'cdquo_text': 'REVENU MOYEN ( MENSUEL OU ANNUEL)', |
|
723 |
'codeUti': None, |
|
724 |
'dateEnd': '2022-12-31T00:00:00+01:00', |
|
725 |
'dateStart': '2022-01-01T00:00:00+01:00', |
|
726 |
'mtt': 1500.44, |
|
727 |
'yearRev': 2021, |
|
728 |
}, |
|
729 |
], |
|
707 | 730 |
'indicatorList': [], |
708 | 731 |
'subscribeActivityList': [], |
709 | 732 |
} |
710 | 733 |
data = resp.json['data']['childList'][0] |
711 | 734 |
del data['medicalRecord'] |
712 | 735 |
del data['authorizedPersonList'] |
713 | 736 |
del data['paiInfoBean'] |
714 | 737 |
assert data == { |
... | ... | |
2077 | 2100 |
Link.objects.create(resource=con, family_id='1312', name_id='local') |
2078 | 2101 |
resp = app.post_json(url + '?NameID=local&rl_id=613878', params=params) |
2079 | 2102 |
assert resp.json['err'] == 'wrong-key' |
2080 | 2103 |
assert ( |
2081 | 2104 |
resp.json['err_desc'] == "adresse/numComp key value 'plop' do not belong to 'Complement' referential" |
2082 | 2105 |
) |
2083 | 2106 | |
2084 | 2107 | |
2108 |
@mock.patch('passerelle.utils.Request.get') |
|
2109 |
@mock.patch('passerelle.utils.Request.post') |
|
2110 |
def test_update_quotient(mocked_post, mocked_get, con, app): |
|
2111 |
mocked_get.return_value = FAMILY_SERVICE_WSDL |
|
2112 |
mocked_post.return_value = UPDATE_QUOTIENT |
|
2113 |
url = get_endpoint('update-quotient') |
|
2114 |
params = { |
|
2115 |
'yearRev': '2021', |
|
2116 |
'dateStart': '2022-10-01', |
|
2117 |
'dateEnd': '2023-01-31', |
|
2118 |
'mtt': '1500.33', |
|
2119 |
'cdquo': 'QS', |
|
2120 |
} |
|
2121 | ||
2122 |
Link.objects.create(resource=con, family_id='1312', name_id='local') |
|
2123 |
resp = app.post_json(url + '?NameID=local&rl_id=613878', params=params) |
|
2124 |
assert_sent_payload(mocked_post, 'Q_create_update_quotient.xml') |
|
2125 |
assert resp.json['err'] == 0 |
|
2126 |
assert resp.json['data'] == 'ok' |
|
2127 | ||
2128 | ||
2129 |
def test_update_quotient_schema_error(con, app): |
|
2130 |
url = get_endpoint('update-quotient') |
|
2131 |
params = { |
|
2132 |
'yearRev': '2021', |
|
2133 |
'dateStart': '2022-10-01', |
|
2134 |
'dateEnd': '2023-01-31', |
|
2135 |
'mtt': '1500,33', |
|
2136 |
'cdquo': 'QS', |
|
2137 |
} |
|
2138 | ||
2139 |
Link.objects.create(resource=con, family_id='1312', name_id='local') |
|
2140 |
resp = app.post_json(url + '?NameID=local&rl_id=613878', params=params, status=400) |
|
2141 |
assert resp.json['err'] == 1 |
|
2142 |
assert resp.json['err_desc'] == "mtt: '1500,33' does not match '^[0-9]+\\\\.?[0-9]*$'" |
|
2143 | ||
2144 | ||
2145 |
@mock.patch('passerelle.utils.Request.get') |
|
2146 |
@mock.patch('passerelle.utils.Request.post') |
|
2147 |
def test_update_quotient_soap_error(mocked_post, mocked_get, con, app): |
|
2148 |
mocked_get.return_value = FAMILY_SERVICE_WSDL |
|
2149 |
mocked_post.return_value = UPDATE_QUOTIENT_500 |
|
2150 |
url = get_endpoint('update-quotient') |
|
2151 |
params = { |
|
2152 |
'yearRev': '2021', |
|
2153 |
'dateStart': '2022-10-01', |
|
2154 |
'dateEnd': '2023-01-31', |
|
2155 |
'mtt': '1500.33', |
|
2156 |
'cdquo': 'QS', |
|
2157 |
} |
|
2158 | ||
2159 |
Link.objects.create(resource=con, family_id='1312', name_id='local') |
|
2160 |
resp = app.post_json(url + '?NameID=local&rl_id=613878', params=params) |
|
2161 |
assert resp.json['err'] == 'Family-createUpdateQuotient-soap:Server' |
|
2162 |
assert 'E07 : Il existe déjà un quotient postérieur' in resp.json['err_desc'] |
|
2163 | ||
2164 | ||
2165 |
def test_update_quotient_wrong_referential_key_error(con, app): |
|
2166 |
url = get_endpoint('update-quotient') |
|
2167 |
params = { |
|
2168 |
'yearRev': '2021', |
|
2169 |
'dateStart': '2023-10-01', |
|
2170 |
'dateEnd': '2023-01-31', |
|
2171 |
'mtt': '1500.33', |
|
2172 |
'cdquo': 'plop', |
|
2173 |
} |
|
2174 | ||
2175 |
Link.objects.create(resource=con, family_id='1312', name_id='local') |
|
2176 |
resp = app.post_json(url + '?NameID=local&rl_id=613878', params=params) |
|
2177 |
assert resp.json['err'] == 'wrong-key' |
|
2178 |
assert resp.json['err_desc'] == "cdquo key value 'plop' do not belong to 'Quotient' required referential" |
|
2179 | ||
2180 | ||
2085 | 2181 |
@mock.patch('passerelle.utils.Request.get') |
2086 | 2182 |
@mock.patch('passerelle.utils.Request.post') |
2087 | 2183 |
def test_create_person(mocked_post, mocked_get, con, app): |
2088 | 2184 |
mocked_get.return_value = FAMILY_SERVICE_WSDL |
2089 | 2185 |
mocked_post.side_effect = [READ_FAMILY, UPDATE_FAMILY] |
2090 | 2186 |
url = get_endpoint('create-person') |
2091 | 2187 |
params = { |
2092 | 2188 |
'civility': None, |
2093 |
- |