Projet

Général

Profil

0003-toulouse-maelis-check-WS-payload-first-70982.patch

Nicolas Roche (absent jusqu'au 3 avril), 08 décembre 2022 17:28

Télécharger (24,3 ko)

Voir les différences:

Subject: [PATCH 3/7] toulouse-maelis: check WS payload first (#70982)

 passerelle/contrib/toulouse_maelis/models.py | 18 +++++-----
 tests/test_toulouse_maelis.py                | 38 ++++++++++----------
 2 files changed, 28 insertions(+), 28 deletions(-)
passerelle/contrib/toulouse_maelis/models.py
717 717
        description='Modification du RL1',
718 718
        name='update-rl1',
719 719
        perm='can_access',
720 720
        parameters={'NameID': {'description': 'Publik NameID'}},
721 721
        post={'request_body': {'schema': {'application/json': schemas.UPDATE_RL1_SCHEMA}}},
722 722
    )
723 723
    def update_rl1(self, request, NameID, post_data):
724 724
        family_id = self.get_link(NameID).family_id
725
        family = self.get_family_raw(family_id)
726 725
        self.assert_rl_payload_in_referential(post_data)
727 726
        self.replace_null_values(post_data)
727
        family = self.get_family_raw(family_id)
728 728

  
729 729
        rl1 = post_data
730 730
        rl1['adresse'] = family['RL1']['adresse']
731 731
        payload = {
732 732
            'dossierNumber': family_id,
733 733
            'category': family['category'],
734 734
            'situation': family['situation'],
735 735
            'flagCom': family['flagCom'],
......
746 746
        description='Création du RL2',
747 747
        name='create-rl2',
748 748
        perm='can_access',
749 749
        parameters={'NameID': {'description': 'Publik NameID'}},
750 750
        post={'request_body': {'schema': {'application/json': schemas.CREATE_RL2_SCHEMA}}},
751 751
    )
752 752
    def create_rl2(self, request, NameID, post_data):
753 753
        family_id = self.get_link(NameID).family_id
754
        self.assert_rl_payload_in_referential(post_data)
754 755
        family = self.get_family_raw(family_id)
755 756
        if family['RL2']:
756 757
            raise APIError('RL2 already defined on family', err_code='already-rl2')
757
        self.assert_rl_payload_in_referential(post_data)
758 758

  
759 759
        payload = {
760 760
            'dossierNumber': family_id,
761 761
            'category': family['category'],
762 762
            'situation': family['situation'],
763 763
            'flagCom': family['flagCom'],
764 764
            'nbChild': family['nbChild'],
765 765
            'nbTotalChild': family['nbTotalChild'],
......
774 774
        description='Modification du RL2',
775 775
        name='update-rl2',
776 776
        perm='can_access',
777 777
        parameters={'NameID': {'description': 'Publik NameID'}},
778 778
        post={'request_body': {'schema': {'application/json': schemas.UPDATE_RL2_SCHEMA}}},
779 779
    )
780 780
    def update_rl2(self, request, NameID, post_data):
781 781
        family_id = self.get_link(NameID).family_id
782
        self.assert_rl_payload_in_referential(post_data)
783
        self.replace_null_values(post_data)
782 784
        family = self.get_family_raw(family_id)
783 785
        if not family['RL2']:
784 786
            raise APIError('No RL2 to update on family', err_code='no-rl2')
785
        self.assert_rl_payload_in_referential(post_data)
786
        self.replace_null_values(post_data)
787 787

  
788 788
        rl2 = post_data
789 789
        rl2['adresse'] = family['RL2']['adresse']
790 790
        payload = {
791 791
            'dossierNumber': family_id,
792 792
            'category': family['category'],
793 793
            'situation': family['situation'],
794 794
            'flagCom': family['flagCom'],
......
840 840
        parameters={
841 841
            'NameID': {'description': 'Publik NameID'},
842 842
            'child_id': {'description': "Numéro de l'enfant"},
843 843
        },
844 844
        post={'request_body': {'schema': {'application/json': schemas.UPDATE_CHILD_SCHEMA}}},
845 845
    )
846 846
    def update_child(self, request, NameID, child_id, post_data):
847 847
        family_id = self.get_link(NameID).family_id
848
        family = self.get_family_raw(family_id)
849 848
        self.assert_child_payload_in_referential(post_data)
850 849
        self.replace_null_values(post_data)
850
        family = self.get_family_raw(family_id)
851 851

  
852 852
        child = post_data
853 853
        child['num'] = child_id
854 854
        for known_child in family['childList']:
855 855
            if str(known_child['num']) == child_id:
856 856
                child['authorizedPersonList'] = known_child['authorizedPersonList']
857 857
                break
858 858
        else:
......
896 896
        perm='can_access',
897 897
        parameters={
898 898
            'NameID': {'description': 'Publik NameID'},
899 899
        },
900 900
        post={'request_body': {'schema': {'application/json': schemas.EMERGENCY_PERSON_SCHEMA}}},
901 901
    )
