From 029e16343dba7ebc789ce3e44382460aaa274e02 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Laur=C3=A9line=20Gu=C3=A9rin?= <zebuline@entrouvert.com>
Date: Fri, 7 May 2021 11:37:34 +0200
Subject: [PATCH 1/4] caluire-axel: family_info endpoint (#53825)

---
 functests/caluire_axel/test_caluire_axel.py   |  11 +-
 passerelle/contrib/caluire_axel/models.py     |  34 +++
 passerelle/contrib/caluire_axel/schemas.py    |   1 +
 .../contrib/caluire_axel/xsd/Individu.xsd     |  33 ++-
 .../xsd/Q_GetFamilleIndividus.xsd             |  24 +++
 .../caluire_axel/xsd/R_FindIndividus.xsd      |  35 +---
 .../xsd/R_GetFamilleIndividus.xsd             |  41 ++++
 tests/data/caluire_axel/family_info.xml       | 197 ++++++++++++++++++
 tests/test_caluire_axel.py                    |  35 ++++
 9 files changed, 371 insertions(+), 40 deletions(-)
 create mode 100644 passerelle/contrib/caluire_axel/xsd/Q_GetFamilleIndividus.xsd
 create mode 100644 passerelle/contrib/caluire_axel/xsd/R_GetFamilleIndividus.xsd
 create mode 100644 tests/data/caluire_axel/family_info.xml

diff --git a/functests/caluire_axel/test_caluire_axel.py b/functests/caluire_axel/test_caluire_axel.py
index c62ae55d..7ef49d5f 100644
--- a/functests/caluire_axel/test_caluire_axel.py
+++ b/functests/caluire_axel/test_caluire_axel.py
@@ -20,11 +20,20 @@ def test_link(conn, user):
     assert res['err'] == 0
     print('\n')
 
+    print("GET family info")
+    url = conn + '/family_info?NameID=%s' % name_id
+    resp = requests.get(url)
+    resp.raise_for_status()
+    data = resp.json()
+    pprint.pprint(data)
+    assert data['err'] == 0
+    print('\n')
+
     print("Deleting link")
     url = conn + '/unlink?NameID=%s' % name_id
     resp = requests.post(url)
     resp.raise_for_status()
     res = resp.json()
-    assert res['err'] == 0
     pprint.pprint(res)
+    assert res['err'] == 0
     print('\n')
diff --git a/passerelle/contrib/caluire_axel/models.py b/passerelle/contrib/caluire_axel/models.py
index 78dddab9..b51542b5 100644
--- a/passerelle/contrib/caluire_axel/models.py
+++ b/passerelle/contrib/caluire_axel/models.py
@@ -130,6 +130,40 @@ class CaluireAxel(BaseResource):
         link.delete()
         return {'link': link_id, 'deleted': True, 'family_id': link.family_id}
 
+    def get_family_data(self, family_id):
+        try:
+            result = schemas.get_famille_individus(
+                self, {'PORTAIL': {'GETFAMILLE': {'IDENTFAMILLE': family_id}}}
+            )
+        except axel.AxelError as e:
+            raise APIError(
+                'Axel error: %s' % e,
+                err_code='error',
+                data={'xml_request': e.xml_request, 'xml_response': e.xml_response},
+            )
+
+        family_data = result.json_response['DATA']['PORTAIL']['GETFAMILLE']
+
+        for child in family_data.get('MEMBRE', []):
+            child['id'] = child['IDENT']
+            child['text'] = '{} {}'.format(child['PRENOM'].strip(), child['NOM'].strip()).strip()
+
+        return family_data
+
+    @endpoint(
+        display_category=_('Family account'),
+        display_order=3,
+        description=_("Get information about user's family"),
+        perm='can_access',
+        parameters={
+            'NameID': {'description': _('Publik ID')},
+        },
+    )
+    def family_info(self, request, NameID):
+        link = self.get_link(NameID)
+        family_data = self.get_family_data(link.family_id)
+        return {'data': family_data}
+
 
 class Link(models.Model):
     resource = models.ForeignKey(CaluireAxel, on_delete=models.CASCADE)
diff --git a/passerelle/contrib/caluire_axel/schemas.py b/passerelle/contrib/caluire_axel/schemas.py
index 37443155..534b7a30 100644
--- a/passerelle/contrib/caluire_axel/schemas.py
+++ b/passerelle/contrib/caluire_axel/schemas.py
@@ -27,6 +27,7 @@ class Operation(axel.Operation):
 
 
 find_individus = Operation('FindIndividus')
+get_famille_individus = Operation('GetFamilleIndividus')
 
 
 LINK_SCHEMA = copy.deepcopy(
diff --git a/passerelle/contrib/caluire_axel/xsd/Individu.xsd b/passerelle/contrib/caluire_axel/xsd/Individu.xsd
index dfd97840..1f05e985 100644
--- a/passerelle/contrib/caluire_axel/xsd/Individu.xsd
+++ b/passerelle/contrib/caluire_axel/xsd/Individu.xsd
@@ -19,6 +19,25 @@
 		</xsd:restriction>
 	</xsd:simpleType>
 	
+	<xsd:simpleType name="PLACEType">
+		<xsd:restriction base="xsd:string">
+			<xsd:enumeration value="" />
+			<xsd:enumeration value="1" />
+			<xsd:enumeration value="2" />
+			<xsd:enumeration value="3" />
+		</xsd:restriction>
+	</xsd:simpleType>
+	
+	<xsd:complexType name="FAMILLEType">
+		<xsd:sequence>
+			<xsd:element name="IDENTFAMILLE" type="all:IDENTType"/>
+			<xsd:element name="PLACE"  type="ind:PLACEType"/>
+			<xsd:element name="SITUATION" type="all:FOOBARType" minOccurs="0" maxOccurs="1"/><!-- CUSTOM -->
+			<xsd:element name="QUALITER1" type="all:FOOBARType" minOccurs="0" maxOccurs="1"/><!-- CUSTOM -->
+			<xsd:element name="QUALITER2" type="all:FOOBARType" minOccurs="0" maxOccurs="1"/><!-- CUSTOM -->
+		</xsd:sequence>
+	</xsd:complexType>
+	
 	<xsd:complexType name="INDIVIDUType">
 		<xsd:sequence>
 			<xsd:element name="IDENT" type="all:IDENTType"/>
@@ -31,13 +50,15 @@
 			<xsd:element name="TELFIXE" type="all:TEL2Type"/>
 			<xsd:element name="TELPORTABLE" type="all:TEL2Type"/>
 			<xsd:element name="MAIL" type="all:COURRIELType"/>
-			<xsd:element name="CSP" type="all:FOOBARType"/><!-- CUSTOM -->
-			<xsd:element name="EMPLOYEUR" type="all:FOOBARType"/><!-- CUSTOM -->
-			<xsd:element name="VILLEEMP" type="all:FOOBARType"/><!-- CUSTOM -->
-			<xsd:element name="PAI" type="all:FOOBARType"/><!-- CUSTOM -->
+			<xsd:element name="CSP" type="all:FOOBARType" minOccurs="0" maxOccurs="1"/><!-- CUSTOM -->
+			<xsd:element name="EMPLOYEUR" type="all:FOOBARType" minOccurs="0" maxOccurs="1"/><!-- CUSTOM -->
+			<xsd:element name="VILLEEMP" type="all:FOOBARType" minOccurs="0" maxOccurs="1"/><!-- CUSTOM -->
+			<xsd:element name="REGIME1" type="all:FOOBARType" minOccurs="0" maxOccurs="1"/><!-- CUSTOM -->
+			<xsd:element name="PAI" type="all:FOOBARType" minOccurs="0" maxOccurs="1"/><!-- CUSTOM -->
 			<xsd:element name="GARDEALTERNEE" type="all:FOOBARType"/><!-- CUSTOM -->
 			<xsd:element name="ADRESSE" type="adr:ADRESSEType" minOccurs="0" maxOccurs="1"/>
-		</xsd:sequence> 
+			<xsd:element name="FAMILLE" type="ind:FAMILLEType" minOccurs="0" maxOccurs="unbounded"/><!-- CUSTOM -->
+		</xsd:sequence>
 	</xsd:complexType>
-		
+	
 </xsd:schema>
diff --git a/passerelle/contrib/caluire_axel/xsd/Q_GetFamilleIndividus.xsd b/passerelle/contrib/caluire_axel/xsd/Q_GetFamilleIndividus.xsd
new file mode 100644
index 00000000..0167977f
--- /dev/null
+++ b/passerelle/contrib/caluire_axel/xsd/Q_GetFamilleIndividus.xsd
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:all="urn:AllAxelTypes">
+	
+	<xsd:import schemaLocation="./AllAxelTypes.xsd" namespace="urn:AllAxelTypes"  />
+		
+	<xsd:complexType name="PORTAILType">
+		<xsd:sequence>
+			<xsd:element ref="GETFAMILLE" minOccurs="0" maxOccurs="1"/>
+		</xsd:sequence>  
+	</xsd:complexType>
+	
+	<xsd:complexType name="GETFAMILLEType">
+		<xsd:sequence>
+			<xsd:element ref="IDENTFAMILLE"/>
+		</xsd:sequence>  
+	</xsd:complexType>
+	
+	<xsd:element name="IDENTFAMILLE" type="all:IDENTREQUIREDType"/>
+	
+	<xsd:element name="GETFAMILLE" type="GETFAMILLEType"/>
+	
+	<xsd:element name="PORTAIL" type="PORTAILType"/>	
+		
+</xsd:schema>
\ No newline at end of file
diff --git a/passerelle/contrib/caluire_axel/xsd/R_FindIndividus.xsd b/passerelle/contrib/caluire_axel/xsd/R_FindIndividus.xsd
index 5c4cf168..09cc2245 100644
--- a/passerelle/contrib/caluire_axel/xsd/R_FindIndividus.xsd
+++ b/passerelle/contrib/caluire_axel/xsd/R_FindIndividus.xsd
@@ -22,46 +22,15 @@
 		</xsd:complexType>
 	</xsd:redefine>	
 			
-	<xsd:complexType name="INDIType">
-		<xsd:complexContent>
-			<xsd:extension base="ind:INDIVIDUType">
-				<xsd:sequence>
-					<xsd:element ref="FAMILLE"  minOccurs="0" maxOccurs="unbounded"/>
-				</xsd:sequence>
-			</xsd:extension>
-		</xsd:complexContent>
-	</xsd:complexType>
-	
-	<xsd:complexType name="FAMILLEType">
-		<xsd:sequence>
-			<xsd:element ref="IDENTFAMILLE" />
-			<xsd:element ref="PLACE"/>
-			<xsd:element ref="SITUATION" minOccurs="0" maxOccurs="1"/><!-- CUSTOM -->
-		</xsd:sequence> 
-	</xsd:complexType>
-	
-	<xsd:simpleType name="PLACEType">
-		<xsd:restriction base="xsd:string">
-			<xsd:enumeration value="" />
-			<xsd:enumeration value="1" />
-			<xsd:enumeration value="2" />
-			<xsd:enumeration value="3" />
-		</xsd:restriction>
-	</xsd:simpleType>
-	
 	<xsd:complexType name="FINDINDIVIDUSType">
 		<xsd:sequence>
 			<xsd:element ref="CODE" />
 			<xsd:element ref="INDIVIDU" minOccurs="0" maxOccurs="unbounded" />
-		</xsd:sequence> 
+		</xsd:sequence>
 	</xsd:complexType>
 
 	<xsd:element name="CODE" type="xsd:integer"/>
-	<xsd:element name="INDIVIDU" type="INDIType"/>
-	<xsd:element name="FAMILLE" type="FAMILLEType"/>
-	<xsd:element name="IDENTFAMILLE" type="all:IDENTType"/>
-	<xsd:element name="PLACE" type="PLACEType"/>
-	<xsd:element name="SITUATION" type="all:FOOBARType"/><!-- CUSTOM -->
+	<xsd:element name="INDIVIDU" type="ind:INDIVIDUType"/>
 	
 	<xsd:element name="FINDINDIVIDUS" type="FINDINDIVIDUSType"/>
 		
diff --git a/passerelle/contrib/caluire_axel/xsd/R_GetFamilleIndividus.xsd b/passerelle/contrib/caluire_axel/xsd/R_GetFamilleIndividus.xsd
new file mode 100644
index 00000000..8d8ff4d1
--- /dev/null
+++ b/passerelle/contrib/caluire_axel/xsd/R_GetFamilleIndividus.xsd
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<xsd:schema	xmlns:all="urn:AllAxelTypes" xmlns:ind="urn:Individu"  xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
+	
+	<xsd:import schemaLocation="./Individu.xsd" namespace="urn:Individu" />
+	<xsd:import schemaLocation="./AllAxelTypes.xsd" namespace="urn:AllAxelTypes" />
+	
+	<xsd:redefine schemaLocation="./R_ShemaResultat.xsd">
+	    <xsd:simpleType name="TYPEType">
+			<xsd:restriction base="TYPEType">
+				<xsd:enumeration value="GetFamilleIndividus" />
+			</xsd:restriction>
+	    </xsd:simpleType>
+		
+		<xsd:complexType name="PORTAILType">
+			<xsd:complexContent>
+				<xsd:extension base="PORTAILType">
+					<xsd:sequence>
+							<xsd:element ref="GETFAMILLE" minOccurs="0" maxOccurs="1"/>
+					</xsd:sequence>
+				</xsd:extension>
+			 </xsd:complexContent>
+		</xsd:complexType>
+	</xsd:redefine>	
+	
+	<xsd:complexType name="GETFAMILLEType">
+		<xsd:sequence>
+			<xsd:element ref="CODE" />
+			<xsd:element ref="RESPONSABLE1" minOccurs="0" maxOccurs="1" />
+			<xsd:element ref="RESPONSABLE2" minOccurs="0" maxOccurs="1" />
+			<xsd:element ref="MEMBRE" minOccurs="0" maxOccurs="unbounded" />
+		</xsd:sequence> 
+	</xsd:complexType>
+	
+	<xsd:element name="CODE" type="xsd:integer"/>
+	<xsd:element name="RESPONSABLE1" type="ind:INDIVIDUType"/>
+	<xsd:element name="RESPONSABLE2" type="ind:INDIVIDUType"/>
+	<xsd:element name="MEMBRE" type="ind:INDIVIDUType"/>
+	
+	<xsd:element name="GETFAMILLE" type="GETFAMILLEType"/>
+		
+</xsd:schema>
diff --git a/tests/data/caluire_axel/family_info.xml b/tests/data/caluire_axel/family_info.xml
new file mode 100644
index 00000000..058ccd29
--- /dev/null
+++ b/tests/data/caluire_axel/family_info.xml
@@ -0,0 +1,197 @@
+<PORTAIL>
+  <GETFAMILLE>
+    <CODE>0</CODE>
+    <RESPONSABLE1>
+      <IDENT>50630</IDENT>
+      <CIVILITE>MME</CIVILITE>
+      <NOM>CALUIRE TEST 1</NOM>
+      <PRENOM>Maman</PRENOM>
+      <NAISSANCE>07/07/1975</NAISSANCE>
+      <SEXE>F</SEXE>
+      <NOMJF />
+      <TELFIXE>0235384722</TELFIXE>
+      <TELPORTABLE>0619290316</TELPORTABLE>
+      <MAIL>mamanbobo@caluire.fr</MAIL>
+      <CSP />
+      <EMPLOYEUR />
+      <VILLEEMP />
+      <PAI>N</PAI>
+      <GARDEALTERNEE>N</GARDEALTERNEE>
+      <ADRESSE>
+        <ADRESSE3 />
+        <ADRESSE4 />
+        <NORUE>30</NORUE>
+        <ADRESSE1>RUE PASTEUR</ADRESSE1>
+        <ADRESSE2 />
+        <CODEPOSTAL>69300</CODEPOSTAL>
+        <VILLE>CALUIRE ET CUIRE</VILLE>
+        <PAYS />
+        <NPAI />
+      </ADRESSE>
+      <FAMILLE>
+        <IDENTFAMILLE>16777</IDENTFAMILLE>
+        <PLACE>1</PLACE>
+        <SITUATION>S&#233;par&#233;</SITUATION>
+      </FAMILLE>
+    </RESPONSABLE1>
+    <RESPONSABLE2>
+      <IDENT>50631</IDENT>
+      <CIVILITE>M</CIVILITE>
+      <NOM>CALUIRE TEST 1</NOM>
+      <PRENOM>Papa </PRENOM>
+      <NAISSANCE>06/09/1875</NAISSANCE>
+      <SEXE>M</SEXE>
+      <NOMJF />
+      <TELFIXE>02 00 00 00 00</TELFIXE>
+      <TELPORTABLE>09 00 00 00 00</TELPORTABLE>
+      <MAIL>papaben@caluire.fr</MAIL>
+      <CSP />
+      <EMPLOYEUR />
+      <VILLEEMP />
+      <PAI>N</PAI>
+      <GARDEALTERNEE>N</GARDEALTERNEE>
+      <ADRESSE>
+        <ADRESSE3 />
+        <ADRESSE4 />
+        <NORUE>50</NORUE>
+        <ADRESSE1>RUE CURIE</ADRESSE1>
+        <ADRESSE2 />
+        <CODEPOSTAL>69300</CODEPOSTAL>
+        <VILLE>CALUIRE ET CUIRE</VILLE>
+        <PAYS />
+        <NPAI />
+      </ADRESSE>
+      <FAMILLE>
+        <IDENTFAMILLE>16777</IDENTFAMILLE>
+        <PLACE>2</PLACE>
+        <SITUATION>S&#233;par&#233;</SITUATION>
+      </FAMILLE>
+    </RESPONSABLE2>
+    <MEMBRE>
+      <IDENT>50632</IDENT>
+      <CIVILITE />
+      <NOM>CALUIRE TEST</NOM>
+      <PRENOM>Enfant 1 </PRENOM>
+      <NAISSANCE>10/10/2013</NAISSANCE>
+      <SEXE>M</SEXE>
+      <NOMJF />
+      <TELFIXE />
+      <TELPORTABLE />
+      <MAIL />
+      <PAI>N</PAI>
+      <GARDEALTERNEE>O</GARDEALTERNEE>
+      <ADRESSE>
+        <ADRESSE3 />
+        <ADRESSE4 />
+        <NORUE>30</NORUE>
+        <ADRESSE1>RUE PASTEUR</ADRESSE1>
+        <ADRESSE2 />
+        <CODEPOSTAL>69300</CODEPOSTAL>
+        <VILLE>CALUIRE ET CUIRE</VILLE>
+        <PAYS />
+        <NPAI />
+      </ADRESSE>
+      <FAMILLE>
+        <IDENTFAMILLE>16777</IDENTFAMILLE>
+        <PLACE>3</PLACE>
+        <SITUATION>S&#233;par&#233;</SITUATION>
+        <QUALITER1>M&#232;re</QUALITER1>
+        <QUALITER2>P&#232;re</QUALITER2>
+      </FAMILLE>
+    </MEMBRE>
+    <MEMBRE>
+      <IDENT>50633</IDENT>
+      <CIVILITE />
+      <NOM>CALUIRE TEST</NOM>
+      <PRENOM>Enfant 2 </PRENOM>
+      <NAISSANCE>12/12/2012</NAISSANCE>
+      <SEXE>F</SEXE>
+      <NOMJF />
+      <TELFIXE />
+      <TELPORTABLE />
+      <MAIL />
+      <PAI>N</PAI>
+      <GARDEALTERNEE>N</GARDEALTERNEE>
+      <ADRESSE>
+        <ADRESSE3 />
+        <ADRESSE4 />
+        <NORUE>30</NORUE>
+        <ADRESSE1>RUE PASTEUR</ADRESSE1>
+        <ADRESSE2 />
+        <CODEPOSTAL>69300</CODEPOSTAL>
+        <VILLE>CALUIRE ET CUIRE</VILLE>
+        <PAYS />
+        <NPAI />
+      </ADRESSE>
+      <FAMILLE>
+        <IDENTFAMILLE>16777</IDENTFAMILLE>
+        <PLACE>3</PLACE>
+        <SITUATION>S&#233;par&#233;</SITUATION>
+        <QUALITER1>M&#232;re</QUALITER1>
+        <QUALITER2>P&#232;re</QUALITER2>
+      </FAMILLE>
+    </MEMBRE>
+    <MEMBRE>
+      <IDENT>54621</IDENT>
+      <CIVILITE />
+      <NOM>CALUIRE TEST</NOM>
+      <PRENOM>Enfant 3</PRENOM>
+      <NAISSANCE>15/03/2010</NAISSANCE>
+      <SEXE>M</SEXE>
+      <NOMJF />
+      <TELFIXE />
+      <TELPORTABLE />
+      <MAIL />
+      <REGIME1>MALL</REGIME1>
+      <PAI>N</PAI>
+      <GARDEALTERNEE>N</GARDEALTERNEE>
+      <ADRESSE>
+        <ADRESSE3 />
+        <ADRESSE4 />
+        <NORUE>30</NORUE>
+        <ADRESSE1>RUE PASTEUR</ADRESSE1>
+        <ADRESSE2 />
+        <CODEPOSTAL>69300</CODEPOSTAL>
+        <VILLE>CALUIRE ET CUIRE</VILLE>
+        <PAYS />
+        <NPAI />
+      </ADRESSE>
+      <FAMILLE>
+        <IDENTFAMILLE>16777</IDENTFAMILLE>
+        <PLACE>3</PLACE>
+        <SITUATION>S&#233;par&#233;</SITUATION>
+        <QUALITER1>M&#232;re</QUALITER1>
+        <QUALITER2>P&#232;re</QUALITER2>
+      </FAMILLE>
+    </MEMBRE>
+    <MEMBRE>
+      <IDENT>59509</IDENT>
+      <CIVILITE />
+      <NOM>CALUIRE TEST </NOM>
+      <PRENOM>Enfant 5</PRENOM>
+      <NAISSANCE>16/11/2009</NAISSANCE>
+      <SEXE>F</SEXE>
+      <NOMJF />
+      <TELFIXE />
+      <TELPORTABLE />
+      <MAIL />
+      <GARDEALTERNEE>N</GARDEALTERNEE>
+      <ADRESSE>
+        <ADRESSE3 />
+        <ADRESSE4 />
+        <NORUE>30</NORUE>
+        <ADRESSE1>RUE PASTEUR</ADRESSE1>
+        <ADRESSE2 />
+        <CODEPOSTAL>69300</CODEPOSTAL>
+        <VILLE>CALUIRE ET CUIRE</VILLE>
+        <PAYS />
+        <NPAI />
+      </ADRESSE>
+      <FAMILLE>
+        <IDENTFAMILLE>16777</IDENTFAMILLE>
+        <PLACE>3</PLACE>
+        <SITUATION>S&#233;par&#233;</SITUATION>
+      </FAMILLE>
+    </MEMBRE>
+  </GETFAMILLE>
+</PORTAIL>
diff --git a/tests/test_caluire_axel.py b/tests/test_caluire_axel.py
index 7fc01a3d..3e18a5ad 100644
--- a/tests/test_caluire_axel.py
+++ b/tests/test_caluire_axel.py
@@ -15,6 +15,7 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+import os
 from contextlib import contextmanager
 
 import mock
@@ -365,3 +366,37 @@ def test_unlink_endpoint(app, resource):
     assert resp.json['link'] == link.pk
     assert resp.json['family_id'] == 'XXX'
     assert resp.json['deleted'] is True
+
+
+def test_family_info_endpoint_axel_error(app, resource):
+    Link.objects.create(resource=resource, name_id='yyy', family_id='XXX', person_id='42')
+    with mock.patch('passerelle.contrib.caluire_axel.schemas.get_famille_individus') as operation:
+        operation.side_effect = AxelError('FooBar')
+        resp = app.get('/caluire-axel/test/family_info?NameID=yyy')
+    assert resp.json['err_desc'] == "Axel error: FooBar"
+    assert resp.json['err'] == 'error'
+
+
+def test_family_info_endpoint_no_result(app, resource):
+    resp = app.get('/caluire-axel/test/family_info?NameID=yyy')
+    assert resp.json['err_desc'] == "Person not found"
+    assert resp.json['err'] == 'not-found'
+
+
+def test_family_info_endpoint(app, resource):
+    Link.objects.create(resource=resource, name_id='yyy', family_id='XXX', person_id='42')
+    filepath = os.path.join(os.path.dirname(__file__), 'data/caluire_axel/family_info.xml')
+    with open(filepath) as xml:
+        content = xml.read()
+    with mock_getdata(content, 'GetFamilleIndividus'):
+        resp = app.get('/caluire-axel/test/family_info?NameID=yyy')
+    assert resp.json['err'] == 0
+    assert set(resp.json['data'].keys()) == set(['CODE', 'MEMBRE', 'RESPONSABLE1', 'RESPONSABLE2'])
+    assert resp.json['data']['MEMBRE'][0]['id'] == '50632'
+    assert resp.json['data']['MEMBRE'][0]['text'] == 'Enfant 1 CALUIRE TEST'
+    assert resp.json['data']['MEMBRE'][1]['id'] == '50633'
+    assert resp.json['data']['MEMBRE'][1]['text'] == 'Enfant 2 CALUIRE TEST'
+    assert resp.json['data']['MEMBRE'][2]['id'] == '54621'
+    assert resp.json['data']['MEMBRE'][2]['text'] == 'Enfant 3 CALUIRE TEST'
+    assert resp.json['data']['MEMBRE'][3]['id'] == '59509'
+    assert resp.json['data']['MEMBRE'][3]['text'] == 'Enfant 5 CALUIRE TEST'
-- 
2.30.2

