400 |
400 |
assert resp.json['data']['MEMBRE'][2]['text'] == 'Enfant 3 CALUIRE TEST'
|
401 |
401 |
assert resp.json['data']['MEMBRE'][3]['id'] == '59509'
|
402 |
402 |
assert resp.json['data']['MEMBRE'][3]['text'] == 'Enfant 5 CALUIRE TEST'
|
|
403 |
|
|
404 |
|
|
405 |
def test_children_info_endpoint_axel_error(app, resource):
|
|
406 |
Link.objects.create(resource=resource, name_id='yyy', family_id='XXX', person_id='42')
|
|
407 |
with mock.patch('passerelle.contrib.caluire_axel.schemas.get_famille_individus') as operation:
|
|
408 |
operation.side_effect = AxelError('FooBar')
|
|
409 |
resp = app.get('/caluire-axel/test/children_info?NameID=yyy')
|
|
410 |
assert resp.json['err_desc'] == "Axel error: FooBar"
|
|
411 |
assert resp.json['err'] == 'error'
|
|
412 |
|
|
413 |
|
|
414 |
def test_children_info_endpoint_no_result(app, resource):
|
|
415 |
resp = app.get('/caluire-axel/test/children_info?NameID=yyy')
|
|
416 |
assert resp.json['err_desc'] == "Person not found"
|
|
417 |
assert resp.json['err'] == 'not-found'
|
|
418 |
|
|
419 |
|
|
420 |
def test_children_info_endpoint(app, resource):
|
|
421 |
Link.objects.create(resource=resource, name_id='yyy', family_id='XXX', person_id='42')
|
|
422 |
filepath = os.path.join(os.path.dirname(__file__), 'data/caluire_axel/family_info.xml')
|
|
423 |
with open(filepath) as xml:
|
|
424 |
content = xml.read()
|
|
425 |
with mock_getdata(content, 'GetFamilleIndividus'):
|
|
426 |
resp = app.get('/caluire-axel/test/children_info?NameID=yyy')
|
|
427 |
assert resp.json['err'] == 0
|
|
428 |
assert len(resp.json['data']) == 4
|
|
429 |
assert resp.json['data'][0]['id'] == '50632'
|
|
430 |
assert resp.json['data'][0]['text'] == 'Enfant 1 CALUIRE TEST'
|
|
431 |
assert resp.json['data'][1]['id'] == '50633'
|
|
432 |
assert resp.json['data'][1]['text'] == 'Enfant 2 CALUIRE TEST'
|
|
433 |
assert resp.json['data'][2]['id'] == '54621'
|
|
434 |
assert resp.json['data'][2]['text'] == 'Enfant 3 CALUIRE TEST'
|
|
435 |
assert resp.json['data'][3]['id'] == '59509'
|
|
436 |
assert resp.json['data'][3]['text'] == 'Enfant 5 CALUIRE TEST'
|
403 |
|
-
|