0001-toulouse-maelis-manage-child-insurance-71696.patch
functests/toulouse_maelis/conftest.py | ||
---|---|---|
365 | 365 |
# create family |
366 | 366 |
create_family_payload = copy.deepcopy(FAMILY_PAYLOAD) |
367 | 367 |
del create_family_payload['childList'][1] # without Lisa |
368 | 368 |
del create_family_payload['rl2'] # without Homer |
369 | 369 |
create_family_payload['rl1']['lastname'] = lastname |
370 | 370 |
for child in create_family_payload['childList']: |
371 | 371 |
child['lastname'] = lastname |
372 | 372 | |
373 |
# test insurance here because it cannot be reset |
|
374 |
create_family_payload['childList'][0]['insurance'] = { |
|
375 |
'company': 'Total Disaster Insurance', |
|
376 |
'contractNumber': '123', |
|
377 |
'memberNumber': '456', |
|
378 |
'contractStart': '2022-01-01', |
|
379 |
'contractEnd': '2022-12-31', |
|
380 |
} |
|
381 | ||
373 | 382 |
url = conn + '/create-family?NameID=%s' % name_id |
374 | 383 |
resp = requests.post(url, json=create_family_payload) |
375 | 384 |
resp.raise_for_status() |
376 | 385 |
create_result = resp.json() |
377 | 386 |
assert create_result['err'] == 0 |
378 | 387 |
print('\ncreate DUI: %s' % str(create_result['data']['number'])) |
379 | 388 |
data = diff_family(conn, name_id, 'test_create_family.json') |
380 | 389 | |
381 | 390 |
return { |
382 | 391 |
'name_id': name_id, # linked |
383 | 392 |
'family_id': str(create_result['data']['number']), |
393 |
'family_payload': create_family_payload, |
|
384 | 394 |
'lastname': lastname, |
385 | 395 |
'rl1_num': data['RL1']['num'], |
386 |
'family_payload': create_family_payload,
|
|
396 |
'bart_num': data['childList'][0]['num'],
|
|
387 | 397 |
'data': data, |
388 | 398 |
} |
389 | 399 | |
390 | 400 | |
391 | 401 |
@pytest.fixture(scope='session') |
392 | 402 |
def update_data(request, conn): |
393 | 403 |
name_id = request.config.getoption('--nameid') |
394 | 404 |
lastname = request.config.getoption('--lastname') |
functests/toulouse_maelis/data/test_create_family.json | ||
---|---|---|
149 | 149 |
}, |
150 | 150 |
{ |
151 | 151 |
"code": "DTC", |
152 | 152 |
"label": "DIPHTERIE TETANOS COQUELUCHE", |
153 | 153 |
"vaccinationDate": "2011-01-11T00:00:00+01:00" |
154 | 154 |
} |
155 | 155 |
] |
156 | 156 |
}, |
157 |
"insurance": null, |
|
157 |
"insurance": { |
|
158 |
"company": "Total Disaster Insurance", |
|
159 |
"contractNumber": "123", |
|
160 |
"memberNumber": "456", |
|
161 |
"contractStart": "2022-01-01T00:00:00+01:00", |
|
162 |
"contractEnd": "2022-12-31T00:00:00+01:00" |
|
163 |
}, |
|
158 | 164 |
"paiInfoBean": { |
159 | 165 |
"code": "PAIMED", |
160 | 166 |
"dateDeb": "2022-09-01T00:00:00+02:00", |
161 | 167 |
"dateFin": "2023-07-01T00:00:00+02:00", |
162 | 168 |
"description": "mischievous, rebellious, misunderstood, disruptive", |
163 | 169 |
"code_text": "MEDICAL" |
164 | 170 |
}, |
165 | 171 |
"mother": "N/A", |
functests/toulouse_maelis/data/test_update_child_insurance.json | ||
---|---|---|
1 |
{ |
|
2 |
"company": "Armagedon Colapse", |
|
3 |
"contractNumber": "444", |
|
4 |
"memberNumber": "555", |
|
5 |
"contractStart": "2022-01-02T00:00:00+01:00", |
|
6 |
"contractEnd": "2022-12-31T00:00:00+01:00" |
|
7 |
} |
functests/toulouse_maelis/test_family.py | ||
---|---|---|
547 | 547 |
for key in 'dietcode', 'paiInfoBean', 'medicalRecord', 'authorizedPersonList', 'indicatorList': |
548 | 548 |
if key in payload: |
549 | 549 |
del payload[key] |
550 | 550 |
resp = requests.post(url, json=payload) |
551 | 551 |
resp.raise_for_status() |
552 | 552 |
assert resp.json()['err'] == 0 |
553 | 553 |
assert diff_family(conn, update_data['name_id'], 'test_update_family.json') |
554 | 554 | |
555 |
# update Bart insurance (on create_data as it cannot be reset) |
|
556 |
unlink(conn, create_data['name_id']) |
|
557 |
link(conn, create_data) |
|
558 |
payload = copy.deepcopy(create_data['family_payload']['childList'][0]) |
|
559 |
for key in 'dietcode', 'paiInfoBean', 'medicalRecord', 'authorizedPersonList', 'indicatorList': |
|
560 |
if key in payload: |
|
561 |
del payload[key] |
|
562 |
payload['insurance'] = { |
|
563 |
'company': 'Armagedon Colapse', |
|
564 |
'contractNumber': '444', |
|
565 |
'memberNumber': '555', |
|
566 |
'contractStart': '2022-01-02', |
|
567 |
'contractEnd': '2022-12-31', |
|
568 |
} |
|
569 |
url = conn + '/update-child?NameID=%s&child_id=%s' % (create_data['name_id'], create_data['bart_num']) |
|
570 |
resp = requests.post(url, json=payload) |
|
571 |
resp.raise_for_status() |
|
572 |
res = resp.json() |
|
573 |
assert res['err'] == 0 |
|
574 |
assert diff_child(conn, create_data['name_id'], 0, 'test_update_child_insurance.json', 'insurance') |
|
575 | ||
555 | 576 | |
556 | 577 |
def test_update_child_dietcode(conn, update_data): |
557 | 578 |
unlink(conn, update_data['name_id']) |
558 | 579 |
link(conn, update_data) |
559 | 580 |
url = conn + '/update-child-dietcode?NameID=%s&child_id=%s&dietcode=' % ( |
560 | 581 |
update_data['name_id'], |
561 | 582 |
update_data['bart_num'], |
562 | 583 |
) |
passerelle/contrib/toulouse_maelis/family_schemas.py | ||
---|---|---|
494 | 494 |
'description': { |
495 | 495 |
'description': 'Texte libre de description (max 500 caractères)', |
496 | 496 |
'oneOf': [{'type': 'string'}, {'type': 'null'}], |
497 | 497 |
}, |
498 | 498 |
}, |
499 | 499 |
'additionalProperties': False, |
500 | 500 |
} |
501 | 501 | |
502 |
INSURANCE_SCHEMA = { |
|
503 |
'$schema': 'http://json-schema.org/draft-04/schema#', |
|
504 |
'title': 'Insurace', |
|
505 |
'description': "Informations sur l'assurance", |
|
506 |
'type': 'object', |
|
507 |
'properties': { |
|
508 |
'company': { |
|
509 |
'description': "Compagnie d'assurrance", |
|
510 |
'oneOf': [{'type': 'string'}, {'type': 'null'}], |
|
511 |
}, |
|
512 |
'contractNumber': { |
|
513 |
'description': 'Numéro du contrat', |
|
514 |
'oneOf': [{'type': 'string'}, {'type': 'null'}], |
|
515 |
}, |
|
516 |
'memberNumber': { |
|
517 |
'description': 'Numéro de membre', |
|
518 |
'oneOf': [{'type': 'string'}, {'type': 'null'}], |
|
519 |
}, |
|
520 |
'contractStart': { |
|
521 |
'description': 'Date de début du contrat', |
|
522 |
'type': 'string', |
|
523 |
'pattern': '^([0-9]{4}-[0-9]{2}-[0-9]{2}){0,1}$', |
|
524 |
}, |
|
525 |
'contractEnd': { |
|
526 |
'description': 'Date de fin du contrat', |
|
527 |
'type': 'string', |
|
528 |
'pattern': '^([0-9]{4}-[0-9]{2}-[0-9]{2}){0,1}$', |
|
529 |
}, |
|
530 |
}, |
|
531 |
} |
|
532 | ||
502 | 533 |
CHILD_SCHEMA = { |
503 | 534 |
'$schema': 'http://json-schema.org/draft-04/schema#', |
504 | 535 |
'title': 'Child', |
505 | 536 |
'description': "Informations sur la création d'un enfant", |
506 | 537 |
'type': 'object', |
507 | 538 |
'required': ['sexe', 'firstname', 'lastname', 'birth'], |
508 | 539 |
'properties': { |
509 | 540 |
'num': { |
... | ... | |
525 | 556 |
'oneOf': schemas.BOOLEAN_TYPES, |
526 | 557 |
}, |
527 | 558 |
'bLeaveAlone': { |
528 | 559 |
'description': 'Autorisation à partir seul', |
529 | 560 |
'oneOf': schemas.BOOLEAN_TYPES, |
530 | 561 |
}, |
531 | 562 |
'medicalRecord': {'oneOf': [MEDICALRECORD_SCHEMA, {'type': 'null'}]}, |
532 | 563 |
'paiInfoBean': {'oneOf': [PAIINFO_SCHEMA, {'type': 'null'}]}, |
564 |
'insurance': {'oneOf': [INSURANCE_SCHEMA, {'type': 'null'}]}, |
|
533 | 565 |
'authorizedPersonList': { |
534 | 566 |
'oneOf': [ |
535 | 567 |
{ |
536 | 568 |
'type': 'array', |
537 | 569 |
'items': AUTHORIZED_PERSON_SCHEMA, |
538 | 570 |
}, |
539 | 571 |
{'type': 'null'}, |
540 | 572 |
], |
tests/data/toulouse_maelis/R_read_family.xml | ||
---|---|---|
180 | 180 |
<vaccinationDate>2011-01-11T00:00:00+01:00</vaccinationDate> |
181 | 181 |
</vaccinList> |
182 | 182 |
<vaccinList> |
183 | 183 |
<code>ROR</code> |
184 | 184 |
<label>ROUGEOLE-OREILLONS-RUBEOLE</label> |
185 | 185 |
<vaccinationDate>1970-01-11T00:00:00+01:00</vaccinationDate> |
186 | 186 |
</vaccinList> |
187 | 187 |
</medicalRecord> |
188 |
<insurance> |
|
189 |
<company>Total Disaster Insurance</company> |
|
190 |
<contractNumber>123</contractNumber> |
|
191 |
<memberNumber>456</memberNumber> |
|
192 |
<contractStart>2022-01-01T00:00:00+01:00</contractStart> |
|
193 |
<contractEnd>2022-12-31T00:00:00+01:00</contractEnd> |
|
194 |
</insurance> |
|
188 | 195 |
<mother> |
189 | 196 |
<num>613963</num> |
190 | 197 |
<civility>MME</civility> |
191 | 198 |
<firstname>JANE</firstname> |
192 | 199 |
<lastname>DOE</lastname> |
193 | 200 |
</mother> |
194 | 201 |
<father> |
195 | 202 |
<num>613878</num> |
tests/data/toulouse_maelis/R_read_family_relax.xml | ||
---|---|---|
180 | 180 |
<vaccinationDate>2011-01-11T00:00:00+01:00</vaccinationDate> |
181 | 181 |
</vaccinList> |
182 | 182 |
<vaccinList> |
183 | 183 |
<code>ROR</code> |
184 | 184 |
<label>ROUGEOLE-OREILLONS-RUBEOLE</label> |
185 | 185 |
<vaccinationDate>1970-01-11T00:00:00+01:00</vaccinationDate> |
186 | 186 |
</vaccinList> |
187 | 187 |
</medicalRecord> |
188 |
<insurance> |
|
189 |
<company>Total Disaster Insurance</company> |
|
190 |
<contractNumber>123</contractNumber> |
|
191 |
<memberNumber>456</memberNumber> |
|
192 |
<contractStart>2022-01-01T00:00:00+01:00</contractStart> |
|
193 |
<contractEnd>2022-12-31T00:00:00+01:00</contractEnd> |
|
194 |
</insurance> |
|
188 | 195 |
<mother> |
189 | 196 |
<num>613963</num> |
190 | 197 |
<civility>MME</civility> |
191 | 198 |
<firstname>JANE</firstname> |
192 | 199 |
<lastname>DOE</lastname> |
193 | 200 |
</mother> |
194 | 201 |
<father> |
195 | 202 |
<num>613878</num> |
tests/data/toulouse_maelis/R_read_family_reordered.xml | ||
---|---|---|
180 | 180 |
<vaccinationDate>2011-01-11T00:00:00+01:00</vaccinationDate> |
181 | 181 |
</vaccinList> |
182 | 182 |
<vaccinList> |
183 | 183 |
<code>ROR</code> |
184 | 184 |
<label>ROUGEOLE-OREILLONS-RUBEOLE</label> |
185 | 185 |
<vaccinationDate>1970-01-11T00:00:00+01:00</vaccinationDate> |
186 | 186 |
</vaccinList> |
187 | 187 |
</medicalRecord> |
188 |
<insurance> |
|
189 |
<company>Total Disaster Insurance</company> |
|
190 |
<contractNumber>123</contractNumber> |
|
191 |
<memberNumber>456</memberNumber> |
|
192 |
<contractStart>2022-01-01T00:00:00+01:00</contractStart> |
|
193 |
<contractEnd>2022-12-31T00:00:00+01:00</contractEnd> |
|
194 |
</insurance> |
|
188 | 195 |
<mother> |
189 | 196 |
<num>613963</num> |
190 | 197 |
<civility>MME</civility> |
191 | 198 |
<firstname>JANE</firstname> |
192 | 199 |
<lastname>DOE</lastname> |
193 | 200 |
</mother> |
194 | 201 |
<father> |
195 | 202 |
<num>613878</num> |
tests/test_toulouse_maelis.py | ||
---|---|---|
899 | 899 |
'place': 'Saint-louis', |
900 | 900 |
'communeCode': '91122', |
901 | 901 |
'countryCode': '99100', |
902 | 902 |
}, |
903 | 903 |
'dietcode': 'RSV', |
904 | 904 |
'dietcode_text': '3- RÉGIME SANS VIANDE', |
905 | 905 |
'bPhoto': True, |
906 | 906 |
'bLeaveAlone': False, |
907 |
'insurance': None, |
|
907 |
'insurance': { |
|
908 |
'company': 'Total Disaster Insurance', |
|
909 |
'contractEnd': '2022-12-31T00:00:00+01:00', |
|
910 |
'contractNumber': '123', |
|
911 |
'contractStart': '2022-01-01T00:00:00+01:00', |
|
912 |
'memberNumber': '456', |
|
913 |
}, |
|
908 | 914 |
'subscribeSchoolList': [], |
909 | 915 |
'mother': {'num': 613963, 'civility': 'MME', 'firstname': 'JANE', 'lastname': 'DOE'}, |
910 | 916 |
'father': {'num': 613878, 'civility': 'M.', 'firstname': 'JHON', 'lastname': 'DOE'}, |
911 | 917 |
'rl': None, |
912 | 918 |
'subscribeActivityList': [], |
913 | 919 |
} |
914 | 920 |
if xml != 'R_read_family_relax.xml': |
915 | 921 |
assert resp.json['data']['childList'][0]['paiInfoBean'] == { |
... | ... | |
1288 | 1294 |
'childList/0/sexe': 'M', |
1289 | 1295 |
'childList/0/birth/dateBirth': '1941-05-24', |
1290 | 1296 |
'childList/0/birth/place': 'Saint-louis', |
1291 | 1297 |
'childList/0/birth/communeCode': '91122', |
1292 | 1298 |
'childList/0/birth/countryCode': '99100', |
1293 | 1299 |
'childList/0/dietcode': 'RSV', |
1294 | 1300 |
'childList/0/medicalRecord/vaccinList/0/code': 'DTC', |
1295 | 1301 |
'childList/0/medicalRecord/vaccinList/0/vaccinationDate': '1940-07-26', |
1302 |
'childList/0/insurance/company': 'Total Disaster Insurance', |
|
1303 |
'childList/0/insurance/contractNumber': '123', |
|
1304 |
'childList/0/insurance/memberNumber': '456', |
|
1305 |
'childList/0/insurance/contractStart': '2022-01-01', |
|
1306 |
'childList/0/insurance/contractEnd': '2022-12-31', |
|
1296 | 1307 |
} |
1297 | 1308 | |
1298 | 1309 |
resp = app.post_json(url + '?NameID=local', params=params) |
1299 | 1310 |
assert resp.json['err'] == 0 |
1300 | 1311 |
assert resp.json['data'] == { |
1301 | 1312 |
'number': 196545, |
1302 | 1313 |
'password': '394634V2', |
1303 | 1314 |
'rl1ErrorList': [], |
... | ... | |
1442 | 1453 |
'childList/0/firstname': 'Robert', |
1443 | 1454 |
'childList/0/sexe': 'M', |
1444 | 1455 |
'childList/0/birth/dateBirth': '1941-05-24', |
1445 | 1456 |
'childList/0/birth/place': 'Duluth', |
1446 | 1457 |
'childList/0/dietcode': 'RSV', |
1447 | 1458 |
'childList/0/paiInfoBean/code': 'PAIALI', |
1448 | 1459 |
'childList/0/medicalRecord/vaccinList/0/code': 'DTC', |
1449 | 1460 |
'childList/0/medicalRecord/vaccinList/0/vaccinationDate': '1940-07-26', |
1461 |
'childList/0/insurance/company': 'Armagedon Colapse', |
|
1462 |
'childList/0/insurance/contractNumber': '444', |
|
1463 |
'childList/0/insurance/memberNumber': '555', |
|
1464 |
'childList/0/insurance/contractStart': '2022-01-02', |
|
1465 |
'childList/0/insurance/contractEnd': '2022-12-31', |
|
1450 | 1466 |
'childList/1/num': '613880', # update child |
1451 | 1467 |
'childList/1/firstname': 'Brunelle', |
1452 | 1468 |
'childList/1/lastname': 'Doe', |
1453 | 1469 |
'childList/1/birth/dateBirth': '1943-01-19', |
1454 | 1470 |
'childList/1/sexe': 'F', |
1455 | 1471 |
} |
1456 | 1472 | |
1457 | 1473 |
Link.objects.create(resource=con, family_id='1312', name_id='local') |
... | ... | |
1962 | 1978 |
family_service.add_soap_response('createChild', get_xml_file('R_create_child.xml')) |
1963 | 1979 |
url = get_endpoint('create-child') |
1964 | 1980 |
params = { |
1965 | 1981 |
'lastname': 'DOE', |
1966 | 1982 |
'firstname': 'JANNIS', |
1967 | 1983 |
'sexe': 'F', |
1968 | 1984 |
'birth/dateBirth': '1943-01-19', |
1969 | 1985 |
'birth/place': 'Port Arthur', |
1986 |
'insurance/company': 'Total Disaster Insurance', |
|
1987 |
'insurance/contractNumber': '123', |
|
1988 |
'insurance/memberNumber': '456', |
|
1989 |
'insurance/contractStart': '2022-01-01', |
|
1990 |
'insurance/contractEnd': '2022-12-31', |
|
1970 | 1991 |
} |
1971 | 1992 | |
1972 | 1993 |
Link.objects.create(resource=con, family_id='1312', name_id='local') |
1973 | 1994 |
resp = app.post_json(url + '?NameID=local', params=params) |
1974 | 1995 |
assert resp.json['err'] == 0 |
1975 | 1996 |
assert resp.json['data'] == {'child_id': 613880} |
1976 | 1997 | |
1977 | 1998 | |
... | ... | |
2068 | 2089 |
params = { |
2069 | 2090 |
'lastname': 'DOE', |
2070 | 2091 |
'firstname': 'JANNIS', |
2071 | 2092 |
'sexe': 'F', |
2072 | 2093 |
'birth/dateBirth': '1943-01-19', |
2073 | 2094 |
'birth/place': 'Port Arthur', |
2074 | 2095 |
'bPhoto': True, |
2075 | 2096 |
'bLeaveAlone': False, |
2097 |
'insurance/company': 'Armagedon Colapse', |
|
2098 |
'insurance/contractNumber': '444', |
|
2099 |
'insurance/memberNumber': '555', |
|
2100 |
'insurance/contractStart': '2022-01-02', |
|
2101 |
'insurance/contractEnd': '2022-12-31', |
|
2076 | 2102 |
} |
2077 | 2103 | |
2078 | 2104 |
Link.objects.create(resource=con, family_id='1312', name_id='local') |
2079 | 2105 |
resp = app.post_json(url + '?NameID=local&child_id=613880', params=params) |
2080 | 2106 |
assert resp.json['err'] == 0 |
2081 | 2107 | |
2082 | 2108 | |
2083 | 2109 |
def test_update_child_not_linked_error(con, app): |
2084 |
- |