902 902
    def create_person(self, request, NameID, post_data):
903 903
        family_id = self.get_link(NameID).family_id
904
        family = self.get_family_raw(family_id)
905 904
        self.assert_person_payload_in_referential(post_data)
905
        family = self.get_family_raw(family_id)
906 906

  
907 907
        personList = family['emergencyPersonList']
908 908
        personList.append(post_data)
909 909
        payload = {
910 910
            'dossierNumber': family_id,
911 911
            'category': family['category'],
912 912
            'situation': family['situation'],
913 913
            'flagCom': family['flagCom'],
......
927 927
        parameters={
928 928
            'NameID': {'description': 'Publik NameID'},
929 929
            'person_id': {'description': 'Numéro de la personne'},
930 930
        },
931 931
        post={'request_body': {'schema': {'application/json': schemas.EMERGENCY_PERSON_SCHEMA}}},
932 932
    )
933 933
    def update_person(self, request, NameID, person_id, post_data):
934 934
        family_id = self.get_link(NameID).family_id
935
        family = self.get_family_raw(family_id)
936 935
        self.assert_person_payload_in_referential(post_data)
936
        family = self.get_family_raw(family_id)
937 937

  
938 938
        personList = family['emergencyPersonList']
939 939
        for i, person in enumerate(personList):
940 940
            if str(person['numPerson']) == person_id:
941 941
                personList[i] = post_data
942 942
                personList[i]['numPerson'] = person_id
943 943
                break
944 944
        else:
......
1003 1003
        parameters={
1004 1004
            'NameID': {'description': 'Publik NameID'},
1005 1005
            'child_id': {'description': "Numéro de l'enfant"},
1006 1006
        },
1007 1007
        post={'request_body': {'schema': {'application/json': schemas.AUTHORIZED_PERSON_SCHEMA}}},
1008 1008
    )
1009 1009
    def create_child_person(self, request, NameID, child_id, post_data):
1010 1010
        family_id = self.get_link(NameID).family_id
1011
        child = self.get_child_raw(family_id, child_id)
1012 1011
        self.assert_child_person_payload_in_referential(post_data)
1012
        child = self.get_child_raw(family_id, child_id)
1013 1013

  
1014 1014
        personList = child['authorizedPersonList']
1015 1015
        personList.append(post_data)
1016 1016
        req = {
1017 1017
            'numFamily': family_id,
1018 1018
            'numPerson': child_id,
1019 1019
            'bLeaveAlone': child['bLeaveAlone'],
1020 1020
            'bPhoto': child['bPhoto'],
......
1032 1032
            'NameID': {'description': 'Publik NameID'},
1033 1033
            'child_id': {'description': "Numéro de l'enfant"},
1034 1034
            'person_id': {'description': 'Numéro de la personne'},
1035 1035
        },
1036 1036
        post={'request_body': {'schema': {'application/json': schemas.AUTHORIZED_PERSON_SCHEMA}}},
1037 1037
    )
1038 1038
    def update_child_person(self, request, NameID, child_id, person_id, post_data):
1039 1039
        family_id = self.get_link(NameID).family_id
1040
        child = self.get_child_raw(family_id, child_id)
1041 1040
        self.assert_child_person_payload_in_referential(post_data)
1041
        child = self.get_child_raw(family_id, child_id)
1042 1042

  
1043 1043
        personList = child['authorizedPersonList']
1044 1044
        for i, person in enumerate(personList):
1045 1045
            if str(person['personInfo']['num']) == person_id:
1046 1046
                personList[i] = post_data
1047 1047
                personList[i]['personInfo']['num'] = person_id
1048 1048
                break
1049 1049
        else:
tests/test_toulouse_maelis.py
1641 1641
    assert resp.json['err'] == 'already-rl1'
