Project

General

Profile

0001-toulouse-maelis-add-maidenName-to-RL-json-schema-716.patch

Nicolas Roche, 24 November 2022 11:38 AM

Download (11.3 KB)

View differences:

Subject: [PATCH 1/5] toulouse-maelis: add maidenName to RL json schema
 (#71642)

 passerelle/contrib/toulouse_maelis/schemas.py |  4 ++++
 tests/data/toulouse_maelis/Q_create_rl2.xml   |  1 +
 tests/data/toulouse_maelis/Q_update_rl2.xml   |  1 +
 tests/data/toulouse_maelis/R_read_family.xml  |  1 +
 tests/test_toulouse_maelis.py                 | 12 +++++++++++-
 5 files changed, 18 insertions(+), 1 deletion(-)
passerelle/contrib/toulouse_maelis/schemas.py
97 97
    'firstname': {
98 98
        'description': 'Prénom',
99 99
        'type': 'string',
100 100
    },
101 101
    'lastname': {
102 102
        'description': 'Nom',
103 103
        'type': 'string',
104 104
    },
105
    'maidenName': {
106
        'description': "Nom de jeune fille ",
107
        'oneOf': [{'type': 'string'}, {'type': 'null'}],
108
    },
105 109
    'birth': BIRTH_SCHEMA,
106 110
}
107 111

  
108 112
ADDRESS_SCHEMA = {
109 113
    '$schema': 'http://json-schema.org/draft-04/schema#',
110 114
    'title': 'Address',
111 115
    'description': 'Informations sur une adresse',
112 116
    'type': 'object',
tests/data/toulouse_maelis/Q_create_rl2.xml
12 12
      <dossierNumber>1312</dossierNumber>
13 13
      <category>BI</category>
14 14
      <situation>M</situation>
15 15
      <flagCom>true</flagCom>
16 16
      <nbChild>2</nbChild>
17 17
      <rl2>
18 18
        <firstname>JANE</firstname>
19 19
        <lastname>DOE</lastname>
20
        <maidenName>Smith</maidenName>
20 21
        <quality>MERE</quality>
21 22
        <civility>MME</civility>
22 23
        <birth>
23 24
          <dateBirth>1940-06-22</dateBirth>
24 25
        </birth>
25 26
        <adresse>
26 27
          <num>170</num>
27 28
          <street1>Chateau d'eau</street1>
tests/data/toulouse_maelis/Q_update_rl2.xml
13 13
      <category>BI</category>
14 14
      <situation>M</situation>
15 15
      <flagCom>true</flagCom>
16 16
      <nbChild>2</nbChild>
17 17
      <rl2>
18 18
        <num>613879</num>
19 19
        <firstname>JANE</firstname>
20 20
        <lastname>DOE</lastname>
21
        <maidenName>Smith</maidenName>
21 22
        <quality>MERE</quality>
22 23
        <civility>MME</civility>
23 24
        <birth>
24 25
          <dateBirth>1940-06-22</dateBirth>
25 26
        </birth>
26 27
        <adresse>
27 28
          <num>170</num>
28 29
          <street1>Chateau d'eau</street1>
tests/data/toulouse_maelis/R_read_family.xml
36 36
          <profession>
37 37
            <addressPro/>
38 38
          </profession>
39 39
        </RL1>
40 40
        <RL2>
41 41
          <num>613879</num>
42 42
          <lastname>DOE</lastname>
43 43
          <firstname>JANE</firstname>
44
          <maidenName>SMITH</maidenName>
44 45
          <quality>MERE</quality>
45 46
          <civility>MME</civility>
46 47
          <birth>
47 48
            <dateBirth>1940-06-22T00:00:00+02:00</dateBirth>
48 49
            <place>Bardot</place>
49 50
            <countryCode>99351</countryCode>
50 51
          </birth>
51 52
          <adresse>
tests/test_toulouse_maelis.py
765 765
    Link.objects.create(resource=con, family_id='1312', name_id='local')
766 766

  
767 767
    resp = app.get(url + '?NameID=local&rl_id=613879')
768 768
    assert resp.json['err'] == 0
769 769
    assert resp.json['data'] == {
770 770
        'num': '613879',
771 771
        'lastname': 'DOE',
772 772
        'firstname': 'JANE',
773
        'maidenName': None,
773
        'maidenName': 'SMITH',
774 774
        'quality': 'MERE',
775 775
        'civility': 'MME',
776 776
        'birth': {
777 777
            'communeCode': None,
778 778
            'countryCode': '99351',
779 779
            'dateBirth': '1940-06-22T00:00:00+02:00',
780 780
            'place': 'Bardot',
781 781
        },
......
1619 1619
def test_create_rl2(mocked_post, mocked_get, con, app):
1620 1620
    mocked_get.return_value = FAMILY_SERVICE_WSDL
1621 1621
    mocked_post.side_effect = [READ_RL1_FAMILY, READ_CIVILITIES, READ_QUALITIES, UPDATE_FAMILY]
1622 1622
    url = get_endpoint('create-rl2')
1623 1623
    params = {
1624 1624
        'civility': 'MME',
1625 1625
        'firstname': 'JANE',
1626 1626
        'lastname': 'DOE',
1627
        'maidenName': 'Smith',
1627 1628
        'quality': 'MERE',
1628 1629
        'birth/dateBirth': '1940-06-22',
1629 1630
        'adresse/num': '170',
1630 1631
        'adresse/street1': "Chateau d'eau",
1631 1632
        'adresse/town': 'Paris',
1632 1633
        'adresse/zipcode': '75014',
1633 1634
    }
1634 1635

  
......
1640 1641

  
1641 1642

  
1642 1643
def test_create_rl2_not_linked_error(con, app):
1643 1644
    url = get_endpoint('create-rl2')
1644 1645
    params = {
1645 1646
        'civility': 'MME',
1646 1647
        'firstname': 'JANE',
1647 1648
        'lastname': 'DOE',
1649
        'maidenName': 'Smith',
1648 1650
        'quality': 'MERE',
1649 1651
        'birth/dateBirth': '1940-06-22',
1650 1652
        'adresse/num': '170',
1651 1653
        'adresse/street1': "Chateau d'eau",
1652 1654
        'adresse/town': 'Paris',
1653 1655
        'adresse/zipcode': '75014',
1654 1656
    }
1655 1657

  
......
1663 1665
def test_create_rl2_connection_error(mocked_post, mocked_get, con, app):
1664 1666
    mocked_get.return_value = FAMILY_SERVICE_WSDL
1665 1667
    mocked_post.side_effect = CONNECTION_ERROR
1666 1668
    url = get_endpoint('create-rl2')
1667 1669
    params = {
1668 1670
        'civility': 'MME',
1669 1671
        'firstname': 'JANE',
1670 1672
        'lastname': 'DOE',
1673
        'maidenName': 'Smith',
1671 1674
        'quality': 'MERE',
1672 1675
        'birth/dateBirth': '1940-06-22',
1673 1676
        'adresse/num': '170',
1674 1677
        'adresse/street1': "Chateau d'eau",
1675 1678
        'adresse/town': 'Paris',
1676 1679
        'adresse/zipcode': '75014',
1677 1680
    }
1678 1681

  
......
1687 1690
def test_create_rl2_already_exists_error(mocked_post, mocked_get, con, app):
1688 1691
    mocked_get.return_value = FAMILY_SERVICE_WSDL
1689 1692
    mocked_post.return_value = READ_FAMILY
1690 1693
    url = get_endpoint('create-rl2')
1691 1694
    params = {
1692 1695
        'civility': 'MME',
1693 1696
        'firstname': 'JANE',
1694 1697
        'lastname': 'DOE',
1698
        'maidenName': 'Smith',
1695 1699
        'quality': 'MERE',
1696 1700
        'birth/dateBirth': '1940-06-22',
1697 1701
        'adresse/num': '170',
1698 1702
        'adresse/street1': "Chateau d'eau",
1699 1703
        'adresse/town': 'Paris',
1700 1704
        'adresse/zipcode': '75014',
1701 1705
    }
1702 1706

  
......
1711 1715
def test_create_rl2_wrong_referential_key_error(mocked_post, mocked_get, con, app):
1712 1716
    mocked_get.return_value = FAMILY_SERVICE_WSDL
1713 1717
    mocked_post.side_effect = [READ_RL1_FAMILY, READ_CIVILITIES, READ_QUALITIES]
1714 1718
    url = get_endpoint('create-rl2')
1715 1719
    params = {
1716 1720
        'civility': 'MME',
1717 1721
        'firstname': 'JANE',
1718 1722
        'lastname': 'DOE',
1723
        'maidenName': 'Smith',
1719 1724
        'quality': 'plop',
1720 1725
        'birth/dateBirth': '1940-06-22',
1721 1726
        'adresse/num': '170',
1722 1727
        'adresse/street1': "Chateau d'eau",
1723 1728
        'adresse/town': 'Paris',
1724 1729
        'adresse/zipcode': '75014',
1725 1730
    }
1726 1731

  
......
1735 1740
def test_update_rl2(mocked_post, mocked_get, con, app):
1736 1741
    mocked_get.return_value = FAMILY_SERVICE_WSDL
1737 1742
    mocked_post.side_effect = [READ_FAMILY, READ_CIVILITIES, READ_QUALITIES, UPDATE_FAMILY]
1738 1743
    url = get_endpoint('update-rl2')
1739 1744
    params = {
1740 1745
        'civility': 'MME',
1741 1746
        'firstname': 'JANE',
1742 1747
        'lastname': 'DOE',
1748
        'maidenName': 'Smith',
1743 1749
        'quality': 'MERE',
1744 1750
        'birth/dateBirth': '1940-06-22',
1745 1751
    }
1746 1752

  
1747 1753
    Link.objects.create(resource=con, family_id='1312', name_id='local')
1748 1754
    resp = app.post_json(url + '?NameID=local', params=params)
1749 1755
    assert_sent_payload(mocked_post, 'Q_update_rl2.xml')
1750 1756
    assert resp.json['err'] == 0
......
1752 1758

  
1753 1759
def test_update_rl2_not_linked_error(con, app):
1754 1760
    url = get_endpoint('update-rl2')
1755 1761
    params = {
1756 1762
        'civility': 'MME',
1757 1763
        'firstname': 'JANE',
1758 1764
        'lastname': 'DOE',
1759 1765
        'quality': 'MERE',
1766
        'maidenName': 'Smith',
1760 1767
        'birth/dateBirth': '1940-06-22',
1761 1768
    }
1762 1769

  
1763 1770
    resp = app.post_json(url + '?NameID=local', params=params)
1764 1771
    assert resp.json['err'] == 'not-linked'
1765 1772
    assert resp.json['err_desc'] == 'User not linked to family'
1766 1773

  
1767 1774

  
......
1770 1777
def test_update_rl2_connection_error(mocked_post, mocked_get, con, app):
1771 1778
    mocked_get.return_value = FAMILY_SERVICE_WSDL
1772 1779
    mocked_post.side_effect = CONNECTION_ERROR
1773 1780
    url = get_endpoint('update-rl2')
1774 1781
    params = {
1775 1782
        'civility': 'MME',
1776 1783
        'firstname': 'JANE',
1777 1784
        'lastname': 'DOE',
1785
        'maidenName': 'Smith',
1778 1786
        'quality': 'MERE',
1779 1787
        'birth/dateBirth': '1940-06-22',
1780 1788
    }
1781 1789

  
1782 1790
    Link.objects.create(resource=con, family_id='1312', name_id='local')
1783 1791
    resp = app.post_json(url + '?NameID=local', params=params, status=500)
1784 1792
    assert resp.json['err']
1785 1793
    assert resp.json['err_desc'] == 'No address associated with hostname'
......
1790 1798
def test_update_rl2_not_exists_error(mocked_post, mocked_get, con, app):
1791 1799
    mocked_get.return_value = FAMILY_SERVICE_WSDL
1792 1800
    mocked_post.return_value = READ_RL1_FAMILY
1793 1801
    url = get_endpoint('update-rl2')
1794 1802
    params = {
1795 1803
        'civility': 'MME',
1796 1804
        'firstname': 'JANE',
1797 1805
        'lastname': 'DOE',
1806
        'maidenName': 'Smith',
1798 1807
        'quality': 'MERE',
1799 1808
        'birth/dateBirth': '1940-06-22',
1800 1809
    }
1801 1810

  
1802 1811
    Link.objects.create(resource=con, family_id='1312', name_id='local')
1803 1812
    resp = app.post_json(url + '?NameID=local', params=params)
1804 1813
    assert resp.json['err'] == 'no-rl2'
1805 1814
    assert resp.json['err_desc'] == 'No RL2 to update on family'
......
1810 1819
def test_update_rl2_wrong_referential_key_error(mocked_post, mocked_get, con, app):
1811 1820
    mocked_get.return_value = FAMILY_SERVICE_WSDL
1812 1821
    mocked_post.side_effect = [READ_FAMILY, READ_CIVILITIES, READ_QUALITIES]
1813 1822
    url = get_endpoint('update-rl2')
1814 1823
    params = {
1815 1824
        'civility': 'MME',
1816 1825
        'firstname': 'JANE',
1817 1826
        'lastname': 'DOE',
1827
        'maidenName': 'Smith',
1818 1828
        'quality': 'plop',
1819 1829
        'birth/dateBirth': '1940-06-22',
1820 1830
    }
1821 1831

  
1822 1832
    Link.objects.create(resource=con, family_id='1312', name_id='local')
1823 1833
    resp = app.post_json(url + '?NameID=local', params=params)
1824 1834
    assert resp.json['err'] == 'wrong-key'
1825 1835
    assert resp.json['err_desc'] == "quality key value 'plop' do not belong to 'Quality' required referential"
1826
-