From dd8eea06e9b873ca0e28c5245023592d840e8193 Mon Sep 17 00:00:00 2001
From: Nicolas ROCHE <nroche@entrouvert.com>
Date: Sun, 20 Nov 2022 12:35:00 +0100
Subject: [PATCH 5/5] toulouse-maelis: child need a num field to update
 (#71642)

---
 passerelle/contrib/toulouse_maelis/schemas.py  | 6 +++++-
 tests/data/toulouse_maelis/Q_update_family.xml | 9 +++++++++
 tests/test_toulouse_maelis.py                  | 7 ++++++-
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/passerelle/contrib/toulouse_maelis/schemas.py b/passerelle/contrib/toulouse_maelis/schemas.py
index 55fb4f8d..e3c408a0 100644
--- a/passerelle/contrib/toulouse_maelis/schemas.py
+++ b/passerelle/contrib/toulouse_maelis/schemas.py
@@ -112,17 +112,17 @@ ID_PROPERTIES = {
 ADDRESS_SCHEMA = {
     '$schema': 'http://json-schema.org/draft-04/schema#',
     'title': 'Address',
     'description': 'Informations sur une adresse',
     'type': 'object',
     'required': ['street1', 'town', 'zipcode'],
     'properties': {
         'num': {
-            'description': 'numéro',
+            'description': "Numéro de l'adresse",
             'oneOf': [{'type': 'string'}, {'type': 'null'}],
         },
         'numComp': {
             'description': 'Complément du numéro (depuis référentiel)',
             'oneOf': [{'type': 'string'}, {'type': 'null'}],
         },
         'street1': {
             'description': 'Libellé de la voie',
@@ -423,16 +423,20 @@ PAIINFO_SCHEMA = {
 
 CHILD_SCHEMA = {
     '$schema': 'http://json-schema.org/draft-04/schema#',
     'title': 'Child',
     'description': "Informations sur la création d'un enfant",
     'type': 'object',
     'required': ['sexe', 'firstname', 'lastname', 'birth'],
     'properties': {
+        'num': {
+            'description': "Numéro de l'enfant",
+            'oneOf': [{'type': 'string'}, {'type': 'null'}],
+        },
         'sexe': {
             'description': 'Sexe (depuis référentiel)',
             'type': 'string',
             'pattern': '.+',
         },
         'birth': BIRTH_SCHEMA,
         'dietcode': {
             'description': 'Code de régime alimentaire (depuis référentiel)',
diff --git a/tests/data/toulouse_maelis/Q_update_family.xml b/tests/data/toulouse_maelis/Q_update_family.xml
index 2239a3c4..4522bab5 100644
--- a/tests/data/toulouse_maelis/Q_update_family.xml
+++ b/tests/data/toulouse_maelis/Q_update_family.xml
@@ -51,16 +51,25 @@
             <code>DTC</code>
             <vaccinationDate>1940-07-26</vaccinationDate>
           </vaccinList>
         </medicalRecord>
         <paiInfoBean>
           <code>PAIALI</code>
         </paiInfoBean>
       </childList>
+      <childList>
+        <num>613880</num>
+        <firstname>Brunelle</firstname>
+        <lastname>Doe</lastname>
+        <sexe>F</sexe>
+        <birth>
+          <dateBirth>1943-01-19</dateBirth>
+        </birth>
+      </childList>
       <emergencyPersonList>
         <personList>
           <civility>MME</civility>
           <firstname>Keny</firstname>
           <lastname>Arkana</lastname>
           <dateBirth>1982-12-20</dateBirth>
           <sexe>F</sexe>
           <quality>T</quality>
diff --git a/tests/test_toulouse_maelis.py b/tests/test_toulouse_maelis.py
index c7e377da..54dd13bc 100644
--- a/tests/test_toulouse_maelis.py
+++ b/tests/test_toulouse_maelis.py
@@ -1253,25 +1253,30 @@ def test_update_family(mocked_post, mocked_get, con, app):
         'rl1/profession/codeCSP': 'ART',
         'rl1/CAFInfo/organ': 'A10007752822',
         'emergencyPersonList/0/personList/0/civility': 'MME',
         'emergencyPersonList/0/personList/0/firstname': 'Keny',
         'emergencyPersonList/0/personList/0/lastname': 'Arkana',
         'emergencyPersonList/0/personList/0/sexe': 'F',
         'emergencyPersonList/0/personList/0/dateBirth': '1982-12-20',
         'emergencyPersonList/0/personList/0/quality': 'T',
-        'childList/0/lastname': 'Zimmerman',
+        'childList/0/lastname': 'Zimmerman',  # add child
         'childList/0/firstname': 'Robert',
         'childList/0/sexe': 'M',
         'childList/0/birth/dateBirth': '1941-05-24',
         'childList/0/birth/place': 'Duluth',
         'childList/0/dietcode': 'RSV',
         'childList/0/paiInfoBean/code': 'PAIALI',
         'childList/0/medicalRecord/vaccinList/0/code': 'DTC',
         'childList/0/medicalRecord/vaccinList/0/vaccinationDate': '1940-07-26',
+        'childList/1/num': '613880',  # update child
+        'childList/1/firstname': 'Brunelle',
+        'childList/1/lastname': 'Doe',
+        'childList/1/birth/dateBirth': '1943-01-19',
+        'childList/1/sexe': 'F',
     }
 
     Link.objects.create(resource=con, family_id='1312', name_id='local')
     resp = app.post_json(url + '?NameID=local', params=params)
     assert_sent_payload(mocked_post, 'Q_update_family.xml')
     assert resp.json['err'] == 0
     assert resp.json['data']['number'] == 196544
     assert not resp.json['data']['childErrorList']
-- 
2.30.2

