Projet

Général

Profil

0001-toulouse-maelis-manage-sex-field-on-persons-69926.patch

Nicolas Roche, 05 octobre 2022 18:06

Télécharger (12,2 ko)

Voir les différences:

Subject: [PATCH] toulouse-maelis: manage sex field on persons (#69926)

 passerelle/contrib/toulouse_maelis/models.py         | 1 +
 passerelle/contrib/toulouse_maelis/schemas.py        | 4 ++++
 tests/data/toulouse_maelis/Q_create_child_person.xml | 1 +
 tests/data/toulouse_maelis/Q_create_person.xml       | 1 +
 tests/data/toulouse_maelis/Q_update_child_person.xml | 1 +
 tests/data/toulouse_maelis/Q_update_person.xml       | 1 +
 tests/test_toulouse_maelis.py                        | 9 +++++++++
 7 files changed, 18 insertions(+)
passerelle/contrib/toulouse_maelis/models.py
192 192
                'flImage',
193 193
            ):
194 194
                data['fsl'][key] = bool(data['fsl'][key] == 'O')
195 195
        return data
196 196

  
197 197
    def add_text_value_to_person(self, data):
198 198
        self.add_text_value('Civility', data, ['civility'])
199 199
        self.add_text_value('Quality', data, ['quality'])
200
        self.add_text_value('Sex', data, ['sexe'])
200 201

  
201 202
    def add_text_value_to_rl(self, data):
202 203
        self.add_text_value('Civility', data, ['civility'])
203 204
        self.add_text_value('Quality', data, ['quality'])
204 205
        self.add_text_value('Complement', data, ['adresse', 'numComp'])
205 206
        self.add_text_value('CSP', data, ['profession', 'codeCSP'])
206 207

  
207 208
    def add_text_value_to_family(self, data):
passerelle/contrib/toulouse_maelis/schemas.py
552 552
        'civility': {
553 553
            'description': 'civilité (depuis référenciel)',
554 554
            'oneOf': [{'type': 'null'}, {'type': 'string'}],
555 555
        },
556 556
        'quality': {
557 557
            'description': 'Qualité',
558 558
            'oneOf': [{'type': 'null'}, {'type': 'string'}],
559 559
        },
560
        'sexe': {
561
            'description': 'Sexe',
562
            'oneOf': [{'type': 'null'}, {'type': 'string'}],
563
        },
560 564
        'contact': CONTACTLIGHT_SCHEMA,
561 565
    },
562 566
    'unflatten': True,
