0001-caluire-axel-family_info-endpoint-53825.patch
functests/caluire_axel/test_caluire_axel.py | ||
---|---|---|
20 | 20 |
assert res['err'] == 0 |
21 | 21 |
print('\n') |
22 | 22 | |
23 |
print("GET family info") |
|
24 |
url = conn + '/family_info?NameID=%s' % name_id |
|
25 |
resp = requests.get(url) |
|
26 |
resp.raise_for_status() |
|
27 |
data = resp.json() |
|
28 |
pprint.pprint(data) |
|
29 |
assert data['err'] == 0 |
|
30 |
print('\n') |
|
31 | ||
23 | 32 |
print("Deleting link") |
24 | 33 |
url = conn + '/unlink?NameID=%s' % name_id |
25 | 34 |
resp = requests.post(url) |
26 | 35 |
resp.raise_for_status() |
27 | 36 |
res = resp.json() |
28 |
assert res['err'] == 0 |
|
29 | 37 |
pprint.pprint(res) |
38 |
assert res['err'] == 0 |
|
30 | 39 |
print('\n') |
passerelle/contrib/caluire_axel/models.py | ||
---|---|---|
130 | 130 |
link.delete() |
131 | 131 |
return {'link': link_id, 'deleted': True, 'family_id': link.family_id} |
132 | 132 | |
133 |
def get_family_data(self, family_id): |
|
134 |
try: |
|
135 |
result = schemas.get_famille_individus( |
|
136 |
self, {'PORTAIL': {'GETFAMILLE': {'IDENTFAMILLE': family_id}}} |
|
137 |
) |
|
138 |
except axel.AxelError as e: |
|
139 |
raise APIError( |
|
140 |
'Axel error: %s' % e, |
|
141 |
err_code='error', |
|
142 |
data={'xml_request': e.xml_request, 'xml_response': e.xml_response}, |
|
143 |
) |
|
144 | ||
145 |
family_data = result.json_response['DATA']['PORTAIL']['GETFAMILLE'] |
|
146 | ||
147 |
for child in family_data.get('MEMBRE', []): |
|
148 |
child['id'] = child['IDENT'] |
|
149 |
child['text'] = '{} {}'.format(child['PRENOM'].strip(), child['NOM'].strip()).strip() |
|
150 | ||
151 |
return family_data |
|
152 | ||
153 |
@endpoint( |
|
154 |
display_category=_('Family account'), |
|
155 |
display_order=3, |
|
156 |
description=_("Get information about user's family"), |
|
157 |
perm='can_access', |
|
158 |
parameters={ |
|
159 |
'NameID': {'description': _('Publik ID')}, |
|
160 |
}, |
|
161 |
) |
|
162 |
def family_info(self, request, NameID): |
|
163 |
link = self.get_link(NameID) |
|
164 |
family_data = self.get_family_data(link.family_id) |
|
165 |
return {'data': family_data} |
|
166 | ||
133 | 167 | |
134 | 168 |
class Link(models.Model): |
135 | 169 |
resource = models.ForeignKey(CaluireAxel, on_delete=models.CASCADE) |
passerelle/contrib/caluire_axel/schemas.py | ||
---|---|---|
27 | 27 | |
28 | 28 | |
29 | 29 |
find_individus = Operation('FindIndividus') |
30 |
get_famille_individus = Operation('GetFamilleIndividus') |
|
30 | 31 | |
31 | 32 | |
32 | 33 |
LINK_SCHEMA = copy.deepcopy( |
passerelle/contrib/caluire_axel/xsd/Individu.xsd | ||
---|---|---|
19 | 19 |
</xsd:restriction> |
20 | 20 |
</xsd:simpleType> |
21 | 21 |
|
22 |
<xsd:simpleType name="PLACEType"> |
|
23 |
<xsd:restriction base="xsd:string"> |
|
24 |
<xsd:enumeration value="" /> |
|
25 |
<xsd:enumeration value="1" /> |
|
26 |
<xsd:enumeration value="2" /> |
|
27 |
<xsd:enumeration value="3" /> |
|
28 |
</xsd:restriction> |
|
29 |
</xsd:simpleType> |
|
30 |
|
|
31 |
<xsd:complexType name="FAMILLEType"> |
|
32 |
<xsd:sequence> |
|
33 |
<xsd:element name="IDENTFAMILLE" type="all:IDENTType"/> |
|
34 |
<xsd:element name="PLACE" type="ind:PLACEType"/> |
|
35 |
<xsd:element name="SITUATION" type="all:FOOBARType" minOccurs="0" maxOccurs="1"/><!-- CUSTOM --> |
|
36 |
<xsd:element name="QUALITER1" type="all:FOOBARType" minOccurs="0" maxOccurs="1"/><!-- CUSTOM --> |
|
37 |
<xsd:element name="QUALITER2" type="all:FOOBARType" minOccurs="0" maxOccurs="1"/><!-- CUSTOM --> |
|
38 |
</xsd:sequence> |
|
39 |
</xsd:complexType> |
|
40 |
|
|
22 | 41 |
<xsd:complexType name="INDIVIDUType"> |
23 | 42 |
<xsd:sequence> |
24 | 43 |
<xsd:element name="IDENT" type="all:IDENTType"/> |
... | ... | |
31 | 50 |
<xsd:element name="TELFIXE" type="all:TEL2Type"/> |
32 | 51 |
<xsd:element name="TELPORTABLE" type="all:TEL2Type"/> |
33 | 52 |
<xsd:element name="MAIL" type="all:COURRIELType"/> |
34 |
<xsd:element name="CSP" type="all:FOOBARType"/><!-- CUSTOM --> |
|
35 |
<xsd:element name="EMPLOYEUR" type="all:FOOBARType"/><!-- CUSTOM --> |
|
36 |
<xsd:element name="VILLEEMP" type="all:FOOBARType"/><!-- CUSTOM --> |
|
37 |
<xsd:element name="PAI" type="all:FOOBARType"/><!-- CUSTOM --> |
|
53 |
<xsd:element name="CSP" type="all:FOOBARType" minOccurs="0" maxOccurs="1"/><!-- CUSTOM --> |
|
54 |
<xsd:element name="EMPLOYEUR" type="all:FOOBARType" minOccurs="0" maxOccurs="1"/><!-- CUSTOM --> |
|
55 |
<xsd:element name="VILLEEMP" type="all:FOOBARType" minOccurs="0" maxOccurs="1"/><!-- CUSTOM --> |
|
56 |
<xsd:element name="REGIME1" type="all:FOOBARType" minOccurs="0" maxOccurs="1"/><!-- CUSTOM --> |
|
57 |
<xsd:element name="PAI" type="all:FOOBARType" minOccurs="0" maxOccurs="1"/><!-- CUSTOM --> |
|
38 | 58 |
<xsd:element name="GARDEALTERNEE" type="all:FOOBARType"/><!-- CUSTOM --> |
39 | 59 |
<xsd:element name="ADRESSE" type="adr:ADRESSEType" minOccurs="0" maxOccurs="1"/> |
40 |
</xsd:sequence> |
|
60 |
<xsd:element name="FAMILLE" type="ind:FAMILLEType" minOccurs="0" maxOccurs="unbounded"/><!-- CUSTOM --> |
|
61 |
</xsd:sequence> |
|
41 | 62 |
</xsd:complexType> |
42 |
|
|
63 |
|
|
43 | 64 |
</xsd:schema> |
passerelle/contrib/caluire_axel/xsd/Q_GetFamilleIndividus.xsd | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8" ?> |
|
2 |
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:all="urn:AllAxelTypes"> |
|
3 |
|
|
4 |
<xsd:import schemaLocation="./AllAxelTypes.xsd" namespace="urn:AllAxelTypes" /> |
|
5 |
|
|
6 |
<xsd:complexType name="PORTAILType"> |
|
7 |
<xsd:sequence> |
|
8 |
<xsd:element ref="GETFAMILLE" minOccurs="0" maxOccurs="1"/> |
|
9 |
</xsd:sequence> |
|
10 |
</xsd:complexType> |
|
11 |
|
|
12 |
<xsd:complexType name="GETFAMILLEType"> |
|
13 |
<xsd:sequence> |
|
14 |
<xsd:element ref="IDENTFAMILLE"/> |
|
15 |
</xsd:sequence> |
|
16 |
</xsd:complexType> |
|
17 |
|
|
18 |
<xsd:element name="IDENTFAMILLE" type="all:IDENTREQUIREDType"/> |
|
19 |
|
|
20 |
<xsd:element name="GETFAMILLE" type="GETFAMILLEType"/> |
|
21 |
|
|
22 |
<xsd:element name="PORTAIL" type="PORTAILType"/> |
|
23 |
|
|
24 |
</xsd:schema> |
passerelle/contrib/caluire_axel/xsd/R_FindIndividus.xsd | ||
---|---|---|
22 | 22 |
</xsd:complexType> |
23 | 23 |
</xsd:redefine> |
24 | 24 |
|
25 |
<xsd:complexType name="INDIType"> |
|
26 |
<xsd:complexContent> |
|
27 |
<xsd:extension base="ind:INDIVIDUType"> |
|
28 |
<xsd:sequence> |
|
29 |
<xsd:element ref="FAMILLE" minOccurs="0" maxOccurs="unbounded"/> |
|
30 |
</xsd:sequence> |
|
31 |
</xsd:extension> |
|
32 |
</xsd:complexContent> |
|
33 |
</xsd:complexType> |
|
34 |
|
|
35 |
<xsd:complexType name="FAMILLEType"> |
|
36 |
<xsd:sequence> |
|
37 |
<xsd:element ref="IDENTFAMILLE" /> |
|
38 |
<xsd:element ref="PLACE"/> |
|
39 |
<xsd:element ref="SITUATION" minOccurs="0" maxOccurs="1"/><!-- CUSTOM --> |
|
40 |
</xsd:sequence> |
|
41 |
</xsd:complexType> |
|
42 |
|
|
43 |
<xsd:simpleType name="PLACEType"> |
|
44 |
<xsd:restriction base="xsd:string"> |
|
45 |
<xsd:enumeration value="" /> |
|
46 |
<xsd:enumeration value="1" /> |
|
47 |
<xsd:enumeration value="2" /> |
|
48 |
<xsd:enumeration value="3" /> |
|
49 |
</xsd:restriction> |
|
50 |
</xsd:simpleType> |
|
51 |
|
|
52 | 25 |
<xsd:complexType name="FINDINDIVIDUSType"> |
53 | 26 |
<xsd:sequence> |
54 | 27 |
<xsd:element ref="CODE" /> |
55 | 28 |
<xsd:element ref="INDIVIDU" minOccurs="0" maxOccurs="unbounded" /> |
56 |
</xsd:sequence>
|
|
29 |
</xsd:sequence> |
|
57 | 30 |
</xsd:complexType> |
58 | 31 |
|
59 | 32 |
<xsd:element name="CODE" type="xsd:integer"/> |
60 |
<xsd:element name="INDIVIDU" type="INDIType"/> |
|
61 |
<xsd:element name="FAMILLE" type="FAMILLEType"/> |
|
62 |
<xsd:element name="IDENTFAMILLE" type="all:IDENTType"/> |
|
63 |
<xsd:element name="PLACE" type="PLACEType"/> |
|
64 |
<xsd:element name="SITUATION" type="all:FOOBARType"/><!-- CUSTOM --> |
|
33 |
<xsd:element name="INDIVIDU" type="ind:INDIVIDUType"/> |
|
65 | 34 |
|
66 | 35 |
<xsd:element name="FINDINDIVIDUS" type="FINDINDIVIDUSType"/> |
67 | 36 |
|
passerelle/contrib/caluire_axel/xsd/R_GetFamilleIndividus.xsd | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8" ?> |
|
2 |
<xsd:schema xmlns:all="urn:AllAxelTypes" xmlns:ind="urn:Individu" xmlns:xsd="http://www.w3.org/2001/XMLSchema" > |
|
3 |
|
|
4 |
<xsd:import schemaLocation="./Individu.xsd" namespace="urn:Individu" /> |
|
5 |
<xsd:import schemaLocation="./AllAxelTypes.xsd" namespace="urn:AllAxelTypes" /> |
|
6 |
|
|
7 |
<xsd:redefine schemaLocation="./R_ShemaResultat.xsd"> |
|
8 |
<xsd:simpleType name="TYPEType"> |
|
9 |
<xsd:restriction base="TYPEType"> |
|
10 |
<xsd:enumeration value="GetFamilleIndividus" /> |
|
11 |
</xsd:restriction> |
|
12 |
</xsd:simpleType> |
|
13 |
|
|
14 |
<xsd:complexType name="PORTAILType"> |
|
15 |
<xsd:complexContent> |
|
16 |
<xsd:extension base="PORTAILType"> |
|
17 |
<xsd:sequence> |
|
18 |
<xsd:element ref="GETFAMILLE" minOccurs="0" maxOccurs="1"/> |
|
19 |
</xsd:sequence> |
|
20 |
</xsd:extension> |
|
21 |
</xsd:complexContent> |
|
22 |
</xsd:complexType> |
|
23 |
</xsd:redefine> |
|
24 |
|
|
25 |
<xsd:complexType name="GETFAMILLEType"> |
|
26 |
<xsd:sequence> |
|
27 |
<xsd:element ref="CODE" /> |
|
28 |
<xsd:element ref="RESPONSABLE1" minOccurs="0" maxOccurs="1" /> |
|
29 |
<xsd:element ref="RESPONSABLE2" minOccurs="0" maxOccurs="1" /> |
|
30 |
<xsd:element ref="MEMBRE" minOccurs="0" maxOccurs="unbounded" /> |
|
31 |
</xsd:sequence> |
|
32 |
</xsd:complexType> |
|
33 |
|
|
34 |
<xsd:element name="CODE" type="xsd:integer"/> |
|
35 |
<xsd:element name="RESPONSABLE1" type="ind:INDIVIDUType"/> |
|
36 |
<xsd:element name="RESPONSABLE2" type="ind:INDIVIDUType"/> |
|
37 |
<xsd:element name="MEMBRE" type="ind:INDIVIDUType"/> |
|
38 |
|
|
39 |
<xsd:element name="GETFAMILLE" type="GETFAMILLEType"/> |
|
40 |
|
|
41 |
</xsd:schema> |
tests/data/caluire_axel/family_info.xml | ||
---|---|---|
1 |
<PORTAIL> |
|
2 |
<GETFAMILLE> |
|
3 |
<CODE>0</CODE> |
|
4 |
<RESPONSABLE1> |
|
5 |
<IDENT>50630</IDENT> |
|
6 |
<CIVILITE>MME</CIVILITE> |
|
7 |
<NOM>CALUIRE TEST 1</NOM> |
|
8 |
<PRENOM>Maman</PRENOM> |
|
9 |
<NAISSANCE>07/07/1975</NAISSANCE> |
|
10 |
<SEXE>F</SEXE> |
|
11 |
<NOMJF /> |
|
12 |
<TELFIXE>0235384722</TELFIXE> |
|
13 |
<TELPORTABLE>0619290316</TELPORTABLE> |
|
14 |
<MAIL>mamanbobo@caluire.fr</MAIL> |
|
15 |
<CSP /> |
|
16 |
<EMPLOYEUR /> |
|
17 |
<VILLEEMP /> |
|
18 |
<PAI>N</PAI> |
|
19 |
<GARDEALTERNEE>N</GARDEALTERNEE> |
|
20 |
<ADRESSE> |
|
21 |
<ADRESSE3 /> |
|
22 |
<ADRESSE4 /> |
|
23 |
<NORUE>30</NORUE> |
|
24 |
<ADRESSE1>RUE PASTEUR</ADRESSE1> |
|
25 |
<ADRESSE2 /> |
|
26 |
<CODEPOSTAL>69300</CODEPOSTAL> |
|
27 |
<VILLE>CALUIRE ET CUIRE</VILLE> |
|
28 |
<PAYS /> |
|
29 |
<NPAI /> |
|
30 |
</ADRESSE> |
|
31 |
<FAMILLE> |
|
32 |
<IDENTFAMILLE>16777</IDENTFAMILLE> |
|
33 |
<PLACE>1</PLACE> |
|
34 |
<SITUATION>Séparé</SITUATION> |
|
35 |
</FAMILLE> |
|
36 |
</RESPONSABLE1> |
|
37 |
<RESPONSABLE2> |
|
38 |
<IDENT>50631</IDENT> |
|
39 |
<CIVILITE>M</CIVILITE> |
|
40 |
<NOM>CALUIRE TEST 1</NOM> |
|
41 |
<PRENOM>Papa </PRENOM> |
|
42 |
<NAISSANCE>06/09/1875</NAISSANCE> |
|
43 |
<SEXE>M</SEXE> |
|
44 |
<NOMJF /> |
|
45 |
<TELFIXE>02 00 00 00 00</TELFIXE> |
|
46 |
<TELPORTABLE>09 00 00 00 00</TELPORTABLE> |
|
47 |
<MAIL>papaben@caluire.fr</MAIL> |
|
48 |
<CSP /> |
|
49 |
<EMPLOYEUR /> |
|
50 |
<VILLEEMP /> |
|
51 |
<PAI>N</PAI> |
|
52 |
<GARDEALTERNEE>N</GARDEALTERNEE> |
|
53 |
<ADRESSE> |
|
54 |
<ADRESSE3 /> |
|
55 |
<ADRESSE4 /> |
|
56 |
<NORUE>50</NORUE> |
|
57 |
<ADRESSE1>RUE CURIE</ADRESSE1> |
|
58 |
<ADRESSE2 /> |
|
59 |
<CODEPOSTAL>69300</CODEPOSTAL> |
|
60 |
<VILLE>CALUIRE ET CUIRE</VILLE> |
|
61 |
<PAYS /> |
|
62 |
<NPAI /> |
|
63 |
</ADRESSE> |
|
64 |
<FAMILLE> |
|
65 |
<IDENTFAMILLE>16777</IDENTFAMILLE> |
|
66 |
<PLACE>2</PLACE> |
|
67 |
<SITUATION>Séparé</SITUATION> |
|
68 |
</FAMILLE> |
|
69 |
</RESPONSABLE2> |
|
70 |
<MEMBRE> |
|
71 |
<IDENT>50632</IDENT> |
|
72 |
<CIVILITE /> |
|
73 |
<NOM>CALUIRE TEST</NOM> |
|
74 |
<PRENOM>Enfant 1 </PRENOM> |
|
75 |
<NAISSANCE>10/10/2013</NAISSANCE> |
|
76 |
<SEXE>M</SEXE> |
|
77 |
<NOMJF /> |
|
78 |
<TELFIXE /> |
|
79 |
<TELPORTABLE /> |
|
80 |
<MAIL /> |
|
81 |
<PAI>N</PAI> |
|
82 |
<GARDEALTERNEE>O</GARDEALTERNEE> |
|
83 |
<ADRESSE> |
|
84 |
<ADRESSE3 /> |
|
85 |
<ADRESSE4 /> |
|
86 |
<NORUE>30</NORUE> |
|
87 |
<ADRESSE1>RUE PASTEUR</ADRESSE1> |
|
88 |
<ADRESSE2 /> |
|
89 |
<CODEPOSTAL>69300</CODEPOSTAL> |
|
90 |
<VILLE>CALUIRE ET CUIRE</VILLE> |
|
91 |
<PAYS /> |
|
92 |
<NPAI /> |
|
93 |
</ADRESSE> |
|
94 |
<FAMILLE> |
|
95 |
<IDENTFAMILLE>16777</IDENTFAMILLE> |
|
96 |
<PLACE>3</PLACE> |
|
97 |
<SITUATION>Séparé</SITUATION> |
|
98 |
<QUALITER1>Mère</QUALITER1> |
|
99 |
<QUALITER2>Père</QUALITER2> |
|
100 |
</FAMILLE> |
|
101 |
</MEMBRE> |
|
102 |
<MEMBRE> |
|
103 |
<IDENT>50633</IDENT> |
|
104 |
<CIVILITE /> |
|
105 |
<NOM>CALUIRE TEST</NOM> |
|
106 |
<PRENOM>Enfant 2 </PRENOM> |
|
107 |
<NAISSANCE>12/12/2012</NAISSANCE> |
|
108 |
<SEXE>F</SEXE> |
|
109 |
<NOMJF /> |
|
110 |
<TELFIXE /> |
|
111 |
<TELPORTABLE /> |
|
112 |
<MAIL /> |
|
113 |
<PAI>N</PAI> |
|
114 |
<GARDEALTERNEE>N</GARDEALTERNEE> |
|
115 |
<ADRESSE> |
|
116 |
<ADRESSE3 /> |
|
117 |
<ADRESSE4 /> |
|
118 |
<NORUE>30</NORUE> |
|
119 |
<ADRESSE1>RUE PASTEUR</ADRESSE1> |
|
120 |
<ADRESSE2 /> |
|
121 |
<CODEPOSTAL>69300</CODEPOSTAL> |
|
122 |
<VILLE>CALUIRE ET CUIRE</VILLE> |
|
123 |
<PAYS /> |
|
124 |
<NPAI /> |
|
125 |
</ADRESSE> |
|
126 |
<FAMILLE> |
|
127 |
<IDENTFAMILLE>16777</IDENTFAMILLE> |
|
128 |
<PLACE>3</PLACE> |
|
129 |
<SITUATION>Séparé</SITUATION> |
|
130 |
<QUALITER1>Mère</QUALITER1> |
|
131 |
<QUALITER2>Père</QUALITER2> |
|
132 |
</FAMILLE> |
|
133 |
</MEMBRE> |
|
134 |
<MEMBRE> |
|
135 |
<IDENT>54621</IDENT> |
|
136 |
<CIVILITE /> |
|
137 |
<NOM>CALUIRE TEST</NOM> |
|
138 |
<PRENOM>Enfant 3</PRENOM> |
|
139 |
<NAISSANCE>15/03/2010</NAISSANCE> |
|
140 |
<SEXE>M</SEXE> |
|
141 |
<NOMJF /> |
|
142 |
<TELFIXE /> |
|
143 |
<TELPORTABLE /> |
|
144 |
<MAIL /> |
|
145 |
<REGIME1>MALL</REGIME1> |
|
146 |
<PAI>N</PAI> |
|
147 |
<GARDEALTERNEE>N</GARDEALTERNEE> |
|
148 |
<ADRESSE> |
|
149 |
<ADRESSE3 /> |
|
150 |
<ADRESSE4 /> |
|
151 |
<NORUE>30</NORUE> |
|
152 |
<ADRESSE1>RUE PASTEUR</ADRESSE1> |
|
153 |
<ADRESSE2 /> |
|
154 |
<CODEPOSTAL>69300</CODEPOSTAL> |
|
155 |
<VILLE>CALUIRE ET CUIRE</VILLE> |
|
156 |
<PAYS /> |
|
157 |
<NPAI /> |
|
158 |
</ADRESSE> |
|
159 |
<FAMILLE> |
|
160 |
<IDENTFAMILLE>16777</IDENTFAMILLE> |
|
161 |
<PLACE>3</PLACE> |
|
162 |
<SITUATION>Séparé</SITUATION> |
|
163 |
<QUALITER1>Mère</QUALITER1> |
|
164 |
<QUALITER2>Père</QUALITER2> |
|
165 |
</FAMILLE> |
|
166 |
</MEMBRE> |
|
167 |
<MEMBRE> |
|
168 |
<IDENT>59509</IDENT> |
|
169 |
<CIVILITE /> |
|
170 |
<NOM>CALUIRE TEST </NOM> |
|
171 |
<PRENOM>Enfant 5</PRENOM> |
|
172 |
<NAISSANCE>16/11/2009</NAISSANCE> |
|
173 |
<SEXE>F</SEXE> |
|
174 |
<NOMJF /> |
|
175 |
<TELFIXE /> |
|
176 |
<TELPORTABLE /> |
|
177 |
<MAIL /> |
|
178 |
<GARDEALTERNEE>N</GARDEALTERNEE> |
|
179 |
<ADRESSE> |
|
180 |
<ADRESSE3 /> |
|
181 |
<ADRESSE4 /> |
|
182 |
<NORUE>30</NORUE> |
|
183 |
<ADRESSE1>RUE PASTEUR</ADRESSE1> |
|
184 |
<ADRESSE2 /> |
|
185 |
<CODEPOSTAL>69300</CODEPOSTAL> |
|
186 |
<VILLE>CALUIRE ET CUIRE</VILLE> |
|
187 |
<PAYS /> |
|
188 |
<NPAI /> |
|
189 |
</ADRESSE> |
|
190 |
<FAMILLE> |
|
191 |
<IDENTFAMILLE>16777</IDENTFAMILLE> |
|
192 |
<PLACE>3</PLACE> |
|
193 |
<SITUATION>Séparé</SITUATION> |
|
194 |
</FAMILLE> |
|
195 |
</MEMBRE> |
|
196 |
</GETFAMILLE> |
|
197 |
</PORTAIL> |
tests/test_caluire_axel.py | ||
---|---|---|
15 | 15 |
# You should have received a copy of the GNU Affero General Public License |
16 | 16 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | |
18 |
import os |
|
18 | 19 |
from contextlib import contextmanager |
19 | 20 | |
20 | 21 |
import mock |
... | ... | |
365 | 366 |
assert resp.json['link'] == link.pk |
366 | 367 |
assert resp.json['family_id'] == 'XXX' |
367 | 368 |
assert resp.json['deleted'] is True |
369 | ||
370 | ||
371 |
def test_family_info_endpoint_axel_error(app, resource): |
|
372 |
Link.objects.create(resource=resource, name_id='yyy', family_id='XXX', person_id='42') |
|
373 |
with mock.patch('passerelle.contrib.caluire_axel.schemas.get_famille_individus') as operation: |
|
374 |
operation.side_effect = AxelError('FooBar') |
|
375 |
resp = app.get('/caluire-axel/test/family_info?NameID=yyy') |
|
376 |
assert resp.json['err_desc'] == "Axel error: FooBar" |
|
377 |
assert resp.json['err'] == 'error' |
|
378 | ||
379 | ||
380 |
def test_family_info_endpoint_no_result(app, resource): |
|
381 |
resp = app.get('/caluire-axel/test/family_info?NameID=yyy') |
|
382 |
assert resp.json['err_desc'] == "Person not found" |
|
383 |
assert resp.json['err'] == 'not-found' |
|
384 | ||
385 | ||
386 |
def test_family_info_endpoint(app, resource): |
|
387 |
Link.objects.create(resource=resource, name_id='yyy', family_id='XXX', person_id='42') |
|
388 |
filepath = os.path.join(os.path.dirname(__file__), 'data/caluire_axel/family_info.xml') |
|
389 |
with open(filepath) as xml: |
|
390 |
content = xml.read() |
|
391 |
with mock_getdata(content, 'GetFamilleIndividus'): |
|
392 |
resp = app.get('/caluire-axel/test/family_info?NameID=yyy') |
|
393 |
assert resp.json['err'] == 0 |
|
394 |
assert set(resp.json['data'].keys()) == set(['CODE', 'MEMBRE', 'RESPONSABLE1', 'RESPONSABLE2']) |
|
395 |
assert resp.json['data']['MEMBRE'][0]['id'] == '50632' |
|
396 |
assert resp.json['data']['MEMBRE'][0]['text'] == 'Enfant 1 CALUIRE TEST' |
|
397 |
assert resp.json['data']['MEMBRE'][1]['id'] == '50633' |
|
398 |
assert resp.json['data']['MEMBRE'][1]['text'] == 'Enfant 2 CALUIRE TEST' |
|
399 |
assert resp.json['data']['MEMBRE'][2]['id'] == '54621' |
|
400 |
assert resp.json['data']['MEMBRE'][2]['text'] == 'Enfant 3 CALUIRE TEST' |
|
401 |
assert resp.json['data']['MEMBRE'][3]['id'] == '59509' |
|
402 |
assert resp.json['data']['MEMBRE'][3]['text'] == 'Enfant 5 CALUIRE TEST' |
|
368 |
- |