195 |
195 |
def test_link(mocked_post, mocked_get, con, app):
|
196 |
196 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
197 |
197 |
mocked_post.return_value = READ_FAMILY
|
198 |
198 |
url = get_endpoint('link')
|
199 |
199 |
assert Link.objects.count() == 0
|
200 |
200 |
|
201 |
201 |
params = {
|
202 |
202 |
'family_id': '1312',
|
203 |
|
'firstname': 'Damien',
|
204 |
|
'lastname': 'Costanze',
|
205 |
|
'dateBirth': '1980-10-07',
|
|
203 |
'firstname': 'Jhon',
|
|
204 |
'lastname': 'Doe',
|
|
205 |
'dateBirth': '1938-07-26',
|
206 |
206 |
}
|
207 |
207 |
resp = app.post_json(url + '?NameID=local', params=params)
|
208 |
208 |
assert Link.objects.count() == 1
|
209 |
209 |
assert resp.json['err'] == 0
|
210 |
210 |
assert resp.json['data'] == 'ok'
|
211 |
211 |
|
212 |
212 |
params['lastname'] = 'John'
|
213 |
213 |
resp = app.post_json(url + '?NameID=local', params=params)
|
... | ... | |
510 |
510 |
{'id': 'DTC', 'text': 'DIPHTERIE TETANOS COQUELUCHE'},
|
511 |
511 |
]
|
512 |
512 |
|
513 |
513 |
|
514 |
514 |
@mock.patch('passerelle.utils.Request.get')
|
515 |
515 |
@mock.patch('passerelle.utils.Request.post')
|
516 |
516 |
def test_read_family(mocked_post, mocked_get, con, app):
|
517 |
517 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
518 |
|
mocked_post.side_effect = [READ_FAMILY, READ_CATEGORIES, READ_SITUATIONS, READ_CIVILITIES, READ_QUALITIES]
|
|
518 |
mocked_post.side_effect = [
|
|
519 |
READ_FAMILY,
|
|
520 |
READ_CATEGORIES,
|
|
521 |
READ_SITUATIONS,
|
|
522 |
READ_CIVILITIES,
|
|
523 |
READ_QUALITIES,
|
|
524 |
READ_CSP,
|
|
525 |
]
|
519 |
526 |
url = get_endpoint('read-family')
|
520 |
527 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
521 |
528 |
|
522 |
529 |
resp = app.get(url + '?NameID=local')
|
523 |
530 |
assert resp.json['err'] == 0
|
524 |
531 |
data = resp.json['data']
|
525 |
532 |
del data['RL1']
|
526 |
533 |
del data['RL2']
|
527 |
534 |
del data['childList']
|
528 |
535 |
del data['authorizedPersonList']
|
529 |
536 |
del data['emergencyPersonList']
|
530 |
537 |
assert data == {
|
531 |
|
'number': 196514,
|
|
538 |
'number': 1312,
|
532 |
539 |
'category': 'BI',
|
533 |
540 |
'situation': 'M',
|
534 |
541 |
'flagCom': True,
|
535 |
542 |
'nbChild': 2,
|
536 |
|
'nbTotalChild': 2,
|
|
543 |
'nbTotalChild': None,
|
537 |
544 |
'nbAES': None,
|
538 |
545 |
'quotientList': [],
|
539 |
546 |
'indicatorList': [],
|
540 |
547 |
'childErrorList': [],
|
541 |
548 |
'category_text': 'BIPARENTALE',
|
542 |
549 |
'situation_text': 'Marié (e)',
|
543 |
550 |
}
|
544 |
|
assert resp.json['data']['RL1'] == {
|
|
551 |
data = resp.json['data']['RL1']
|
|
552 |
del data['profession']
|
|
553 |
assert data == {
|
545 |
554 |
'num': '613878',
|
546 |
|
'lastname': 'COSTANZE',
|
547 |
|
'firstname': 'DAMIEN',
|
|
555 |
'lastname': 'DOE',
|
|
556 |
'firstname': 'JHON',
|
548 |
557 |
'quality': 'PERE',
|
549 |
|
'quality_text': 'PERE',
|
550 |
558 |
'civility': 'M.',
|
551 |
|
'civility_text': 'Monsieur',
|
552 |
|
'dateBirth': '1980-10-07T00:00:00+01:00',
|
|
559 |
'dateBirth': '1938-07-26T00:00:00+01:00',
|
553 |
560 |
'adresse': {
|
554 |
|
'idStreet': 'AV0044',
|
555 |
|
'num': 9,
|
|
561 |
'idStreet': None,
|
|
562 |
'num': 170,
|
556 |
563 |
'numComp': None,
|
557 |
|
'street1': 'AVENUE VALDILETTA',
|
558 |
|
'street2': 'LES MANDARINIERS',
|
559 |
|
'town': 'NICE',
|
560 |
|
'zipcode': '06100',
|
|
564 |
'street1': "Chateau d'eau",
|
|
565 |
'street2': None,
|
|
566 |
'town': 'Paris',
|
|
567 |
'zipcode': '75014',
|
561 |
568 |
},
|
562 |
569 |
'contact': {
|
563 |
|
'phone': '0664107085',
|
564 |
|
'mobile': '0637957391',
|
565 |
|
'mail': 'petro.costache@yahoo.com',
|
|
570 |
'phone': 'non',
|
|
571 |
'mobile': '0777777777',
|
|
572 |
'mail': 'djhon@example.org',
|
566 |
573 |
'isContactMail': True,
|
567 |
574 |
'isContactSms': True,
|
568 |
575 |
'isInvoicePdf': True,
|
569 |
576 |
},
|
570 |
|
'profession': None,
|
571 |
|
'CAFInfo': {'number': '51', 'organ': None},
|
|
577 |
'CAFInfo': None,
|
|
578 |
'civility_text': 'Monsieur',
|
|
579 |
'quality_text': 'PERE',
|
572 |
580 |
}
|
573 |
|
assert resp.json['data']['childList'][0] == {
|
|
581 |
data = resp.json['data']['childList'][0]
|
|
582 |
del data['fsl']
|
|
583 |
del data['medicalRecord']
|
|
584 |
assert data == {
|
574 |
585 |
'num': '613880',
|
575 |
|
'lastname': 'COSTANZE',
|
576 |
|
'firstname': 'CASSANDRA',
|
|
586 |
'lastname': 'DOE',
|
|
587 |
'firstname': 'JANNIS',
|
577 |
588 |
'sexe': 'F',
|
578 |
589 |
'sexe_text': 'Féminin',
|
579 |
|
'birth': {'dateBirth': '2021-06-22T00:00:00+02:00', 'place': None},
|
580 |
|
'dietcode': 'STD',
|
581 |
|
'fsl': None,
|
|
590 |
'birth': {'dateBirth': '1943-01-19T00:00:00+01:00', 'place': None},
|
|
591 |
'dietcode': 'RSV',
|
582 |
592 |
'bPhoto': False,
|
583 |
593 |
'bLeaveAlone': False,
|
584 |
594 |
'authorizedPersonList': [],
|
585 |
595 |
'indicatorList': [],
|
586 |
|
'medicalRecord': None,
|
587 |
596 |
'subscribeSchoolList': [],
|
588 |
|
'mother': None,
|
589 |
|
'father': None,
|
|
597 |
'mother': {'num': 613963, 'civility': 'MME', 'firstname': 'JANE', 'lastname': 'DOE'},
|
|
598 |
'father': {'num': 613878, 'civility': 'M.', 'firstname': 'JHON', 'lastname': 'DOE'},
|
590 |
599 |
'rl': None,
|
591 |
600 |
'subscribeActivityList': [],
|
592 |
|
'paiInfoBean': None,
|
|
601 |
'paiInfoBean': {
|
|
602 |
'code': 'PAIALI',
|
|
603 |
'dateDeb': '2022-01-01T00:00:00+01:00',
|
|
604 |
'dateFin': '2022-12-31T00:00:00+01:00',
|
|
605 |
'description': 'bla bla PAI',
|
|
606 |
},
|
|
607 |
}
|
|
608 |
assert resp.json['data']['childList'][0]['fsl'] == {
|
|
609 |
'dateDeb': '2022-01-01T00:00:00+01:00',
|
|
610 |
'dateFin': '2022-12-31T00:00:00+01:00',
|
|
611 |
'allergieAlimentaire': 'O',
|
|
612 |
'allergieRespiratoire': 'O',
|
|
613 |
'allergieAutre': 'O',
|
|
614 |
'allergieMedicament': 'O',
|
|
615 |
'asthme': 'N',
|
|
616 |
'flPAI': 'N',
|
|
617 |
'flImage': 'N',
|
|
618 |
'dtcPrap1': '2022-02-22T00:00:00+01:00',
|
|
619 |
'obsMed1': 'some obsMed1 text',
|
|
620 |
'obsMed2': 'some obsMed2 text',
|
|
621 |
'obsMed3': 'some obsMed3 text',
|
|
622 |
'obsDir1': 'some obsDir1 text',
|
|
623 |
'obsDir2': 'some obsDir2 text',
|
|
624 |
'obsDir3': 'some obsDir3 text',
|
|
625 |
'obsAssist1': 'some obsAssist1 text',
|
|
626 |
'obsAssist2': 'some obsAssist2 text',
|
|
627 |
'obsAssist3': 'some obsAssist3 text',
|
|
628 |
'cons1Med': 'some cons1Med text',
|
|
629 |
'cons2Med': 'some cons2Med text',
|
|
630 |
}
|
|
631 |
assert resp.json['data']['childList'][0]['medicalRecord'] == {
|
|
632 |
"familyDoctor": {
|
|
633 |
"name": "DRE",
|
|
634 |
"phone": "0612341234",
|
|
635 |
"address": {"street1": "Alameda", "zipcode": "90220", "town": "Compton"},
|
|
636 |
},
|
|
637 |
"vaccinList": [
|
|
638 |
{
|
|
639 |
"code": "ROR",
|
|
640 |
"label": "ROUGEOLE-OREILLONS-RUBEOLE",
|
|
641 |
"vaccinationDate": "2012-02-22T00:00:00+01:00",
|
|
642 |
},
|
|
643 |
{
|
|
644 |
"code": "DTC",
|
|
645 |
"label": "DIPHTERIE TETANOS COQUELUCHE",
|
|
646 |
"vaccinationDate": "2011-01-11T00:00:00+01:00",
|
|
647 |
},
|
|
648 |
{
|
|
649 |
"code": "ROR",
|
|
650 |
"label": "ROUGEOLE-OREILLONS-RUBEOLE",
|
|
651 |
"vaccinationDate": "1970-01-11T00:00:00+01:00",
|
|
652 |
},
|
|
653 |
],
|
593 |
654 |
}
|
594 |
655 |
assert resp.json['data']['emergencyPersonList'][0] == {
|
595 |
656 |
'firstname': 'KENY',
|
596 |
657 |
'lastname': 'ARKANA',
|
597 |
|
'quality': 'MERE',
|
598 |
|
'civility': None,
|
599 |
|
'contact': {'phone': '0123456789', 'mobile': None, 'mail': None},
|
600 |
|
'numPerson': 614059,
|
601 |
658 |
'dateBirth': '1970-01-01',
|
602 |
|
'quality_text': 'MERE',
|
|
659 |
'quality': 'T',
|
|
660 |
'civility': 'MME',
|
|
661 |
'contact': {'phone': '0123456789', 'mobile': None, 'mail': 'pueblo@example.org'},
|
|
662 |
'numPerson': 614059,
|
|
663 |
'civility_text': 'Madame',
|
|
664 |
'quality_text': 'TANTE',
|
603 |
665 |
}
|
604 |
666 |
|
605 |
667 |
|
606 |
668 |
def test_read_family_not_linked_error(con, app):
|
607 |
669 |
url = get_endpoint('read-family')
|
608 |
670 |
|
609 |
671 |
resp = app.get(url + '?NameID=')
|
610 |
672 |
assert resp.json['err'] == 'not-linked'
|
611 |
673 |
assert resp.json['err_desc'] == 'User not linked to family'
|
612 |
674 |
|
613 |
675 |
|
614 |
676 |
@mock.patch('passerelle.utils.Request.get')
|
615 |
677 |
@mock.patch('passerelle.utils.Request.post')
|
616 |
678 |
def test_read_rl1(mocked_post, mocked_get, con, app):
|
617 |
679 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
618 |
|
mocked_post.side_effect = [READ_FAMILY, READ_CATEGORIES, READ_SITUATIONS, READ_CIVILITIES, READ_QUALITIES]
|
|
680 |
mocked_post.side_effect = [
|
|
681 |
READ_FAMILY,
|
|
682 |
READ_CATEGORIES,
|
|
683 |
READ_SITUATIONS,
|
|
684 |
READ_CIVILITIES,
|
|
685 |
READ_QUALITIES,
|
|
686 |
READ_CSP,
|
|
687 |
]
|
619 |
688 |
url = get_endpoint('read-rl')
|
620 |
689 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
621 |
690 |
|
622 |
691 |
resp = app.get(url + '?NameID=local&rl_id=613878')
|
623 |
692 |
assert resp.json['err'] == 0
|
624 |
|
assert resp.json['data']['firstname'] == 'DAMIEN'
|
|
693 |
assert resp.json['data']['firstname'] == 'JHON'
|
625 |
694 |
|
626 |
695 |
|
627 |
696 |
@mock.patch('passerelle.utils.Request.get')
|
628 |
697 |
@mock.patch('passerelle.utils.Request.post')
|
629 |
698 |
def test_read_rl2(mocked_post, mocked_get, con, app):
|
630 |
699 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
631 |
|
mocked_post.side_effect = [READ_FAMILY, READ_CATEGORIES, READ_SITUATIONS, READ_CIVILITIES, READ_QUALITIES]
|
|
700 |
mocked_post.side_effect = [
|
|
701 |
READ_FAMILY,
|
|
702 |
READ_CATEGORIES,
|
|
703 |
READ_SITUATIONS,
|
|
704 |
READ_CIVILITIES,
|
|
705 |
READ_QUALITIES,
|
|
706 |
READ_CSP,
|
|
707 |
]
|
632 |
708 |
url = get_endpoint('read-rl')
|
633 |
709 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
634 |
710 |
|
635 |
711 |
resp = app.get(url + '?NameID=local&rl_id=613879')
|
636 |
712 |
assert resp.json['err'] == 0
|
637 |
713 |
assert resp.json['data'] == {
|
638 |
714 |
'num': '613879',
|
639 |
|
'lastname': 'COSTANZE',
|
640 |
|
'firstname': 'JENNIFER',
|
|
715 |
'lastname': 'DOE',
|
|
716 |
'firstname': 'JANE',
|
641 |
717 |
'quality': 'MERE',
|
642 |
718 |
'civility': 'MME',
|
643 |
|
'dateBirth': '1987-05-21T00:00:00+02:00',
|
|
719 |
'dateBirth': '1940-06-22T00:00:00+02:00',
|
644 |
720 |
'adresse': {
|
645 |
|
'idStreet': 'AV0044',
|
646 |
|
'num': 9,
|
|
721 |
'idStreet': None,
|
|
722 |
'num': 170,
|
647 |
723 |
'numComp': None,
|
648 |
|
'street1': 'AVENUE VALDILETTA',
|
649 |
|
'street2': 'LES MANDARINIERS',
|
650 |
|
'town': 'NICE',
|
651 |
|
'zipcode': '06100',
|
|
724 |
'street1': "Chateau d'eau",
|
|
725 |
'street2': None,
|
|
726 |
'town': 'Paris',
|
|
727 |
'zipcode': '75014',
|
652 |
728 |
},
|
653 |
729 |
'contact': {
|
654 |
730 |
'phone': None,
|
655 |
731 |
'mobile': None,
|
656 |
732 |
'mail': None,
|
657 |
733 |
'isContactMail': False,
|
658 |
734 |
'isContactSms': False,
|
659 |
735 |
'isInvoicePdf': False,
|
660 |
736 |
},
|
661 |
|
'profession': None,
|
662 |
|
'CAFInfo': {'number': '51', 'organ': None},
|
|
737 |
'profession': {
|
|
738 |
'codeCSP': 'ART',
|
|
739 |
'profession': 'informaticien',
|
|
740 |
'employerName': 'EO',
|
|
741 |
'phone': '0123456789',
|
|
742 |
'addressPro': {'num': None, 'street': None, 'zipcode': None, 'town': 'Orléans'},
|
|
743 |
'codeCSP_text': 'ARTISAN',
|
|
744 |
},
|
|
745 |
'CAFInfo': {'number': '789', 'organ': 'ma caf'},
|
663 |
746 |
'civility_text': 'Madame',
|
664 |
747 |
'quality_text': 'MERE',
|
665 |
748 |
}
|
666 |
749 |
|
667 |
750 |
|
668 |
751 |
def test_read_rl_not_linked_error(con, app):
|
669 |
752 |
url = get_endpoint('read-rl')
|
670 |
753 |
|
... | ... | |
672 |
755 |
assert resp.json['err'] == 'not-linked'
|
673 |
756 |
assert resp.json['err_desc'] == 'User not linked to family'
|
674 |
757 |
|
675 |
758 |
|
676 |
759 |
@mock.patch('passerelle.utils.Request.get')
|
677 |
760 |
@mock.patch('passerelle.utils.Request.post')
|
678 |
761 |
def test_read_rl_not_found(mocked_post, mocked_get, con, app):
|
679 |
762 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
680 |
|
mocked_post.side_effect = [READ_FAMILY, READ_CATEGORIES, READ_SITUATIONS, READ_CIVILITIES, READ_QUALITIES]
|
|
763 |
mocked_post.side_effect = [
|
|
764 |
READ_FAMILY,
|
|
765 |
READ_CATEGORIES,
|
|
766 |
READ_SITUATIONS,
|
|
767 |
READ_CIVILITIES,
|
|
768 |
READ_QUALITIES,
|
|
769 |
READ_CSP,
|
|
770 |
]
|
681 |
771 |
url = get_endpoint('read-rl')
|
682 |
772 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
683 |
773 |
|
684 |
774 |
resp = app.get(url + '?NameID=local&rl_id=000000')
|
685 |
775 |
assert resp.json['err'] == 'not-found'
|
686 |
776 |
assert resp.json['err_desc'] == "no '000000' RL on '1312' family"
|
687 |
777 |
|
688 |
778 |
|
689 |
779 |
@mock.patch('passerelle.utils.Request.get')
|
690 |
780 |
@mock.patch('passerelle.utils.Request.post')
|
691 |
781 |
def test_read_person(mocked_post, mocked_get, con, app):
|
692 |
782 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
693 |
|
mocked_post.side_effect = [READ_FAMILY, READ_CATEGORIES, READ_SITUATIONS, READ_CIVILITIES, READ_QUALITIES]
|
|
783 |
mocked_post.side_effect = [
|
|
784 |
READ_FAMILY,
|
|
785 |
READ_CATEGORIES,
|
|
786 |
READ_SITUATIONS,
|
|
787 |
READ_CIVILITIES,
|
|
788 |
READ_QUALITIES,
|
|
789 |
READ_CSP,
|
|
790 |
]
|
694 |
791 |
url = get_endpoint('read-person')
|
695 |
792 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
696 |
793 |
|
697 |
794 |
resp = app.get(url + '?NameID=local&person_id=614059&kind=emergency')
|
698 |
795 |
assert resp.json['err'] == 0
|
699 |
796 |
assert resp.json['data']['firstname'] == 'KENY'
|
700 |
797 |
|
701 |
798 |
|
... | ... | |
714 |
811 |
assert resp.json['err'] == 'not-linked'
|
715 |
812 |
assert resp.json['err_desc'] == 'User not linked to family'
|
716 |
813 |
|
717 |
814 |
|
718 |
815 |
@mock.patch('passerelle.utils.Request.get')
|
719 |
816 |
@mock.patch('passerelle.utils.Request.post')
|
720 |
817 |
def test_read_person_not_found(mocked_post, mocked_get, con, app):
|
721 |
818 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
722 |
|
mocked_post.side_effect = [READ_FAMILY, READ_CATEGORIES, READ_SITUATIONS, READ_CIVILITIES, READ_QUALITIES]
|
|
819 |
mocked_post.side_effect = [
|
|
820 |
READ_FAMILY,
|
|
821 |
READ_CATEGORIES,
|
|
822 |
READ_SITUATIONS,
|
|
823 |
READ_CIVILITIES,
|
|
824 |
READ_QUALITIES,
|
|
825 |
READ_CSP,
|
|
826 |
]
|
723 |
827 |
url = get_endpoint('read-person')
|
724 |
828 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
725 |
829 |
|
726 |
830 |
resp = app.get(url + '?NameID=local&person_id=000000&kind=emergency')
|
727 |
831 |
assert resp.json['err'] == 'not-found'
|
728 |
832 |
assert resp.json['err_desc'] == "no '000000' emergency person on '1312' family"
|
729 |
833 |
|
730 |
834 |
|
731 |
835 |
@mock.patch('passerelle.utils.Request.get')
|
732 |
836 |
@mock.patch('passerelle.utils.Request.post')
|
733 |
837 |
def test_read_child(mocked_post, mocked_get, con, app):
|
734 |
838 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
735 |
|
mocked_post.side_effect = [READ_FAMILY, READ_CATEGORIES, READ_SITUATIONS, READ_CIVILITIES, READ_QUALITIES]
|
|
839 |
mocked_post.side_effect = [
|
|
840 |
READ_FAMILY,
|
|
841 |
READ_CATEGORIES,
|
|
842 |
READ_SITUATIONS,
|
|
843 |
READ_CIVILITIES,
|
|
844 |
READ_QUALITIES,
|
|
845 |
READ_CSP,
|
|
846 |
]
|
736 |
847 |
url = get_endpoint('read-child')
|
737 |
848 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
738 |
849 |
|
739 |
850 |
resp = app.get(url + '?NameID=local&child_id=613880')
|
740 |
851 |
assert resp.json['err'] == 0
|
741 |
|
assert resp.json['data']['firstname'] == 'CASSANDRA'
|
|
852 |
assert resp.json['data']['firstname'] == 'JANNIS'
|
742 |
853 |
|
743 |
854 |
|
744 |
855 |
def test_read_child_not_linked_error(con, app):
|
745 |
856 |
url = get_endpoint('read-child')
|
746 |
857 |
|
747 |
858 |
resp = app.get(url + '?NameID=local&child_id=613880')
|
748 |
859 |
assert resp.json['err'] == 'not-linked'
|
749 |
860 |
assert resp.json['err_desc'] == 'User not linked to family'
|
750 |
861 |
|
751 |
862 |
|
752 |
863 |
@mock.patch('passerelle.utils.Request.get')
|
753 |
864 |
@mock.patch('passerelle.utils.Request.post')
|
754 |
865 |
def test_read_child_not_found(mocked_post, mocked_get, con, app):
|
755 |
866 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
756 |
|
mocked_post.side_effect = [READ_FAMILY, READ_CATEGORIES, READ_SITUATIONS, READ_CIVILITIES, READ_QUALITIES]
|
|
867 |
mocked_post.side_effect = [
|
|
868 |
READ_FAMILY,
|
|
869 |
READ_CATEGORIES,
|
|
870 |
READ_SITUATIONS,
|
|
871 |
READ_CIVILITIES,
|
|
872 |
READ_QUALITIES,
|
|
873 |
READ_CSP,
|
|
874 |
]
|
757 |
875 |
url = get_endpoint('read-child')
|
758 |
876 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
759 |
877 |
|
760 |
878 |
resp = app.get(url + '?NameID=local&child_id=000000')
|
761 |
879 |
assert resp.json['err'] == 'not-found'
|
762 |
880 |
assert resp.json['err_desc'] == "no '000000' child on '1312' family"
|
763 |
881 |
|
764 |
882 |
|
... | ... | |
772 |
890 |
@mock.patch('passerelle.utils.Request.get')
|
773 |
891 |
@mock.patch('passerelle.utils.Request.post')
|
774 |
892 |
def test_is_rl_exists(mocked_post, mocked_get, post_response, result, con, app):
|
775 |
893 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
776 |
894 |
mocked_post.return_value = post_response
|
777 |
895 |
url = get_endpoint('is-rl-exists')
|
778 |
896 |
|
779 |
897 |
params = {
|
780 |
|
'firstname': 'Damien',
|
781 |
|
'lastname': 'Costanze',
|
782 |
|
'dateBirth': '1980-10-07',
|
|
898 |
'firstname': 'Jhon',
|
|
899 |
'lastname': 'Doe',
|
|
900 |
'dateBirth': '1938-07-26',
|
783 |
901 |
}
|
784 |
902 |
resp = app.post_json(url, params=params)
|
785 |
903 |
assert resp.json['err'] == 0
|
786 |
904 |
assert resp.json['data'] == result
|
787 |
905 |
|
788 |
906 |
|
789 |
907 |
def test_is_rl_exists_schema_error(con, app):
|
790 |
908 |
url = get_endpoint('is-rl-exists')
|
791 |
909 |
|
792 |
910 |
params = {
|
793 |
|
'firstname': 'Damien',
|
794 |
|
'lastname': 'Costanze',
|
795 |
|
'dateBirth': '1980-10-07 more text',
|
|
911 |
'firstname': 'Jhon',
|
|
912 |
'lastname': 'Doe',
|
|
913 |
'dateBirth': '1938-07-26 more text',
|
796 |
914 |
}
|
797 |
915 |
resp = app.post_json(url, params=params, status=400)
|
798 |
916 |
assert resp.json['err'] == 1
|
799 |
917 |
assert "does not match '^[0-9]{4}-[0-9]{2}-[0-9]{2}$'" in resp.json['err_desc']
|
800 |
918 |
|
801 |
919 |
|
802 |
920 |
@pytest.mark.parametrize(
|
803 |
921 |
'post_response, result',
|
... | ... | |
809 |
927 |
@mock.patch('passerelle.utils.Request.get')
|
810 |
928 |
@mock.patch('passerelle.utils.Request.post')
|
811 |
929 |
def test_is_child_exists(mocked_post, mocked_get, post_response, result, con, app):
|
812 |
930 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
813 |
931 |
mocked_post.return_value = post_response
|
814 |
932 |
url = get_endpoint('is-child-exists')
|
815 |
933 |
|
816 |
934 |
params = {
|
817 |
|
'firstname': 'Cassandra',
|
818 |
|
'lastname': 'Costanze',
|
819 |
|
'dateBirth': '2021-06-22',
|
|
935 |
'firstname': 'Doe',
|
|
936 |
'lastname': 'Jhonny allen',
|
|
937 |
'dateBirth': '1942-11-27',
|
820 |
938 |
}
|
821 |
939 |
resp = app.post_json(url, params=params)
|
822 |
940 |
assert resp.json['err'] == 0
|
823 |
941 |
assert resp.json['data'] == result
|
824 |
942 |
|
825 |
943 |
|
826 |
944 |
@mock.patch('passerelle.utils.Request.get')
|
827 |
945 |
@mock.patch('passerelle.utils.Request.post')
|
... | ... | |
1030 |
1148 |
def test_create_person(mocked_post, mocked_get, con, app):
|
1031 |
1149 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1032 |
1150 |
mocked_post.side_effect = [READ_FAMILY, UPDATE_FAMILY]
|
1033 |
1151 |
url = get_endpoint('create-person')
|
1034 |
1152 |
params = {
|
1035 |
1153 |
'civility': None,
|
1036 |
1154 |
'firstname': 'Mathias',
|
1037 |
1155 |
'lastname': 'Cassel',
|
1038 |
|
'quality': 'PERE',
|
|
1156 |
'quality': 'O',
|
1039 |
1157 |
'dateBirth': '1972-01-01',
|
1040 |
1158 |
'contact/phone': None,
|
1041 |
1159 |
'contact/mobile': '0623456789',
|
1042 |
1160 |
'contact/mail': None,
|
1043 |
1161 |
}
|
1044 |
1162 |
|
1045 |
1163 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
1046 |
1164 |
resp = app.post_json(url + '?NameID=local&kind=emergency', params=params)
|
... | ... | |
1049 |
1167 |
|
1050 |
1168 |
|
1051 |
1169 |
def test_create_person_wrong_parameter(con, app):
|
1052 |
1170 |
url = get_endpoint('create-person')
|
1053 |
1171 |
params = {
|
1054 |
1172 |
'civility': None,
|
1055 |
1173 |
'firstname': 'Mathias',
|
1056 |
1174 |
'lastname': 'Cassel',
|
1057 |
|
'quality': 'PERE',
|
|
1175 |
'quality': 'O',
|
1058 |
1176 |
'dateBirth': '1972-01-01',
|
1059 |
1177 |
'contact/phone': None,
|
1060 |
1178 |
'contact/mobile': '0623456789',
|
1061 |
1179 |
'contact/mail': None,
|
1062 |
1180 |
}
|
1063 |
1181 |
|
1064 |
1182 |
resp = app.post_json(url + '?NameID=local&kind=baby-sitter', params=params)
|
1065 |
1183 |
assert resp.json['err'] == 1
|
... | ... | |
1067 |
1185 |
|
1068 |
1186 |
|
1069 |
1187 |
def test_create_person_not_linked_error(con, app):
|
1070 |
1188 |
url = get_endpoint('create-person')
|
1071 |
1189 |
params = {
|
1072 |
1190 |
'civility': None,
|
1073 |
1191 |
'firstname': 'Mathias',
|
1074 |
1192 |
'lastname': 'Cassel',
|
1075 |
|
'quality': 'PERE',
|
|
1193 |
'quality': 'O',
|
1076 |
1194 |
'dateBirth': '1972-01-01',
|
1077 |
1195 |
'contact/phone': None,
|
1078 |
1196 |
'contact/mobile': '0623456789',
|
1079 |
1197 |
'contact/mail': None,
|
1080 |
1198 |
}
|
1081 |
1199 |
|
1082 |
1200 |
resp = app.post_json(url + '?NameID=local&kind=emergency', params=params)
|
1083 |
1201 |
assert resp.json['err'] == 'not-linked'
|
... | ... | |
1089 |
1207 |
def test_update_person(mocked_post, mocked_get, con, app):
|
1090 |
1208 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1091 |
1209 |
mocked_post.side_effect = [READ_FAMILY, UPDATE_FAMILY]
|
1092 |
1210 |
url = get_endpoint('update-person')
|
1093 |
1211 |
params = {
|
1094 |
1212 |
'civility': None,
|
1095 |
1213 |
'firstname': 'Mathias',
|
1096 |
1214 |
'lastname': 'Cassel',
|
1097 |
|
'quality': 'PERE',
|
|
1215 |
'quality': 'O',
|
1098 |
1216 |
'dateBirth': '1972-01-01',
|
1099 |
1217 |
'contact/phone': None,
|
1100 |
1218 |
'contact/mobile': '0623456789',
|
1101 |
1219 |
'contact/mail': None,
|
1102 |
1220 |
}
|
1103 |
1221 |
|
1104 |
1222 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
1105 |
1223 |
resp = app.post_json(url + '?NameID=local&person_id=614059&kind=emergency', params=params)
|
... | ... | |
1108 |
1226 |
|
1109 |
1227 |
|
1110 |
1228 |
def test_update_person_wrong_parameter(con, app):
|
1111 |
1229 |
url = get_endpoint('update-person')
|
1112 |
1230 |
params = {
|
1113 |
1231 |
'civility': None,
|
1114 |
1232 |
'firstname': 'Mathias',
|
1115 |
1233 |
'lastname': 'Cassel',
|
1116 |
|
'quality': 'PERE',
|
|
1234 |
'quality': 'O',
|
1117 |
1235 |
'dateBirth': '1972-01-01',
|
1118 |
1236 |
'contact/phone': None,
|
1119 |
1237 |
'contact/mobile': '0623456789',
|
1120 |
1238 |
'contact/mail': None,
|
1121 |
1239 |
}
|
1122 |
1240 |
|
1123 |
1241 |
resp = app.post_json(url + '?NameID=local&person_id=614059&kind=baby-sitter', params=params)
|
1124 |
1242 |
assert resp.json['err'] == 1
|
... | ... | |
1126 |
1244 |
|
1127 |
1245 |
|
1128 |
1246 |
def test_update_person_not_linked_error(con, app):
|
1129 |
1247 |
url = get_endpoint('update-person')
|
1130 |
1248 |
params = {
|
1131 |
1249 |
'civility': None,
|
1132 |
1250 |
'firstname': 'Mathias',
|
1133 |
1251 |
'lastname': 'Cassel',
|
1134 |
|
'quality': 'PERE',
|
|
1252 |
'quality': 'O',
|
1135 |
1253 |
'dateBirth': '1972-01-01',
|
1136 |
1254 |
'contact/phone': None,
|
1137 |
1255 |
'contact/mobile': '0623456789',
|
1138 |
1256 |
'contact/mail': None,
|
1139 |
1257 |
}
|
1140 |
1258 |
|
1141 |
1259 |
resp = app.post_json(url + '?NameID=local&person_id=614059&kind=emergency', params=params)
|
1142 |
1260 |
assert resp.json['err'] == 'not-linked'
|
... | ... | |
1148 |
1266 |
def test_update_person_not_found(mocked_post, mocked_get, con, app):
|
1149 |
1267 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1150 |
1268 |
mocked_post.side_effect = [READ_FAMILY, UPDATE_FAMILY]
|
1151 |
1269 |
url = get_endpoint('update-person')
|
1152 |
1270 |
params = {
|
1153 |
1271 |
'civility': None,
|
1154 |
1272 |
'firstname': 'Mathias',
|
1155 |
1273 |
'lastname': 'Cassel',
|
1156 |
|
'quality': 'PERE',
|
|
1274 |
'quality': 'O',
|
1157 |
1275 |
'dateBirth': '1972-01-01',
|
1158 |
1276 |
'contact/phone': None,
|
1159 |
1277 |
'contact/mobile': '0623456789',
|
1160 |
1278 |
'contact/mail': None,
|
1161 |
1279 |
}
|
1162 |
|
|
1163 |
1280 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
1164 |
1281 |
resp = app.post_json(url + '?NameID=local&person_id=000000&kind=emergency', params=params)
|
1165 |
1282 |
assert resp.json['err'] == 'not-found'
|
1166 |
1283 |
assert resp.json['err_desc'] == "no '000000' authorized person on '1312' family"
|
1167 |
1284 |
|
1168 |
1285 |
|
1169 |
1286 |
@mock.patch('passerelle.utils.Request.get')
|
1170 |
1287 |
@mock.patch('passerelle.utils.Request.post')
|
1171 |
1288 |
def test_delete_person(mocked_post, mocked_get, con, app):
|
1172 |
1289 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1173 |
1290 |
mocked_post.side_effect = [READ_FAMILY, UPDATE_FAMILY]
|
1174 |
1291 |
url = get_endpoint('delete-person')
|
1175 |
1292 |
params = {
|
1176 |
1293 |
'civility': None,
|
1177 |
1294 |
'firstname': 'Mathias',
|
1178 |
1295 |
'lastname': 'Cassel',
|
1179 |
|
'quality': 'PERE',
|
|
1296 |
'quality': 'O',
|
1180 |
1297 |
'dateBirth': '1972-01-01',
|
1181 |
1298 |
'contact/phone': None,
|
1182 |
1299 |
'contact/mobile': '0623456789',
|
1183 |
1300 |
'contact/mail': None,
|
1184 |
1301 |
}
|
1185 |
1302 |
|
1186 |
1303 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
1187 |
1304 |
resp = app.post_json(url + '?NameID=local&person_id=614059&kind=emergency', params=params)
|
... | ... | |
1190 |
1307 |
|
1191 |
1308 |
|
1192 |
1309 |
def test_delete_person_wrong_parameter(con, app):
|
1193 |
1310 |
url = get_endpoint('delete-person')
|
1194 |
1311 |
params = {
|
1195 |
1312 |
'civility': None,
|
1196 |
1313 |
'firstname': 'Mathias',
|
1197 |
1314 |
'lastname': 'Cassel',
|
1198 |
|
'quality': 'PERE',
|
|
1315 |
'quality': 'O',
|
1199 |
1316 |
'dateBirth': '1972-01-01',
|
1200 |
1317 |
'contact/phone': None,
|
1201 |
1318 |
'contact/mobile': '0623456789',
|
1202 |
1319 |
'contact/mail': None,
|
1203 |
1320 |
}
|
1204 |
1321 |
|
1205 |
1322 |
resp = app.post_json(url + '?NameID=local&person_id=614059&kind=baby-sitter', params=params)
|
1206 |
1323 |
assert resp.json['err'] == 1
|
... | ... | |
1208 |
1325 |
|
1209 |
1326 |
|
1210 |
1327 |
def test_delete_person_not_linked_error(con, app):
|
1211 |
1328 |
url = get_endpoint('delete-person')
|
1212 |
1329 |
params = {
|
1213 |
1330 |
'civility': None,
|
1214 |
1331 |
'firstname': 'Mathias',
|
1215 |
1332 |
'lastname': 'Cassel',
|
1216 |
|
'quality': 'PERE',
|
|
1333 |
'quality': 'O',
|
1217 |
1334 |
'dateBirth': '1972-01-01',
|
1218 |
1335 |
'contact/phone': None,
|
1219 |
1336 |
'contact/mobile': '0623456789',
|
1220 |
1337 |
'contact/mail': None,
|
1221 |
1338 |
}
|
1222 |
1339 |
|
1223 |
1340 |
resp = app.post_json(url + '?NameID=local&person_id=614059&kind=emergency', params=params)
|
1224 |
1341 |
assert resp.json['err'] == 'not-linked'
|
... | ... | |
1230 |
1347 |
def test_delete_person_not_found(mocked_post, mocked_get, con, app):
|
1231 |
1348 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1232 |
1349 |
mocked_post.side_effect = [READ_FAMILY, UPDATE_FAMILY]
|
1233 |
1350 |
url = get_endpoint('delete-person')
|
1234 |
1351 |
params = {
|
1235 |
1352 |
'civility': None,
|
1236 |
1353 |
'firstname': 'Mathias',
|
1237 |
1354 |
'lastname': 'Cassel',
|
1238 |
|
'quality': 'PERE',
|
|
1355 |
'quality': 'O',
|
1239 |
1356 |
'dateBirth': '1972-01-01',
|
1240 |
1357 |
'contact/phone': None,
|
1241 |
1358 |
'contact/mobile': '0623456789',
|
1242 |
1359 |
'contact/mail': None,
|
1243 |
1360 |
}
|
1244 |
1361 |
|
1245 |
1362 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
1246 |
1363 |
resp = app.post_json(url + '?NameID=local&person_id=000000&kind=emergency', params=params)
|
1247 |
|
-
|