1642 1642
    assert 'Il existe déjà' in resp.json['err_desc']
1643 1643

  
1644 1644

  
1645 1645
@mock.patch('passerelle.utils.Request.get')
1646 1646
@mock.patch('passerelle.utils.Request.post')
1647 1647
def test_update_rl1(mocked_post, mocked_get, con, app):
1648 1648
    mocked_get.return_value = FAMILY_SERVICE_WSDL
1649
    mocked_post.side_effect = [READ_RL1_FAMILY, READ_CIVILITIES, READ_QUALITIES, UPDATE_FAMILY]
1649
    mocked_post.side_effect = [READ_CIVILITIES, READ_QUALITIES, READ_RL1_FAMILY, UPDATE_FAMILY]
1650 1650
    url = get_endpoint('update-rl1')
1651 1651
    params = {
1652 1652
        'civility': 'M.',
1653 1653
        'firstname': 'Jhonny',
1654 1654
        'lastname': 'Doe',
1655 1655
        'quality': 'PERE',
1656 1656
        'birth/dateBirth': '1943-06-15',
1657 1657
    }
......
1696 1696
    assert resp.json['err']
1697 1697
    assert resp.json['err_desc'] == 'No address associated with hostname'
1698 1698

  
1699 1699

  
1700 1700
@mock.patch('passerelle.utils.Request.get')
1701 1701
@mock.patch('passerelle.utils.Request.post')
1702 1702
def test_update_rl1_wrong_referential_key_error(mocked_post, mocked_get, con, app):
1703 1703
    mocked_get.return_value = FAMILY_SERVICE_WSDL
1704
    mocked_post.side_effect = [READ_FAMILY, READ_CIVILITIES, READ_QUALITIES]
1704
    mocked_post.side_effect = [READ_CIVILITIES, READ_QUALITIES]
1705 1705
    url = get_endpoint('update-rl1')
1706 1706
    params = {
1707 1707
        'civility': 'M.',
1708 1708
        'firstname': 'Jhonny',
1709 1709
        'lastname': 'Doe',
1710 1710
        'quality': 'plop',
1711 1711
        'birth/dateBirth': '1943-06-15',
1712 1712
    }
......
1716 1716
    assert resp.json['err'] == 'wrong-key'
1717 1717
    assert resp.json['err_desc'] == "quality key value 'plop' do not belong to 'Quality' required referential"
1718 1718

  
1719 1719

  
1720 1720
@mock.patch('passerelle.utils.Request.get')
1721 1721
@mock.patch('passerelle.utils.Request.post')
1722 1722
def test_create_rl2(mocked_post, mocked_get, con, app):
1723 1723
    mocked_get.return_value = FAMILY_SERVICE_WSDL
1724
    mocked_post.side_effect = [READ_RL1_FAMILY, READ_CIVILITIES, READ_QUALITIES, UPDATE_FAMILY]
1724
    mocked_post.side_effect = [READ_CIVILITIES, READ_QUALITIES, READ_RL1_FAMILY, UPDATE_FAMILY]
1725 1725
    url = get_endpoint('create-rl2')
