From 233f5c05b301772961b5d8712886b9d313147963 Mon Sep 17 00:00:00 2001
From: Nicolas ROCHE <nroche@entrouvert.com>
Date: Thu, 28 Jul 2022 14:50:45 +0200
Subject: [PATCH] toulouse_maelis: add civility to RL required properties
 (#67787)

---
 passerelle/contrib/toulouse_maelis/schemas.py  | 2 +-
 tests/data/toulouse_maelis/Q_create_family.xml | 1 +
 tests/data/toulouse_maelis/Q_update_family.xml | 1 +
 tests/test_toulouse_maelis.py                  | 6 ++++++
 4 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/passerelle/contrib/toulouse_maelis/schemas.py b/passerelle/contrib/toulouse_maelis/schemas.py
index 6fd88b1f..475dd5f7 100644
--- a/passerelle/contrib/toulouse_maelis/schemas.py
+++ b/passerelle/contrib/toulouse_maelis/schemas.py
@@ -223,17 +223,17 @@ CAFINFO_SCHEMA = {
     ],
 }
 
 RLINFO_SCHEMA = {
     '$schema': 'http://json-schema.org/draft-04/schema#',
     'title': 'RLInfo',
     'description': "Informations sur le responsable légal",
     'type': 'object',
-    'required': ['firstname', 'lastname', 'quality', 'dateBirth', 'adresse'],
+    'required': ['firstname', 'lastname', 'civility', 'quality', 'dateBirth', 'adresse'],
     'properties': {
         'civility': {
             'description': 'civilité (depuis référenciel)',
             'oneOf': [{'type': 'null'}, {'type': 'string'}],
         },
         'quality': {
             'description': 'Qualité',
             'type': 'string',
diff --git a/tests/data/toulouse_maelis/Q_create_family.xml b/tests/data/toulouse_maelis/Q_create_family.xml
index c52fa792..28f68dec 100644
--- a/tests/data/toulouse_maelis/Q_create_family.xml
+++ b/tests/data/toulouse_maelis/Q_create_family.xml
@@ -11,16 +11,17 @@
   <soap-env:Body>
     <ns0:createFamily xmlns:ns0="family.ws.maelis.sigec.com">
       <categorie>ACCEUI</categorie>
       <situation>C</situation>
       <rl1>
         <lastname>Doe</lastname>
         <firstname>Jhon</firstname>
         <quality>AU</quality>
+        <civility>M.</civility>
         <dateBirth>1938-07-26</dateBirth>
         <adresse>
           <street1>Chateau</street1>
           <town>Paris</town>
           <zipcode>75014</zipcode>
         </adresse>
       </rl1>
     </ns0:createFamily>
diff --git a/tests/data/toulouse_maelis/Q_update_family.xml b/tests/data/toulouse_maelis/Q_update_family.xml
index 698dcfde..8fdfecf9 100644
--- a/tests/data/toulouse_maelis/Q_update_family.xml
+++ b/tests/data/toulouse_maelis/Q_update_family.xml
@@ -12,16 +12,17 @@
     <ns0:updateFamily xmlns:ns0="family.ws.maelis.sigec.com">
       <dossierNumber>1312</dossierNumber>
       <categorie>BI</categorie>
       <situation>C</situation>
       <rl1>
         <lastname>Doe</lastname>
         <firstname>Jhon</firstname>
         <quality>AU</quality>
+        <civility>M.</civility>
         <dateBirth>1938-07-26</dateBirth>
         <adresse>
           <street1>Chateau</street1>
           <town>Paris</town>
           <zipcode>75014</zipcode>
         </adresse>
       </rl1>
     </ns0:updateFamily>
diff --git a/tests/test_toulouse_maelis.py b/tests/test_toulouse_maelis.py
index dec3f42d..45386403 100644
--- a/tests/test_toulouse_maelis.py
+++ b/tests/test_toulouse_maelis.py
@@ -690,16 +690,17 @@ def test_is_child_exists(mocked_post, mocked_get, post_response, result, con, ap
 @mock.patch('passerelle.utils.Request.post')
 def test_create_family(mocked_post, mocked_get, con, app):
     mocked_get.return_value = FAMILY_SERVICE_WSDL
     mocked_post.return_value = CREATE_FAMILY
     url = get_endpoint('create-family')
     params = {
         'categorie': 'ACCEUI',
         'situation': 'C',
+        'rl1/civility': 'M.',
         'rl1/firstname': 'Jhon',
         'rl1/lastname': 'Doe',
         'rl1/quality': 'AU',
         'rl1/dateBirth': '1938-07-26',
         'rl1/adresse/street1': 'Chateau',
         'rl1/adresse/town': 'Paris',
         'rl1/adresse/zipcode': '75014',
     }
@@ -716,16 +717,17 @@ def test_create_family(mocked_post, mocked_get, con, app):
     assert Link.objects.get(resource=con, family_id='196545', name_id='local')
 
 
 def test_create_family_already_linked_error(con, app):
     url = get_endpoint('create-family')
     params = {
         'categorie': 'ACCEUI',
         'situation': 'C',
+        'rl1/civility': 'M.',
         'rl1/firstname': 'Jhon',
         'rl1/lastname': 'Doe',
         'rl1/quality': 'AU',
         'rl1/dateBirth': '1938-07-26',
         'rl1/adresse/street1': 'Chateau',
         'rl1/adresse/town': 'Paris',
         'rl1/adresse/zipcode': '75014',
     }
@@ -740,16 +742,17 @@ def test_create_family_already_linked_error(con, app):
 @mock.patch('passerelle.utils.Request.post')
 def test_create_family_maelis_error(mocked_post, mocked_get, con, app):
     mocked_get.return_value = FAMILY_SERVICE_WSDL
     mocked_post.return_value = CREATE_FAMILY_ERR
     url = get_endpoint('create-family')
     params = {
         'categorie': 'ACCEUI',
         'situation': 'C',
+        'rl1/civility': 'M.',
         'rl1/firstname': 'Jhon',
         'rl1/lastname': 'Doe',
         'rl1/quality': 'AU',
         'rl1/dateBirth': '1938-07-26',
         'rl1/adresse/street1': 'Chateau',
         'rl1/adresse/town': 'Paris',
         'rl1/adresse/zipcode': '75014',
     }
@@ -763,16 +766,17 @@ def test_create_family_maelis_error(mocked_post, mocked_get, con, app):
 @mock.patch('passerelle.utils.Request.post')
 def test_update_family(mocked_post, mocked_get, con, app):
     mocked_get.return_value = FAMILY_SERVICE_WSDL
     mocked_post.return_value = UPDATE_FAMILY
     url = get_endpoint('update-family')
     params = {
         'categorie': 'BI',
         'situation': 'C',
+        'rl1/civility': 'M.',
         'rl1/firstname': 'Jhon',
         'rl1/lastname': 'Doe',
         'rl1/quality': 'AU',
         'rl1/dateBirth': '1938-07-26',
         'rl1/adresse/street1': 'Chateau',
         'rl1/adresse/town': 'Paris',
         'rl1/adresse/zipcode': '75014',
     }
@@ -783,16 +787,17 @@ def test_update_family(mocked_post, mocked_get, con, app):
     assert resp.json['err'] == 0
 
 
 def test_update_family_already_not_linked_error(con, app):
     url = get_endpoint('update-family')
     params = {
         'categorie': 'BI',
         'situation': 'C',
+        'rl1/civility': 'M.',
         'rl1/firstname': 'Jhon',
         'rl1/lastname': 'Doe',
         'rl1/quality': 'AU',
         'rl1/dateBirth': '1938-07-26',
         'rl1/adresse/street1': 'Chateau',
         'rl1/adresse/town': 'Paris',
         'rl1/adresse/zipcode': '75014',
     }
@@ -834,16 +839,17 @@ def test_update_family_maelis_error(mocked_post, mocked_get, con, app):
 def test_update_family_soap_error(mocked_post, mocked_get, con, app):
     mocked_get.return_value = FAMILY_SERVICE_WSDL
     mocked_post.return_value = UPDATE_FAMILY_500
     url = get_endpoint('update-family')
     params = {
         'nbChild': '100',
         'categorie': 'BI',
         'situation': 'C',
+        'rl1/civility': 'M.',
         'rl1/firstname': 'Jhon',
         'rl1/lastname': 'Doe',
         'rl1/quality': 'AU',
         'rl1/dateBirth': '1938-07-26',
         'rl1/adresse/street1': 'Chateau',
         'rl1/adresse/town': 'Paris',
         'rl1/adresse/zipcode': '75014',
     }
-- 
2.30.2