563 567
}
564 568
FAMILYPERSON_SCHEMA['properties'].update(ID_PROPERTIES)
565 569

  
566 570
AUTHORIZEDPERSON_SCHEMA = {
567 571
    '$schema': 'http://json-schema.org/draft-04/schema#',
tests/data/toulouse_maelis/Q_create_child_person.xml
32 32
          </personQuality>
33 33
        </personList>
34 34
        <personList>
35 35
          <personInfo>
36 36
            <civility>MME</civility>
37 37
            <lastname>Ross</lastname>
38 38
            <firstname>Diana</firstname>
39 39
            <dateBirth>1944-03-26</dateBirth>
40
            <sexe>F</sexe>
40 41
            <contact>
41 42
              <phone>0199999999</phone>
42 43
              <mobile>0723456789</mobile>
43 44
              <mail>dross@example.org</mail>
44 45
            </contact>
45 46
          </personInfo>
46 47
          <personQuality>
47 48
            <code>TUTEUR</code>
tests/data/toulouse_maelis/Q_create_person.xml
28 28
            <mail>pueblo@example.org</mail>
29 29
          </contact>
30 30
        </personList>
31 31
        <personList>
32 32
          <civility/>
33 33
          <firstname>Mathias</firstname>
34 34
          <lastname>Cassel</lastname>
35 35
          <dateBirth>1972-01-01</dateBirth>
36
          <sexe>M</sexe>
36 37
          <quality>O</quality>
37 38
          <contact>
38 39
            <phone/>
39 40
            <mobile>0623456789</mobile>
40 41
            <mail/>
41 42
          </contact>
42 43
        </personList>
43 44
      </emergencyPersonList>
tests/data/toulouse_maelis/Q_update_child_person.xml
14 14
        <numPerson>613880</numPerson>
15 15
        <personList>
16 16
          <personInfo>
17 17
            <num>614719</num>
18 18
            <civility>M.</civility>
19 19
            <lastname>Bent</lastname>
20 20
            <firstname>Angelo</firstname>
21 21
            <dateBirth>1985-06-22</dateBirth>
22
            <sexe>M</sexe>
22 23
            <contact>
23 24
              <phone>0102030405</phone>
24 25
              <mobile/>
25 26
              <mail/>
26 27
            </contact>
27 28
          </personInfo>
28 29
          <personQuality>
29 30
            <code>O</code>
tests/data/toulouse_maelis/Q_update_person.xml
17 17
      <nbChild>2</nbChild>
18 18
      <emergencyPersonList>
19 19
        <personList>
20 20
          <numPerson>614059</numPerson>
21 21
          <civility/>
22 22
          <firstname>Mathias</firstname>
23 23
          <lastname>Cassel</lastname>
24 24
          <dateBirth>1972-01-01</dateBirth>
25
          <sexe>M</sexe>
25 26
          <quality>O</quality>
26 27
          <contact>
27 28
            <phone/>
28 29
            <mobile>0623456789</mobile>
29 30
            <mail/>
30 31
          </contact>
31 32
        </personList>
32 33
      </emergencyPersonList>
tests/test_toulouse_maelis.py
1654 1654
    mocked_get.return_value = FAMILY_SERVICE_WSDL
1655 1655
    mocked_post.side_effect = [READ_FAMILY, UPDATE_FAMILY]
1656 1656
    url = get_endpoint('create-person')
1657 1657
    params = {
1658 1658
        'civility': None,
1659 1659
        'firstname': 'Mathias',
1660 1660
        'lastname': 'Cassel',
1661 1661
        'quality': 'O',
1662
        'sexe': 'M',
1662 1663
        'dateBirth': '1972-01-01',
1663 1664
        'contact/phone': None,
1664 1665
        'contact/mobile': '0623456789',
1665 1666
        'contact/mail': None,
1666 1667
    }
1667 1668

  
1668 1669
    Link.objects.create(resource=con, family_id='1312', name_id='local')
1669 1670
    resp = app.post_json(url + '?NameID=local', params=params)
......
1673 1674

  
1674 1675
def test_create_person_not_linked_error(con, app):
1675 1676
    url = get_endpoint('create-person')
1676 1677
    params = {
1677 1678
        'civility': None,
1678 1679
        'firstname': 'Mathias',
1679 1680
        'lastname': 'Cassel',
1680 1681
        'quality': 'O',
1682
        'sexe': 'M',
1681 1683
        'dateBirth': '1972-01-01',
1682 1684
        'contact/phone': None,
1683 1685
        'contact/mobile': '0623456789',
1684 1686
        'contact/mail': None,
1685 1687
    }
1686 1688

  
1687 1689
    resp = app.post_json(url + '?NameID=local', params=params)
1688 1690
    assert resp.json['err'] == 'not-linked'
......
1695 1697
    mocked_get.return_value = FAMILY_SERVICE_WSDL
1696 1698
    mocked_post.side_effect = [READ_FAMILY, UPDATE_FAMILY]
1697 1699
    url = get_endpoint('update-person')
1698 1700
    params = {
1699 1701
        'civility': None,
1700 1702
        'firstname': 'Mathias',
1701 1703
        'lastname': 'Cassel',
1702 1704
        'quality': 'O',
1705
        'sexe': 'M',
1703 1706
        'dateBirth': '1972-01-01',
1704 1707
        'contact/phone': None,
1705 1708
        'contact/mobile': '0623456789',
1706 1709
        'contact/mail': None,
1707 1710
    }
1708 1711

  
1709 1712
    Link.objects.create(resource=con, family_id='1312', name_id='local')
1710 1713
    resp = app.post_json(url + '?NameID=local&person_id=614059', params=params)
......
1714 1717

  
1715 1718
def test_update_person_not_linked_error(con, app):
1716 1719
    url = get_endpoint('update-person')
1717 1720
    params = {
1718 1721
        'civility': None,
1719 1722
        'firstname': 'Mathias',
1720 1723
        'lastname': 'Cassel',
1721 1724
        'quality': 'O',
1725
        'sexe': 'M',
1722 1726
        'dateBirth': '1972-01-01',
1723 1727
        'contact/phone': None,
1724 1728
        'contact/mobile': '0623456789',
1725 1729
        'contact/mail': None,
1726 1730
    }
1727 1731

  
1728 1732
    resp = app.post_json(url + '?NameID=local&person_id=614059', params=params)
1729 1733
    assert resp.json['err'] == 'not-linked'
......
1736 1740
    mocked_get.return_value = FAMILY_SERVICE_WSDL
1737 1741
    mocked_post.side_effect = [READ_FAMILY]
1738 1742
    url = get_endpoint('update-person')
1739 1743
    params = {
1740 1744
        'civility': None,
1741 1745
        'firstname': 'Mathias',
1742 1746
        'lastname': 'Cassel',
1743 1747
        'quality': 'O',
1748
        'sexe': 'M',
1744 1749
        'dateBirth': '1972-01-01',
1745 1750
        'contact/phone': None,
1746 1751
        'contact/mobile': '0623456789',
1747 1752
        'contact/mail': None,
1748 1753
    }
1749 1754
    Link.objects.create(resource=con, family_id='1312', name_id='local')
1750 1755
    resp = app.post_json(url + '?NameID=local&person_id=000000', params=params)
1751 1756
    assert resp.json['err'] == 'not-found'
......
1791 1796
def test_create_child_person(mocked_post, mocked_get, con, app):
1792 1797
    mocked_get.return_value = FAMILY_SERVICE_WSDL
1793 1798
    mocked_post.side_effect = [READ_FAMILY, UPDATE_CHILD_AUTO]
1794 1799
    url = get_endpoint('create-child-person')
1795 1800
    params = {
1796 1801
        'personInfo/civility': 'MME',
1797 1802
        'personInfo/firstname': 'Diana',
1798 1803
        'personInfo/lastname': 'Ross',
1804
        'personInfo/sexe': 'F',
1799 1805
        'personInfo/dateBirth': '1944-03-26',
1800 1806
        'personInfo/contact/phone': '0199999999',
1801 1807
        'personInfo/contact/mobile': '0723456789',
1802 1808
        'personInfo/contact/mail': 'dross@example.org',
1803 1809
        'personQuality/code': 'TUTEUR',
1804 1810
    }
1805 1811

  
1806 1812
    Link.objects.create(resource=con, family_id='1312', name_id='local')
......
1810 1816

  
1811 1817

  
1812 1818
def test_create_child_person_not_linked_error(con, app):
1813 1819
    url = get_endpoint('create-child-person')
1814 1820
    params = {
1815 1821
        'personInfo/civility': 'MME',
1816 1822
        'personInfo/firstname': 'Diana',
1817 1823
        'personInfo/lastname': 'Ross',
1824
        'personInfo/sexe': 'F',
1818 1825
        'personInfo/dateBirth': '1944-03-26',
1819 1826
        'personInfo/contact/phone': '01999999999',
1820 1827
        'personInfo/contact/mobile': '0723456789',
1821 1828
        'personInfo/contact/mail': 'dross@example.org',
1822 1829
        'personQuality/code': 'TUTEUR',
1823 1830
    }
1824 1831

  
1825 1832
    resp = app.post_json(url + '?NameID=local&child_id=613880', params=params)
......
1832 1839
def test_create_child_person_no_child_error(mocked_post, mocked_get, con, app):
1833 1840
    mocked_get.return_value = FAMILY_SERVICE_WSDL
1834 1841
    mocked_post.side_effect = [READ_FAMILY]
1835 1842
    url = get_endpoint('create-child-person')
1836 1843
    params = {
1837 1844
        'personInfo/civility': 'MME',
1838 1845
        'personInfo/firstname': 'Diana',
1839 1846
        'personInfo/lastname': 'Ross',
1847
        'personInfo/sexe': 'F',
1840 1848
        'personInfo/dateBirth': '1944-03-26',
1841 1849
        'personInfo/contact/phone': '01999999999',
1842 1850
        'personInfo/contact/mobile': '0723456789',
1843 1851
        'personInfo/contact/mail': 'dross@example.org',
1844 1852
        'personQuality/code': 'TUTEUR',
1845 1853
    }
1846 1854

  
1847 1855
    Link.objects.create(resource=con, family_id='1312', name_id='local')
......
1855 1863
def test_update_child_person(mocked_post, mocked_get, con, app):
1856 1864
    mocked_get.return_value = FAMILY_SERVICE_WSDL
1857 1865
    mocked_post.side_effect = [READ_FAMILY, UPDATE_FAMILY]
1858 1866
    url = get_endpoint('update-child-person')
1859 1867
    params = {
1860 1868
        'personInfo/civility': 'M.',
1861 1869
        'personInfo/firstname': 'Angelo',
1862 1870
        'personInfo/lastname': 'Bent',
1871
        'personInfo/sexe': 'M',
1863 1872
        'personInfo/dateBirth': '1985-06-22',
1864 1873
        'personInfo/contact/phone': '0102030405',
1865 1874
        'personInfo/contact/mobile': None,
1866 1875
        'personInfo/contact/mail': None,
1867 1876
        'personQuality/code': 'O',
1868 1877
    }
1869 1878

  
1870 1879
    Link.objects.create(resource=con, family_id='1312', name_id='local')
1871
-