477 |
477 |
resp = app.get('/toulouse-axel/test/management_dates')
|
478 |
478 |
assert set(resp.json.keys()) == set(['err', 'data'])
|
479 |
479 |
assert resp.json['err'] == 0
|
480 |
|
assert set(resp.json['data'].keys()) == set(['REPORT-REVENUS', 'EXTRACTION-FAMILLES', 'EXTRACTION-CAFPRO'])
|
|
480 |
assert set(resp.json['data'].keys()) == set([
|
|
481 |
'REPORT-REVENUS',
|
|
482 |
'report_revenus',
|
|
483 |
'EXTRACTION-FAMILLES',
|
|
484 |
'extraction_familles',
|
|
485 |
'EXTRACTION-CAFPRO',
|
|
486 |
'extraction_cafpro'
|
|
487 |
])
|
|
488 |
|
|
489 |
# again - data are in cache
|
|
490 |
resp = app.get('/toulouse-axel/test/management_dates')
|
|
491 |
assert set(resp.json.keys()) == set(['err', 'data'])
|
|
492 |
assert resp.json['err'] == 0
|
|
493 |
assert set(resp.json['data'].keys()) == set([
|
|
494 |
'REPORT-REVENUS',
|
|
495 |
'report_revenus',
|
|
496 |
'EXTRACTION-FAMILLES',
|
|
497 |
'extraction_familles',
|
|
498 |
'EXTRACTION-CAFPRO',
|
|
499 |
'extraction_cafpro'
|
|
500 |
])
|
|
501 |
|
|
502 |
with mock.patch('passerelle.contrib.toulouse_axel.models.ToulouseAxel.get_management_dates') as management_dates:
|
|
503 |
management_dates.return_value = {'foo': 'bar'}
|
|
504 |
resp = app.get('/toulouse-axel/test/management_dates')
|
|
505 |
assert set(resp.json.keys()) == set(['err', 'data'])
|
|
506 |
assert resp.json['err'] == 0
|
|
507 |
assert resp.json['data'] == {'foo': 'bar'}
|
481 |
508 |
|
482 |
509 |
|
483 |
510 |
def test_link_endpoint_nameid_empty(app, resource, link_params):
|
... | ... | |
679 |
706 |
assert resp.json['data'] == expected
|
680 |
707 |
|
681 |
708 |
|
682 |
|
def test_family_info_endpoint_axel_error(app, resource):
|
|
709 |
def test_family_info_endpoint_axel_error(app, resource, family_data):
|
683 |
710 |
Link.objects.create(resource=resource, name_id='yyy', dui='XXX', person_id='42')
|
684 |
711 |
with mock.patch('passerelle.contrib.toulouse_axel.models.ref_famille_dui') as operation:
|
685 |
712 |
operation.side_effect = AxelError('FooBar')
|
... | ... | |
687 |
714 |
assert resp.json['err_desc'] == "Axel error: FooBar"
|
688 |
715 |
assert resp.json['err'] == 'error'
|
689 |
716 |
|
|
717 |
filepath = os.path.join(os.path.dirname(__file__), 'data/toulouse_axel/family_info.xml')
|
|
718 |
with open(filepath) as xml:
|
|
719 |
content = xml.read()
|
|
720 |
with mock.patch('passerelle.contrib.toulouse_axel.models.ToulouseAxel.get_management_dates') as management_dates:
|
|
721 |
management_dates.side_effect = APIError('Axel error: FooBar')
|
|
722 |
with mock_getdata(content, 'RefFamilleDui'):
|
|
723 |
resp = app.get('/toulouse-axel/test/family_info?NameID=yyy')
|
|
724 |
assert resp.json['err_desc'] == "Axel error: FooBar"
|
|
725 |
|
690 |
726 |
|
691 |
727 |
def test_family_info_endpoint_no_result(app, resource):
|
692 |
728 |
resp = app.get('/toulouse-axel/test/family_info?NameID=yyy')
|
... | ... | |
699 |
735 |
filepath = os.path.join(os.path.dirname(__file__), 'data/toulouse_axel/family_info.xml')
|
700 |
736 |
with open(filepath) as xml:
|
701 |
737 |
content = xml.read()
|
702 |
|
with mock_getdata(content, 'RefFamilleDui'):
|
703 |
|
resp = app.get('/toulouse-axel/test/family_info?NameID=yyy')
|
|
738 |
with mock.patch('passerelle.contrib.toulouse_axel.models.ToulouseAxel.get_management_dates') as management_dates:
|
|
739 |
management_dates.return_value = {'foo': 'bar'}
|
|
740 |
with mock_getdata(content, 'RefFamilleDui'):
|
|
741 |
resp = app.get('/toulouse-axel/test/family_info?NameID=yyy')
|
704 |
742 |
assert resp.json['err'] == 0
|
705 |
743 |
assert set(resp.json['data'].keys()) == set([
|
706 |
744 |
'ADRESSE',
|
... | ... | |
717 |
755 |
'SITUATIONFAMILIALE',
|
718 |
756 |
'SITUATIONFAMILIALE_label',
|
719 |
757 |
'TELFIXE',
|
|
758 |
'management_dates',
|
720 |
759 |
])
|
721 |
760 |
assert resp.json['data']['ENFANT'][0]['id'] == '4242'
|
722 |
761 |
assert resp.json['data']['ENFANT'][0]['text'] == 'foo foo'
|
... | ... | |
728 |
767 |
assert resp.json['data']['ENFANT'][0]['CONTACT'][2]['text'] == 'foo foo'
|
729 |
768 |
assert resp.json['data']['ENFANT'][1]['id'] == '3535'
|
730 |
769 |
assert resp.json['data']['ENFANT'][1]['text'] == 'foo foo'
|
|
770 |
assert resp.json['data']['management_dates'] == {'foo': 'bar'}
|
731 |
771 |
|
732 |
772 |
with mock.patch('passerelle.contrib.toulouse_axel.models.ToulouseAxel.are_children_registered') as registered:
|
733 |
773 |
registered.side_effect = [{'4242': True}, {}]
|
734 |
|
with mock_getdata(content, 'RefFamilleDui'):
|
735 |
|
resp = app.get('/toulouse-axel/test/family_info?NameID=yyy')
|
|
774 |
with mock.patch('passerelle.contrib.toulouse_axel.models.ToulouseAxel.get_management_dates') as management_dates:
|
|
775 |
management_dates.return_value = {'foo': 'bar'}
|
|
776 |
with mock_getdata(content, 'RefFamilleDui'):
|
|
777 |
resp = app.get('/toulouse-axel/test/family_info?NameID=yyy')
|
736 |
778 |
assert resp.json['err'] == 0
|
737 |
779 |
assert resp.json['data']['ENFANT'][0]['clae_cantine_current'] is True
|
738 |
780 |
assert resp.json['data']['ENFANT'][0]['clae_cantine_next'] is None
|
... | ... | |
741 |
783 |
|
742 |
784 |
with mock.patch('passerelle.contrib.toulouse_axel.models.ToulouseAxel.are_children_registered') as registered:
|
743 |
785 |
registered.side_effect = [{}, {'4242': False, '3535': True}]
|
744 |
|
with mock_getdata(content, 'RefFamilleDui'):
|
745 |
|
resp = app.get('/toulouse-axel/test/family_info?NameID=yyy')
|
|
786 |
with mock.patch('passerelle.contrib.toulouse_axel.models.ToulouseAxel.get_management_dates') as management_dates:
|
|
787 |
management_dates.return_value = {'foo': 'bar'}
|
|
788 |
with mock_getdata(content, 'RefFamilleDui'):
|
|
789 |
resp = app.get('/toulouse-axel/test/family_info?NameID=yyy')
|
746 |
790 |
assert resp.json['err'] == 0
|
747 |
791 |
assert resp.json['data']['ENFANT'][0]['clae_cantine_current'] is None
|
748 |
792 |
assert resp.json['data']['ENFANT'][0]['clae_cantine_next'] is False
|
749 |
|
-
|