1726 1726
    params = {
1727 1727
        'civility': 'MME',
1728 1728
        'firstname': 'JANE',
1729 1729
        'lastname': 'DOE',
1730 1730
        'maidenName': 'Smith',
1731 1731
        'quality': 'MERE',
1732 1732
        'birth/dateBirth': '1940-06-22',
......
1787 1787
    assert resp.json['err']
1788 1788
    assert resp.json['err_desc'] == 'No address associated with hostname'
1789 1789

  
1790 1790

  
1791 1791
@mock.patch('passerelle.utils.Request.get')
1792 1792
@mock.patch('passerelle.utils.Request.post')
1793 1793
def test_create_rl2_already_exists_error(mocked_post, mocked_get, con, app):
1794 1794
    mocked_get.return_value = FAMILY_SERVICE_WSDL
1795
    mocked_post.return_value = READ_FAMILY
1795
    mocked_post.side_effect = [READ_CIVILITIES, READ_QUALITIES, READ_FAMILY, READ_FAMILY]
1796 1796
    url = get_endpoint('create-rl2')
1797 1797
    params = {
1798 1798
        'civility': 'MME',
1799 1799
        'firstname': 'JANE',
1800 1800
        'lastname': 'DOE',
1801 1801
        'maidenName': 'Smith',
1802 1802
        'quality': 'MERE',
1803 1803
        'birth/dateBirth': '1940-06-22',
......
1812 1812
    assert resp.json['err'] == 'already-rl2'
1813 1813
    assert resp.json['err_desc'] == 'RL2 already defined on family'
1814 1814

  
1815 1815

  
1816 1816
@mock.patch('passerelle.utils.Request.get')
1817 1817
@mock.patch('passerelle.utils.Request.post')
1818 1818
def test_create_rl2_wrong_referential_key_error(mocked_post, mocked_get, con, app):
1819 1819
    mocked_get.return_value = FAMILY_SERVICE_WSDL
1820
    mocked_post.side_effect = [READ_RL1_FAMILY, READ_CIVILITIES, READ_QUALITIES]
1820
    mocked_post.side_effect = [READ_CIVILITIES, READ_QUALITIES, READ_RL1_FAMILY]
1821 1821
    url = get_endpoint('create-rl2')
1822 1822
    params = {
1823 1823
        'civility': 'MME',
1824 1824
        'firstname': 'JANE',
1825 1825
        'lastname': 'DOE',
1826 1826
        'maidenName': 'Smith',
1827 1827
        'quality': 'plop',
1828 1828
        'birth/dateBirth': '1940-06-22',
......
1837 1837
    assert resp.json['err'] == 'wrong-key'
1838 1838
    assert resp.json['err_desc'] == "quality key value 'plop' do not belong to 'Quality' required referential"
1839 1839

  
1840 1840

  
1841 1841
@mock.patch('passerelle.utils.Request.get')
1842 1842
@mock.patch('passerelle.utils.Request.post')
1843 1843
def test_update_rl2(mocked_post, mocked_get, con, app):
1844 1844
    mocked_get.return_value = FAMILY_SERVICE_WSDL
1845
    mocked_post.side_effect = [READ_FAMILY, READ_CIVILITIES, READ_QUALITIES, UPDATE_FAMILY]
1845
    mocked_post.side_effect = [READ_CIVILITIES, READ_QUALITIES, READ_FAMILY, UPDATE_FAMILY]
1846 1846
    url = get_endpoint('update-rl2')
1847 1847
    params = {
1848 1848
        'civility': 'MME',
1849 1849
        'firstname': 'JANE',
1850 1850
        'lastname': 'DOE',
1851 1851
        'maidenName': 'Smith',
1852 1852
        'quality': 'MERE',
1853 1853
        'birth/dateBirth': '1940-06-22',
......
1895 1895
    assert resp.json['err']
1896 1896
    assert resp.json['err_desc'] == 'No address associated with hostname'
1897 1897

  
1898 1898

  
1899 1899
@mock.patch('passerelle.utils.Request.get')
1900 1900
@mock.patch('passerelle.utils.Request.post')
1901 1901
def test_update_rl2_not_exists_error(mocked_post, mocked_get, con, app):
1902 1902
    mocked_get.return_value = FAMILY_SERVICE_WSDL
1903
    mocked_post.return_value = READ_RL1_FAMILY
1903
    mocked_post.side_effect = [READ_CIVILITIES, READ_QUALITIES, READ_RL1_FAMILY]
1904 1904
    url = get_endpoint('update-rl2')
1905 1905
    params = {
1906 1906
        'civility': 'MME',
1907 1907
        'firstname': 'JANE',
1908 1908
        'lastname': 'DOE',
1909 1909
        'maidenName': 'Smith',
1910 1910
        'quality': 'MERE',
1911 1911
        'birth/dateBirth': '1940-06-22',
......
1916 1916
    assert resp.json['err'] == 'no-rl2'
1917 1917
    assert resp.json['err_desc'] == 'No RL2 to update on family'
1918 1918

  
1919 1919

  
1920 1920
@mock.patch('passerelle.utils.Request.get')
1921 1921
@mock.patch('passerelle.utils.Request.post')
1922 1922
def test_update_rl2_wrong_referential_key_error(mocked_post, mocked_get, con, app):
1923 1923
    mocked_get.return_value = FAMILY_SERVICE_WSDL
1924
    mocked_post.side_effect = [READ_FAMILY, READ_CIVILITIES, READ_QUALITIES]
1924
    mocked_post.side_effect = [READ_CIVILITIES, READ_QUALITIES]
1925 1925
    url = get_endpoint('update-rl2')
1926 1926
    params = {
1927 1927
        'civility': 'MME',
1928 1928
        'firstname': 'JANE',
1929 1929
        'lastname': 'DOE',
1930 1930
        'maidenName': 'Smith',
1931 1931
        'quality': 'plop',
1932 1932
        'birth/dateBirth': '1940-06-22',
......
2218 2218
        resp.json['err_desc'] == "adresse/numComp key value 'plop' do not belong to 'Complement' referential"
2219 2219
    )
2220 2220

  
2221 2221

  
2222 2222
@mock.patch('passerelle.utils.Request.get')
2223 2223
@mock.patch('passerelle.utils.Request.post')
2224 2224
def test_create_person(mocked_post, mocked_get, con, app):
2225 2225
    mocked_get.return_value = FAMILY_SERVICE_WSDL
2226
    mocked_post.side_effect = [READ_FAMILY, READ_QUALITIES, UPDATE_FAMILY]
2226
    mocked_post.side_effect = [READ_QUALITIES, READ_FAMILY, UPDATE_FAMILY]
2227 2227
    url = get_endpoint('create-person')
2228 2228
    params = {
2229 2229
        'civility': None,
2230 2230
        'firstname': 'Mathias',
2231 2231
        'lastname': 'Cassel',
2232 2232
        'quality': 'O',
2233 2233
        'sexe': 'M',
2234 2234
        'dateBirth': '1972-01-01',
......
2298 2298
    assert resp.json['err'] == 'not-linked'
2299 2299
    assert resp.json['err_desc'] == 'User not linked to family'
2300 2300

  
2301 2301

  
2302 2302
@mock.patch('passerelle.utils.Request.get')
2303 2303
@mock.patch('passerelle.utils.Request.post')
2304 2304
def test_create_person_wrong_referential_key_error(mocked_post, mocked_get, con, app):
2305 2305
    mocked_get.return_value = FAMILY_SERVICE_WSDL
2306
    mocked_post.side_effect = [READ_FAMILY, READ_QUALITIES, UPDATE_FAMILY]
2306
    mocked_post.side_effect = [READ_QUALITIES]
2307 2307
    url = get_endpoint('create-person')
2308 2308
    params = {
2309 2309
        'civility': None,
2310 2310
        'firstname': 'Mathias',
2311 2311
        'lastname': 'Cassel',
2312 2312
        'quality': 'O',
2313 2313
        'sexe': 'plop',
2314 2314
        'dateBirth': '1972-01-01',
......
2322 2322
    assert resp.json['err'] == 'wrong-key'
2323 2323
    assert resp.json['err_desc'] == "sexe key value 'plop' do not belong to 'Sex' referential"
2324 2324

  
2325 2325

  
2326 2326
@mock.patch('passerelle.utils.Request.get')
2327 2327
@mock.patch('passerelle.utils.Request.post')
2328 2328
def test_update_person(mocked_post, mocked_get, con, app):
2329 2329
    mocked_get.return_value = FAMILY_SERVICE_WSDL
2330
    mocked_post.side_effect = [READ_FAMILY, READ_QUALITIES, UPDATE_FAMILY]
2330
    mocked_post.side_effect = [READ_QUALITIES, READ_FAMILY, UPDATE_FAMILY]
2331 2331
    url = get_endpoint('update-person')
2332 2332
    params = {
2333 2333
        'civility': None,
2334 2334
        'firstname': 'Mathias',
2335 2335
        'lastname': 'Cassel',
2336 2336
        'quality': 'O',
2337 2337
        'sexe': 'M',
2338 2338
        'dateBirth': '1972-01-01',
......
2365 2365
    assert resp.json['err'] == 'not-linked'
2366 2366
    assert resp.json['err_desc'] == 'User not linked to family'
2367 2367

  
2368 2368

  
2369 2369
@mock.patch('passerelle.utils.Request.get')
2370 2370
@mock.patch('passerelle.utils.Request.post')
2371 2371
def test_update_person_not_found(mocked_post, mocked_get, con, app):
2372 2372
    mocked_get.return_value = FAMILY_SERVICE_WSDL
2373
    mocked_post.side_effect = [READ_FAMILY, READ_QUALITIES]
2373
    mocked_post.side_effect = [READ_QUALITIES, READ_FAMILY]
2374 2374
    url = get_endpoint('update-person')
2375 2375
    params = {
2376 2376
        'civility': None,
2377 2377
        'firstname': 'Mathias',
2378 2378
        'lastname': 'Cassel',
2379 2379
        'quality': 'O',
2380 2380
        'sexe': 'M',
2381 2381
        'dateBirth': '1972-01-01',
......
2422 2422
    assert resp.json['err'] == 'not-found'
2423 2423
    assert resp.json['err_desc'] == "no '000000' authorized person on '1312' family"
2424 2424

  
2425 2425

  
2426 2426
@mock.patch('passerelle.utils.Request.get')
2427 2427
@mock.patch('passerelle.utils.Request.post')
2428 2428
def test_create_child_person(mocked_post, mocked_get, con, app):
2429 2429
    mocked_get.return_value = FAMILY_SERVICE_WSDL
2430
    mocked_post.side_effect = [READ_FAMILY, READ_CIVILITIES, READ_QUALITIES, UPDATE_CHILD_AUTO]
2430
    mocked_post.side_effect = [READ_CIVILITIES, READ_QUALITIES, READ_FAMILY, UPDATE_CHILD_AUTO]
2431 2431
    url = get_endpoint('create-child-person')
2432 2432
    params = {
2433 2433
        'personInfo/civility': 'MME',
2434 2434
        'personInfo/firstname': 'Diana',
2435 2435
        'personInfo/lastname': 'Ross',
2436 2436
        'personInfo/sexe': 'F',
2437 2437
        'personInfo/dateBirth': '1944-03-26',
2438 2438
        'personInfo/contact/phone': '0199999999',
......
2484 2484
    assert resp.json['err'] == 'not-linked'
2485 2485
    assert resp.json['err_desc'] == 'User not linked to family'
2486 2486

  
2487 2487

  
2488 2488
@mock.patch('passerelle.utils.Request.get')
2489 2489
@mock.patch('passerelle.utils.Request.post')
2490 2490
def test_create_child_person_wrong_referential_key_error(mocked_post, mocked_get, con, app):
2491 2491
    mocked_get.return_value = FAMILY_SERVICE_WSDL
2492
    mocked_post.side_effect = [READ_FAMILY, READ_CIVILITIES]
2492
    mocked_post.side_effect = [READ_CIVILITIES]
2493 2493
    url = get_endpoint('create-child-person')
2494 2494
    params = {
2495 2495
        'personInfo/civility': 'MME',
2496 2496
        'personInfo/firstname': 'Diana',
2497 2497
        'personInfo/lastname': 'Ross',
2498 2498
        'personInfo/sexe': 'plop',
2499 2499
        'personInfo/dateBirth': '1944-03-26',
2500 2500
        'personInfo/contact/phone': '0199999999',
......
2508 2508
    assert resp.json['err'] == 'wrong-key'
2509 2509
    assert resp.json['err_desc'] == "personInfo/sexe key value 'plop' do not belong to 'Sex' referential"
2510 2510

  
2511 2511

  
2512 2512
@mock.patch('passerelle.utils.Request.get')
2513 2513
@mock.patch('passerelle.utils.Request.post')
2514 2514
def test_create_child_person_no_child_error(mocked_post, mocked_get, con, app):
2515 2515
    mocked_get.return_value = FAMILY_SERVICE_WSDL
2516
    mocked_post.side_effect = [READ_FAMILY]
2516
    mocked_post.side_effect = [READ_CIVILITIES, READ_QUALITIES, READ_FAMILY]
2517 2517
    url = get_endpoint('create-child-person')
2518 2518
    params = {
2519 2519
        'personInfo/civility': 'MME',
2520 2520
        'personInfo/firstname': 'Diana',
2521 2521
        'personInfo/lastname': 'Ross',
2522 2522
        'personInfo/sexe': 'F',
2523 2523
        'personInfo/dateBirth': '1944-03-26',
2524 2524
        'personInfo/contact/phone': '01999999999',
......
2532 2532
    assert resp.json['err'] == 'not-found'
2533 2533
    assert resp.json['err_desc'] == "no '42' child on '1312' family"
2534 2534

  
2535 2535

  
2536 2536
@mock.patch('passerelle.utils.Request.get')
2537 2537
@mock.patch('passerelle.utils.Request.post')
2538 2538
def test_update_child_person(mocked_post, mocked_get, con, app):
2539 2539
    mocked_get.return_value = FAMILY_SERVICE_WSDL
2540
    mocked_post.side_effect = [READ_FAMILY, READ_CIVILITIES, READ_QUALITIES, UPDATE_FAMILY]
2540
    mocked_post.side_effect = [READ_CIVILITIES, READ_QUALITIES, READ_FAMILY, UPDATE_FAMILY]
2541 2541
    url = get_endpoint('update-child-person')
2542 2542
    params = {
2543 2543
        'personInfo/civility': 'M.',
2544 2544
        'personInfo/firstname': 'Angelo',
2545 2545
        'personInfo/lastname': 'Bent',
2546 2546
        'personInfo/sexe': 'M',
2547 2547
        'personInfo/dateBirth': '1985-06-22',
2548 2548
        'personInfo/contact/phone': '0102030405',
......
2574 2574
    assert resp.json['err'] == 'not-linked'
2575 2575
    assert resp.json['err_desc'] == 'User not linked to family'
2576 2576

  
2577 2577

  
2578 2578
@mock.patch('passerelle.utils.Request.get')
2579 2579
@mock.patch('passerelle.utils.Request.post')
2580 2580
def test_update_child_person_wrong_referential_key_error(mocked_post, mocked_get, con, app):
2581 2581
    mocked_get.return_value = FAMILY_SERVICE_WSDL
2582
    mocked_post.side_effect = [READ_FAMILY, READ_CIVILITIES, READ_QUALITIES, UPDATE_FAMILY]
2582
    mocked_post.side_effect = [READ_CIVILITIES, READ_QUALITIES]
2583 2583
    url = get_endpoint('update-child-person')
2584 2584
    params = {
2585 2585
        'personInfo/civility': 'M.',
2586 2586
        'personInfo/firstname': 'Angelo',
2587 2587
        'personInfo/lastname': 'Bent',
2588 2588
        'personInfo/sexe': 'plop',
2589 2589
        'personInfo/dateBirth': '1985-06-22',
2590 2590
        'personInfo/contact/phone': '0102030405',
......
2598 2598
    assert resp.json['err'] == 'wrong-key'
2599 2599
    assert resp.json['err_desc'] == "personInfo/sexe key value 'plop' do not belong to 'Sex' referential"
2600 2600

  
2601 2601

  
2602 2602
@mock.patch('passerelle.utils.Request.get')
2603 2603
@mock.patch('passerelle.utils.Request.post')
2604 2604
def test_update_child_person_no_child_error(mocked_post, mocked_get, con, app):
2605 2605
    mocked_get.return_value = FAMILY_SERVICE_WSDL
2606
    mocked_post.side_effect = [READ_FAMILY, READ_CIVILITIES, READ_QUALITIES, READ_QUALITIES]
2606
    mocked_post.side_effect = [READ_CIVILITIES, READ_QUALITIES, READ_FAMILY]
2607 2607
    url = get_endpoint('update-child-person')
2608 2608
    params = {
2609 2609
        'personInfo/civility': 'M.',
2610 2610
        'personInfo/firstname': 'Angelo',
2611 2611
        'personInfo/lastname': 'Bent',
2612 2612
        'personInfo/dateBirth': '1985-06-22',
2613 2613
        'personInfo/contact/phone': '0102030405',
2614 2614
        'personInfo/contact/mobile': None,
......
2621 2621
    assert resp.json['err'] == 'not-found'
2622 2622
    assert resp.json['err_desc'] == "no '42' child on '1312' family"
2623 2623

  
2624 2624

  
2625 2625
@mock.patch('passerelle.utils.Request.get')
2626 2626
@mock.patch('passerelle.utils.Request.post')
2627 2627
def test_update_child_person_not_found(mocked_post, mocked_get, con, app):
2628 2628
    mocked_get.return_value = FAMILY_SERVICE_WSDL
2629
    mocked_post.side_effect = [READ_FAMILY, READ_CIVILITIES, READ_QUALITIES, READ_QUALITIES]
2629
    mocked_post.side_effect = [READ_CIVILITIES, READ_QUALITIES, READ_FAMILY]
2630 2630
    url = get_endpoint('update-child-person')
2631 2631
    params = {
2632 2632
        'personInfo/civility': 'M.',
2633 2633
        'personInfo/firstname': 'Angelo',
2634 2634
        'personInfo/lastname': 'Bent',
2635 2635
        'personInfo/dateBirth': '1985-06-22',
2636 2636
        'personInfo/contact/phone': '0102030405',
2637 2637
        'personInfo/contact/mobile': None,
2638
-