0002-toulouse_axel-update-family-endpoint-38124.patch
functests/toulouse_axel/test_toulouse_axel.py | ||
---|---|---|
24 | 24 |
url = conn + '/family_info?NameID=%s' % name_id |
25 | 25 |
resp = requests.get(url) |
26 | 26 |
resp.raise_for_status() |
27 |
data = resp.json() |
|
28 |
assert res['err'] == 0 |
|
29 |
pprint.pprint(data) |
|
30 |
print('\n') |
|
31 | ||
32 |
payload = data['data'] |
|
33 |
for key in ['SITUATIONFAMILIALE', 'NBENFANTACTIF', 'NBRLACTIF', 'IDDUI', 'CODEMISEAJOUR']: |
|
34 |
payload.pop(key) |
|
35 |
payload['N0TELEDOSSIER'] = '42' |
|
36 |
payload['DROITALIMAGE'] = 'NON' |
|
37 |
for key in ['MONTANTTOTAL', 'DATEVALIDITE', 'SFI', 'IREVENUS', 'RNF']: |
|
38 |
payload['REVENUS'].pop(key) |
|
39 |
payload['REVENUS']['CHOIXREVENU'] = '' |
|
40 |
for enfant in payload['ENFANT']: |
|
41 |
for key in ['NOM', 'DATENAISSANCE', 'SEXE', 'PRENOMPERE', 'PRENOMMERE', 'NOMPERE', 'NOMMERE', 'RATTACHEAUTREDUI', 'PRENOM']: |
|
42 |
enfant.pop(key) |
|
43 |
enfant['AUTORISATIONURGENCEMEDICALE'] = 'OUI' |
|
44 | ||
45 |
print("Update family info with the following payload:") |
|
46 |
pprint.pprint(payload) |
|
47 |
url = conn + '/update_family_info?NameID=%s' % name_id |
|
48 |
resp = requests.post(url, json=payload) |
|
49 |
resp.raise_for_status() |
|
27 | 50 |
res = resp.json() |
28 | 51 |
assert res['err'] == 0 |
29 | 52 |
pprint.pprint(res) |
30 | 53 |
print('\n') |
31 | 54 | |
32 |
data = res |
|
33 | 55 |
for child in data['data']['ENFANT']: |
34 | 56 |
print("GET child info") |
35 | 57 |
url = conn + '/child_info?NameID=%s&idpersonne=%s' % (name_id, child['IDPERSONNE']) |
passerelle/contrib/toulouse_axel/models.py | ||
---|---|---|
91 | 91 | |
92 | 92 |
def __call__(self, resource, request_data): |
93 | 93 |
client = resource.soap_client() |
94 | ||
94 | 95 |
serialized_request = ET.tostring( |
95 | 96 |
self.request_converter.encode(request_data)) |
97 |
try: |
|
98 |
self.request_converter.xml_schema.validate(serialized_request) |
|
99 |
except xmlschema.XMLSchemaValidationError as e: |
|
100 |
raise AxelError('invalid request', str(e)) |
|
101 | ||
96 | 102 |
result = client.service.getData( |
97 | 103 |
self.operation, |
98 | 104 |
force_text(serialized_request), |
... | ... | |
106 | 112 |
try: |
107 | 113 |
return self.response_converter.decode(ET.fromstring(result)) |
108 | 114 |
except xmlschema.XMLSchemaValidationError as e: |
109 |
raise AxelError('invalid response', e)
|
|
115 |
raise AxelError('invalid response', str(e))
|
|
110 | 116 | |
111 | 117 | |
112 | 118 |
ref_verif_dui = Operation('RefVerifDui') |
113 | 119 |
ref_famille_dui = Operation('RefFamilleDui') |
120 |
form_maj_famille_dui = Operation('FormMajFamilleDui') |
|
114 | 121 |
ref_facture_a_payer = Operation('RefFactureAPayer') |
115 | 122 |
ref_facture_pdf = Operation('RefFacturePDF', prefix='') |
116 | 123 | |
... | ... | |
136 | 143 |
LINK_SCHEMA['properties'].pop('IDPERSONNE') |
137 | 144 |
LINK_SCHEMA['required'].remove('IDPERSONNE') |
138 | 145 | |
146 |
UPDATE_FAMILY_SCHEMA = copy.deepcopy( |
|
147 |
form_maj_famille_dui.request_schema['properties']['PORTAIL']['properties']['DUI']) |
|
148 |
UPDATE_FAMILY_SCHEMA['properties'].pop('IDDUI') |
|
149 |
UPDATE_FAMILY_SCHEMA['properties'].pop('DATEDEMANDE') |
|
150 |
UPDATE_FAMILY_SCHEMA['properties'].pop('QUIACTUALISEDUI') |
|
151 |
UPDATE_FAMILY_SCHEMA['required'].remove('IDDUI') |
|
152 |
UPDATE_FAMILY_SCHEMA['required'].remove('DATEDEMANDE') |
|
153 |
UPDATE_FAMILY_SCHEMA['required'].remove('QUIACTUALISEDUI') |
|
154 | ||
139 | 155 |
@endpoint( |
140 | 156 |
description=_('Create link between user and Toulouse Axel'), |
141 | 157 |
perm='can_access', |
... | ... | |
226 | 242 | |
227 | 243 |
raise APIError('Child not found', err='not-found') |
228 | 244 | |
245 |
@endpoint( |
|
246 |
description=_("Update information about user's family"), |
|
247 |
perm='can_access', |
|
248 |
parameters={ |
|
249 |
'NameID': {'description': _('Publik ID')}, |
|
250 |
}, |
|
251 |
post={ |
|
252 |
'request_body': { |
|
253 |
'schema': { |
|
254 |
'application/json': UPDATE_FAMILY_SCHEMA, |
|
255 |
} |
|
256 |
} |
|
257 |
}) |
|
258 |
def update_family_info(self, request, NameID, post_data): |
|
259 |
try: |
|
260 |
link = self.link_set.get(name_id=NameID) |
|
261 |
except Link.DoesNotExist: |
|
262 |
raise APIError('Person not found', err='not-found') |
|
263 | ||
264 |
post_data['IDDUI'] = link.dui |
|
265 |
post_data['DATEDEMANDE'] = datetime.date.today().strftime('%Y-%m-%d') |
|
266 |
if 'RL2' in post_data and post_data['RL2'].get('IDPERSONNE') == link.person_id: |
|
267 |
post_data['QUIACTUALISEDUI'] = '2' |
|
268 |
else: |
|
269 |
post_data['QUIACTUALISEDUI'] = '1' |
|
270 |
try: |
|
271 |
form_maj_famille_dui(self, {'PORTAIL': {'DUI': post_data}}) |
|
272 |
except AxelError as e: |
|
273 |
raise APIError('Axel error: %s' % e, err='error') |
|
274 | ||
275 |
return {'updated': True, 'dui': link.dui} |
|
276 | ||
229 | 277 |
def get_invoices(self, name_id, error_status=200): |
230 | 278 |
link = self.get_link(name_id, error_status=error_status) |
231 | 279 |
try: |
passerelle/contrib/toulouse_axel/xsd/Dui/Q_FormMajFamilleDui.xsd | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8" ?> |
|
2 |
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:all="urn:AllAxelTypes" xmlns:adr="urn:AdresseDui"> |
|
3 | ||
4 |
<xsd:import schemaLocation="../AllAxelTypes.xsd" namespace="urn:AllAxelTypes" /> |
|
5 |
|
|
6 |
<xsd:import schemaLocation="./AdresseDui.xsd" namespace="urn:AdresseDui" /> |
|
7 | ||
8 |
<xsd:include schemaLocation="./ResponsableDui.xsd"/> |
|
9 |
|
|
10 |
<xsd:include schemaLocation="./ContactDui.xsd"/> |
|
11 |
|
|
12 |
<xsd:include schemaLocation="./AssuranceDui.xsd"/> |
|
13 |
|
|
14 |
<xsd:include schemaLocation="./FicheSanitaireDui.xsd"/> |
|
15 | ||
16 |
<xsd:simpleType name="N0TELEDOSSIERType"> |
|
17 |
<xsd:restriction base="xsd:string"> |
|
18 |
<xsd:minLength value="1" /> |
|
19 |
<xsd:maxLength value="12" /> |
|
20 |
</xsd:restriction> |
|
21 |
</xsd:simpleType> |
|
22 |
|
|
23 |
<xsd:simpleType name="QUIACTUALISEDUIType"> |
|
24 |
<xsd:restriction base="xsd:string"> |
|
25 |
<xsd:enumeration value="1" /> |
|
26 |
<xsd:enumeration value="2" /> |
|
27 |
</xsd:restriction> |
|
28 |
</xsd:simpleType> |
|
29 |
|
|
30 |
<xsd:simpleType name="TYPEREGIMEType"> |
|
31 |
<xsd:restriction base="xsd:string"> |
|
32 |
<xsd:enumeration value="" /> |
|
33 |
<xsd:enumeration value="GENE" /> |
|
34 |
<xsd:enumeration value="ZAU" /> |
|
35 |
<xsd:enumeration value="MSA" /> |
|
36 |
</xsd:restriction> |
|
37 |
</xsd:simpleType> |
|
38 |
|
|
39 |
<xsd:simpleType name="NUMEROCAFType"> |
|
40 |
<xsd:restriction base="xsd:string"> |
|
41 |
<xsd:minLength value="0" /> |
|
42 |
<xsd:maxLength value="7" /> |
|
43 |
</xsd:restriction> |
|
44 |
</xsd:simpleType> |
|
45 |
|
|
46 |
<xsd:simpleType name="ALLOCATAIREType"> |
|
47 |
<xsd:restriction base="xsd:string"> |
|
48 |
<xsd:enumeration value="" /> |
|
49 |
<xsd:enumeration value="1" /> |
|
50 |
<xsd:enumeration value="2" /> |
|
51 |
</xsd:restriction> |
|
52 |
</xsd:simpleType> |
|
53 | ||
54 |
<xsd:simpleType name="CHOIXREVENUType"> |
|
55 |
<xsd:restriction base="xsd:string"> |
|
56 |
<xsd:enumeration value="" /> |
|
57 |
<xsd:enumeration value="rnf" /> |
|
58 |
<xsd:enumeration value="cafprooui" /> |
|
59 |
<xsd:enumeration value="RNF" /> |
|
60 |
<xsd:enumeration value="CAFPROOUI" /> |
|
61 |
</xsd:restriction> |
|
62 |
</xsd:simpleType> |
|
63 |
|
|
64 |
<xsd:complexType name="REVENUSType"> |
|
65 |
<xsd:sequence> |
|
66 |
<xsd:element ref="TYPEREGIME" /> |
|
67 |
<xsd:element ref="NUMEROCAF" /> |
|
68 |
<xsd:element ref="ALLOCATAIRE" /> |
|
69 |
<xsd:element ref="CHOIXREVENU" /> |
|
70 |
<xsd:element ref="NBENFANTSACHARGE" /> |
|
71 |
</xsd:sequence> |
|
72 |
</xsd:complexType> |
|
73 |
|
|
74 |
<xsd:complexType name="ENFANTType"> |
|
75 |
<xsd:sequence> |
|
76 |
<xsd:element ref="IDPERSONNE" /> |
|
77 |
<xsd:element ref="AUTORISATIONURGENCEMEDICALE" /> |
|
78 |
<xsd:element ref="ASSURANCE" minOccurs="0" maxOccurs="1"/> |
|
79 |
<xsd:element ref="SANITAIRE" minOccurs="0" maxOccurs="1"/> |
|
80 |
<xsd:element ref="CONTACT" minOccurs="0" maxOccurs="3"/> |
|
81 |
</xsd:sequence> |
|
82 |
</xsd:complexType> |
|
83 |
|
|
84 |
<xsd:complexType name="DUIType"> |
|
85 |
<xsd:sequence> |
|
86 |
<xsd:element ref="DATEDEMANDE" /> |
|
87 |
<xsd:element ref="N0TELEDOSSIER" /> |
|
88 |
<xsd:element ref="IDDUI" /> |
|
89 |
<xsd:element ref="QUIACTUALISEDUI" /> |
|
90 |
<xsd:element ref="DROITALIMAGE" /> |
|
91 |
<xsd:element ref="REACTUALISATIONENLIGNE" /> |
|
92 |
<xsd:element ref="DEMATFACTURES" /> |
|
93 |
<xsd:element ref="ADRESSE" minOccurs="1" maxOccurs="1"/> |
|
94 |
<xsd:element ref="TELFIXE" /> |
|
95 |
<xsd:element ref="RL1" minOccurs="0" maxOccurs="1"/> |
|
96 |
<xsd:element ref="RL2" minOccurs="0" maxOccurs="1"/> |
|
97 |
<xsd:element ref="ENFANT" minOccurs="0" maxOccurs="6"/> |
|
98 |
<xsd:element ref="REVENUS" minOccurs="0" maxOccurs="1"/> |
|
99 |
</xsd:sequence> |
|
100 |
</xsd:complexType> |
|
101 |
|
|
102 |
<xsd:complexType name="PORTAILType"> |
|
103 |
<xsd:sequence> |
|
104 |
<xsd:element ref="DUI"/> |
|
105 |
</xsd:sequence> |
|
106 |
</xsd:complexType> |
|
107 |
|
|
108 |
<xsd:element name="DATEDEMANDE" type="all:DATEType"/> |
|
109 |
<xsd:element name="N0TELEDOSSIER" type="N0TELEDOSSIERType"/> |
|
110 |
<xsd:element name="IDDUI" type="all:IDENTREQUIREDType"/> |
|
111 |
<xsd:element name="QUIACTUALISEDUI" type="QUIACTUALISEDUIType"/> |
|
112 |
<xsd:element name="DROITALIMAGE" type="all:OUINONREQUIREDType"/> |
|
113 |
<xsd:element name="REACTUALISATIONENLIGNE" type="all:OUINONREQUIREDType"/> |
|
114 |
<xsd:element name="DEMATFACTURES" type="all:OUINONREQUIREDType"/> |
|
115 |
<xsd:element name="ADRESSE" type="adr:ADRESSEType"/> |
|
116 |
<xsd:element name="TELFIXE" type="all:TELType"/> |
|
117 |
<xsd:element name="RL1" type="RESPONSABLE1Type"/> |
|
118 |
<xsd:element name="RL2" type="RESPONSABLE2Type"/> |
|
119 |
<xsd:element name="ENFANT" type="ENFANTType"/> |
|
120 |
<xsd:element name="REVENUS" type="REVENUSType"/> |
|
121 |
|
|
122 |
<xsd:element name="IDPERSONNE" type="all:IDENTREQUIREDType"/> |
|
123 |
<xsd:element name="AUTORISATIONURGENCEMEDICALE" type="all:OUINONREQUIREDType"/> |
|
124 |
<xsd:element name="ASSURANCE" type="ASSURANCEType"/> |
|
125 |
<xsd:element name="SANITAIRE" type="SANITAIREType"/> |
|
126 |
<xsd:element name="CONTACT" type="CONTACTType"/> |
|
127 |
|
|
128 |
<xsd:element name="TYPEREGIME" type="TYPEREGIMEType"/> |
|
129 |
<xsd:element name="NUMEROCAF" type="NUMEROCAFType"/> |
|
130 |
<xsd:element name="ALLOCATAIRE" type="ALLOCATAIREType"/> |
|
131 |
<xsd:element name="CHOIXREVENU" type="CHOIXREVENUType"/> |
|
132 |
<xsd:element name="NBENFANTSACHARGE" type="all:unsignedInt-or-empty"/> |
|
133 |
|
|
134 |
<xsd:element name="DUI" type="DUIType"/> |
|
135 |
|
|
136 |
<xsd:element name="PORTAIL" type="PORTAILType"/> |
|
137 |
</xsd:schema> |
passerelle/contrib/toulouse_axel/xsd/Dui/R_FormMajFamilleDui.xsd | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8" ?> |
|
2 |
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
|
3 | ||
4 |
<xsd:redefine schemaLocation="../R_ShemaResultat.xsd"> |
|
5 |
<xsd:simpleType name="TYPEType"> |
|
6 |
<xsd:restriction base="TYPEType"> |
|
7 |
<xsd:enumeration value="FormMajFamilleDui" /> |
|
8 |
</xsd:restriction> |
|
9 |
</xsd:simpleType> |
|
10 |
|
|
11 |
<xsd:complexType name="PORTAILType"> |
|
12 |
<xsd:complexContent> |
|
13 |
<xsd:extension base="PORTAILType"> |
|
14 |
<xsd:sequence> |
|
15 |
<xsd:element name="DUI" type="xsd:string" minOccurs="0"/> |
|
16 |
</xsd:sequence> |
|
17 |
</xsd:extension> |
|
18 |
</xsd:complexContent> |
|
19 |
</xsd:complexType> |
|
20 |
</xsd:redefine> |
|
21 |
</xsd:schema> |
tests/data/toulouse_axel/update_family_info.json | ||
---|---|---|
1 |
{ |
|
2 |
"ADRESSE": { |
|
3 |
"CODEINSEEVILLE": null, |
|
4 |
"CODEPOSTAL": "31400", |
|
5 |
"COMPLEMENT1": "foo", |
|
6 |
"COMPLEMENT2": null, |
|
7 |
"COMPLEMENTVOIE": null, |
|
8 |
"NUMEROSTI": "1234", |
|
9 |
"NUMVOIE": "42", |
|
10 |
"VILLE": "TOULOUSE", |
|
11 |
"VOIE": "RUE bar" |
|
12 |
}, |
|
13 |
"DEMATFACTURES": "NON", |
|
14 |
"DROITALIMAGE": "NON", |
|
15 |
"ENFANT": [ |
|
16 |
{ |
|
17 |
"ASSURANCE": { |
|
18 |
"DATEFIN": "2020-12-31", |
|
19 |
"NOM": "foo", |
|
20 |
"NUMERO": "1234" |
|
21 |
}, |
|
22 |
"AUTORISATIONURGENCEMEDICALE": "OUI", |
|
23 |
"CONTACT": [ |
|
24 |
{ |
|
25 |
"CHERCHERLENFANT": "OUI", |
|
26 |
"ENCASURGENCE": "OUI", |
|
27 |
"LIENPARENTE": null, |
|
28 |
"NOM": "foo", |
|
29 |
"PRENOM": "foo", |
|
30 |
"TELFIXE": "0505050505", |
|
31 |
"TELPORTABLE": "0606060606" |
|
32 |
}, |
|
33 |
{ |
|
34 |
"CHERCHERLENFANT": "OUI", |
|
35 |
"ENCASURGENCE": "OUI", |
|
36 |
"LIENPARENTE": null, |
|
37 |
"NOM": "foo", |
|
38 |
"PRENOM": "foo", |
|
39 |
"TELFIXE": "0505050505", |
|
40 |
"TELPORTABLE": "0606060606" |
|
41 |
}, |
|
42 |
{ |
|
43 |
"CHERCHERLENFANT": "OUI", |
|
44 |
"ENCASURGENCE": "OUI", |
|
45 |
"LIENPARENTE": null, |
|
46 |
"NOM": "foo", |
|
47 |
"PRENOM": "foo", |
|
48 |
"TELFIXE": "0505050505", |
|
49 |
"TELPORTABLE": "0606060606" |
|
50 |
} |
|
51 |
], |
|
52 |
"IDPERSONNE": "4242", |
|
53 |
"SANITAIRE": { |
|
54 |
"ALLERGIE": [ |
|
55 |
{ |
|
56 |
"ALLERGIQUE": "OUI", |
|
57 |
"NOMALLERGIE": null, |
|
58 |
"TYPE": "ASTHME" |
|
59 |
}, |
|
60 |
{ |
|
61 |
"ALLERGIQUE": "OUI", |
|
62 |
"NOMALLERGIE": null, |
|
63 |
"TYPE": "MEDICAMENTEUSES" |
|
64 |
}, |
|
65 |
{ |
|
66 |
"ALLERGIQUE": "OUI", |
|
67 |
"NOMALLERGIE": null, |
|
68 |
"TYPE": "ALIMENTAIRES" |
|
69 |
} |
|
70 |
], |
|
71 |
"AUTREDIFFICULTE": null, |
|
72 |
"DATEFINVALIDITE": "2020-12-31", |
|
73 |
"ECOLESPECIALISEE": null, |
|
74 |
"INDICATEURAUXILIAIREVS": "NON", |
|
75 |
"INDICATEURECOLE": "NON", |
|
76 |
"INDICATEURHANDICAP": "NON", |
|
77 |
"INDICATEURNOTIFMDPH": "NON", |
|
78 |
"INDICATEURPAI": "NON", |
|
79 |
"INFOUTILES": null, |
|
80 |
"MEDECIN": { |
|
81 |
"NOM": "foo", |
|
82 |
"TELMEDECIN": "0505050505" |
|
83 |
}, |
|
84 |
"VACCIN": { |
|
85 |
"AUTRE": null, |
|
86 |
"BCGAJOUR": null, |
|
87 |
"COQAJOUR": null, |
|
88 |
"DAJOUR": null, |
|
89 |
"HBAJOUR": null, |
|
90 |
"HIBAJOUR": null, |
|
91 |
"IIPAJOUR": null, |
|
92 |
"MENINAJOUR": null, |
|
93 |
"PAJOUR": null, |
|
94 |
"RORAJOUR": null, |
|
95 |
"TAJOUR": null |
|
96 |
} |
|
97 |
} |
|
98 |
}, |
|
99 |
{ |
|
100 |
"ASSURANCE": { |
|
101 |
"DATEFIN": "2020-12-31", |
|
102 |
"NOM": "foo", |
|
103 |
"NUMERO": "1234" |
|
104 |
}, |
|
105 |
"AUTORISATIONURGENCEMEDICALE": "OUI", |
|
106 |
"IDPERSONNE": "3535", |
|
107 |
"SANITAIRE": { |
|
108 |
"ALLERGIE": [ |
|
109 |
{ |
|
110 |
"ALLERGIQUE": "OUI", |
|
111 |
"NOMALLERGIE": null, |
|
112 |
"TYPE": "ASTHME" |
|
113 |
}, |
|
114 |
{ |
|
115 |
"ALLERGIQUE": "OUI", |
|
116 |
"NOMALLERGIE": null, |
|
117 |
"TYPE": "MEDICAMENTEUSES" |
|
118 |
}, |
|
119 |
{ |
|
120 |
"ALLERGIQUE": "OUI", |
|
121 |
"NOMALLERGIE": null, |
|
122 |
"TYPE": "ALIMENTAIRES" |
|
123 |
} |
|
124 |
], |
|
125 |
"AUTREDIFFICULTE": null, |
|
126 |
"DATEFINVALIDITE": "2020-12-31", |
|
127 |
"ECOLESPECIALISEE": null, |
|
128 |
"INDICATEURAUXILIAIREVS": "NON", |
|
129 |
"INDICATEURECOLE": "NON", |
|
130 |
"INDICATEURHANDICAP": "NON", |
|
131 |
"INDICATEURNOTIFMDPH": "NON", |
|
132 |
"INDICATEURPAI": "NON", |
|
133 |
"INFOUTILES": null, |
|
134 |
"MEDECIN": { |
|
135 |
"NOM": "foo", |
|
136 |
"TELMEDECIN": "0505050505" |
|
137 |
}, |
|
138 |
"VACCIN": { |
|
139 |
"AUTRE": null, |
|
140 |
"BCGAJOUR": null, |
|
141 |
"COQAJOUR": "OUI", |
|
142 |
"DAJOUR": "OUI", |
|
143 |
"HBAJOUR": "OUI", |
|
144 |
"HIBAJOUR": "OUI", |
|
145 |
"IIPAJOUR": "OUI", |
|
146 |
"MENINAJOUR": "OUI", |
|
147 |
"PAJOUR": "OUI", |
|
148 |
"RORAJOUR": "OUI", |
|
149 |
"TAJOUR": "OUI" |
|
150 |
} |
|
151 |
} |
|
152 |
} |
|
153 |
], |
|
154 |
"N0TELEDOSSIER": "42", |
|
155 |
"REACTUALISATIONENLIGNE": "NON", |
|
156 |
"REVENUS": { |
|
157 |
"ALLOCATAIRE": "2", |
|
158 |
"CHOIXREVENU": "", |
|
159 |
"NBENFANTSACHARGE": 2, |
|
160 |
"NUMEROCAF": "1234", |
|
161 |
"TYPEREGIME": "GENE" |
|
162 |
}, |
|
163 |
"RL1": { |
|
164 |
"ADREMPLOYEUR": { |
|
165 |
"CODEINSEEVILLE": null, |
|
166 |
"CODEPOSTAL": null, |
|
167 |
"COMPLEMENT1": null, |
|
168 |
"COMPLEMENT2": null, |
|
169 |
"COMPLEMENTVOIE": null, |
|
170 |
"NUMEROSTI": null, |
|
171 |
"NUMVOIE": null, |
|
172 |
"VILLE": null, |
|
173 |
"VOIE": null |
|
174 |
}, |
|
175 |
"CIVILITE": "M", |
|
176 |
"COURRIEL": "foo@bar.com", |
|
177 |
"CSP": "ETU", |
|
178 |
"DATENAISSANCE": "1980-01-01", |
|
179 |
"IDPERSONNE": "42", |
|
180 |
"INDICATEURRL": "1", |
|
181 |
"NOM": "foo", |
|
182 |
"NOMEMPLOYEUR": "foo", |
|
183 |
"NOMJEUNEFILLE": null, |
|
184 |
"PRENOM": "foo", |
|
185 |
"PROFESSION": "ETUDIANT", |
|
186 |
"TELPORTABLE": "0606060606" |
|
187 |
}, |
|
188 |
"RL2": { |
|
189 |
"ADREMPLOYEUR": { |
|
190 |
"CODEINSEEVILLE": null, |
|
191 |
"CODEPOSTAL": null, |
|
192 |
"COMPLEMENT1": null, |
|
193 |
"COMPLEMENT2": null, |
|
194 |
"COMPLEMENTVOIE": null, |
|
195 |
"NUMEROSTI": null, |
|
196 |
"NUMVOIE": null, |
|
197 |
"VILLE": null, |
|
198 |
"VOIE": null |
|
199 |
}, |
|
200 |
"CIVILITE": "MME", |
|
201 |
"COURRIEL": "foo@bar.com", |
|
202 |
"CSP": "EMP", |
|
203 |
"DATENAISSANCE": "1980-01-01", |
|
204 |
"IDPERSONNE": "35", |
|
205 |
"INDICATEURRL": "2", |
|
206 |
"NOM": "foo", |
|
207 |
"NOMEMPLOYEUR": "foo", |
|
208 |
"NOMJEUNEFILLE": null, |
|
209 |
"PRENOM": "foo", |
|
210 |
"PROFESSION": "foo", |
|
211 |
"TELPORTABLE": "0606060606" |
|
212 |
}, |
|
213 |
"TELFIXE": null |
|
214 |
} |
tests/test_toulouse_axel.py | ||
---|---|---|
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | |
17 | 17 |
from contextlib import contextmanager |
18 |
import datetime |
|
19 |
import json |
|
18 | 20 |
import mock |
19 | 21 |
import os |
20 | 22 | |
... | ... | |
24 | 26 |
AxelError, |
25 | 27 |
Link, |
26 | 28 |
ToulouseAxel, |
29 |
form_maj_famille_dui, |
|
27 | 30 |
ref_famille_dui, |
28 | 31 |
ref_facture_a_payer, |
29 | 32 |
ref_facture_pdf, |
... | ... | |
41 | 44 | |
42 | 45 | |
43 | 46 |
@pytest.fixture |
44 |
def params(): |
|
47 |
def link_params():
|
|
45 | 48 |
return { |
46 | 49 |
'IDDUI': 'XXX', |
47 | 50 |
'PRENOM': 'John', |
... | ... | |
50 | 53 |
} |
51 | 54 | |
52 | 55 | |
56 |
@pytest.fixture |
|
57 |
def update_params(): |
|
58 |
filepath = os.path.join(os.path.dirname(__file__), 'data/toulouse_axel/update_family_info.json') |
|
59 |
with open(filepath) as jsonfile: |
|
60 |
content = jsonfile.read() |
|
61 |
return json.loads(content) |
|
62 | ||
63 | ||
53 | 64 |
def test_operation_status_error(resource): |
54 | 65 |
resp = ''' |
55 | 66 |
<?xml version="1.0"?> |
... | ... | |
70 | 81 |
ref_verif_dui(resource, { |
71 | 82 |
'PORTAIL': { |
72 | 83 |
'DUI': { |
84 |
'IDDUI': 'XXX', |
|
85 |
'IDPERSONNE': '42', |
|
73 | 86 |
'PRENOM': 'John', |
74 | 87 |
'NOM': 'Doe', |
75 | 88 |
'NAISSANCE': '2010-10-10', |
... | ... | |
133 | 146 |
}) |
134 | 147 | |
135 | 148 | |
149 |
@pytest.mark.parametrize('content', [ |
|
150 |
'<PORTAIL><DUI/></PORTAIL>', |
|
151 |
]) |
|
152 |
def test_operation_form_maj_famille_dui(resource, content): |
|
153 |
with mock_getdata(content, 'FormMajFamilleDui'): |
|
154 |
with pytest.raises(AxelError): |
|
155 |
form_maj_famille_dui(resource, { |
|
156 |
'PORTAIL': { |
|
157 |
'DUI': { |
|
158 |
'IDDUI': 'XXX', |
|
159 |
} |
|
160 |
} |
|
161 |
}) |
|
162 | ||
163 | ||
136 | 164 |
@pytest.mark.parametrize('content', [ |
137 | 165 |
'<PORTAIL><DUI/></PORTAIL>', |
138 | 166 |
]) |
... | ... | |
163 | 191 |
}) |
164 | 192 | |
165 | 193 | |
166 |
def test_link_endpoint_nameid_empty(app, resource, params): |
|
167 |
resp = app.post_json('/toulouse-axel/test/link?NameID=', params=params, status=400) |
|
194 |
def test_link_endpoint_nameid_empty(app, resource, link_params):
|
|
195 |
resp = app.post_json('/toulouse-axel/test/link?NameID=', params=link_params, status=400)
|
|
168 | 196 |
assert resp.json['err_desc'] == "NameID is empty" |
169 | 197 | |
170 | 198 | |
171 |
def test_link_endpoint_axel_error(app, resource, params): |
|
199 |
def test_link_endpoint_axel_error(app, resource, link_params):
|
|
172 | 200 |
with mock.patch('passerelle.contrib.toulouse_axel.models.ref_verif_dui') as operation: |
173 | 201 |
operation.side_effect = AxelError('FooBar') |
174 |
resp = app.post_json('/toulouse-axel/test/link?NameID=yyy', params=params) |
|
202 |
resp = app.post_json('/toulouse-axel/test/link?NameID=yyy', params=link_params)
|
|
175 | 203 |
assert resp.json['err_desc'] == "Axel error: FooBar" |
176 | 204 | |
177 | 205 | |
... | ... | |
180 | 208 |
'<IDDUI>XXX</IDDUI><IDPERSONNE>42</IDPERSONNE><CODE>1</CODE>', |
181 | 209 |
'<IDDUI>XXX</IDDUI><IDPERSONNE>42</IDPERSONNE><CODE>4</CODE>', |
182 | 210 |
]) |
183 |
def test_link_endpoint_no_result(app, resource, params, xml_response): |
|
211 |
def test_link_endpoint_no_result(app, resource, link_params, xml_response):
|
|
184 | 212 |
content = '''<PORTAIL> |
185 | 213 |
<DUI> |
186 | 214 |
%s |
187 | 215 |
</DUI> |
188 | 216 |
</PORTAIL>''' % xml_response |
189 | 217 |
with mock_getdata(content, 'RefVerifDui'): |
190 |
resp = app.post_json('/toulouse-axel/test/link?NameID=yyy', params=params) |
|
218 |
resp = app.post_json('/toulouse-axel/test/link?NameID=yyy', params=link_params)
|
|
191 | 219 |
assert resp.json['err_desc'] == "Person not found" |
192 | 220 | |
193 | 221 | |
194 |
def test_link_endpoint_conflict(app, resource, params): |
|
222 |
def test_link_endpoint_conflict(app, resource, link_params):
|
|
195 | 223 |
content = '''<PORTAIL> |
196 | 224 |
<DUI> |
197 | 225 |
<IDDUI>XXX</IDDUI> |
... | ... | |
202 | 230 |
# existing link but dui is wrong |
203 | 231 |
link = Link.objects.create(resource=resource, name_id='yyy', dui='YYY', person_id='42') |
204 | 232 |
with mock_getdata(content, 'RefVerifDui'): |
205 |
resp = app.post_json('/toulouse-axel/test/link?NameID=yyy', params=params) |
|
233 |
resp = app.post_json('/toulouse-axel/test/link?NameID=yyy', params=link_params)
|
|
206 | 234 |
assert resp.json['err_desc'] == "Data conflict" |
207 | 235 | |
208 | 236 |
# existing link but person_id is wrong |
... | ... | |
210 | 238 |
link.person_id = '35' |
211 | 239 |
link.save() |
212 | 240 |
with mock_getdata(content, 'RefVerifDui'): |
213 |
resp = app.post_json('/toulouse-axel/test/link?NameID=yyy', params=params) |
|
241 |
resp = app.post_json('/toulouse-axel/test/link?NameID=yyy', params=link_params)
|
|
214 | 242 |
assert resp.json['err_desc'] == "Data conflict" |
215 | 243 | |
216 | 244 | |
217 | 245 |
@pytest.mark.parametrize('code', [2, 3]) |
218 |
def test_link_endpoint(app, resource, params, code): |
|
246 |
def test_link_endpoint(app, resource, link_params, code):
|
|
219 | 247 |
content = '''<PORTAIL> |
220 | 248 |
<DUI> |
221 | 249 |
<IDDUI>XXX</IDDUI> |
... | ... | |
224 | 252 |
</DUI> |
225 | 253 |
</PORTAIL>''' % code |
226 | 254 |
with mock_getdata(content, 'RefVerifDui'): |
227 |
resp = app.post_json('/toulouse-axel/test/link?NameID=yyy', params=params) |
|
255 |
resp = app.post_json('/toulouse-axel/test/link?NameID=yyy', params=link_params)
|
|
228 | 256 |
assert set(resp.json.keys()) == set([ |
229 | 257 |
'err', 'link', 'created', 'dui']) |
230 | 258 |
assert resp.json['err'] == 0 |
... | ... | |
233 | 261 | |
234 | 262 |
# again |
235 | 263 |
with mock_getdata(content, 'RefVerifDui'): |
236 |
resp = app.post_json('/toulouse-axel/test/link?NameID=yyy', params=params) |
|
264 |
resp = app.post_json('/toulouse-axel/test/link?NameID=yyy', params=link_params)
|
|
237 | 265 |
assert set(resp.json.keys()) == set([ |
238 | 266 |
'err', 'link', 'created', 'dui']) |
239 | 267 |
assert resp.json['err'] == 0 |
... | ... | |
340 | 368 |
]) |
341 | 369 | |
342 | 370 | |
371 |
def test_update_family_info_endpoint_axel_error(app, resource, update_params): |
|
372 |
Link.objects.create(resource=resource, name_id='yyy', dui='XXX', person_id='42') |
|
373 |
with mock.patch('passerelle.contrib.toulouse_axel.models.form_maj_famille_dui') as operation: |
|
374 |
operation.side_effect = AxelError('FooBar') |
|
375 |
resp = app.post_json('/toulouse-axel/test/update_family_info?NameID=yyy', params=update_params) |
|
376 |
assert resp.json['err_desc'] == "Axel error: FooBar" |
|
377 | ||
378 | ||
379 |
def test_update_family_info_endpoint_no_result(app, resource, update_params): |
|
380 |
resp = app.post_json('/toulouse-axel/test/update_family_info?NameID=yyy', params=update_params) |
|
381 |
assert resp.json['err_desc'] == "Person not found" |
|
382 | ||
383 | ||
384 |
def test_update_family_info_endpoint(app, resource, update_params): |
|
385 |
link = Link.objects.create(resource=resource, name_id='yyy', dui='XXX', person_id='42') |
|
386 |
content = "<PORTAIL/>" |
|
387 |
with mock_getdata(content, 'FormMajFamilleDui'): |
|
388 |
resp = app.post_json('/toulouse-axel/test/update_family_info?NameID=yyy', params=update_params) |
|
389 |
assert resp.json['err'] == 0 |
|
390 |
assert resp.json['dui'] == 'XXX' |
|
391 |
assert resp.json['updated'] is True |
|
392 | ||
393 |
with mock.patch('passerelle.contrib.toulouse_axel.models.form_maj_famille_dui') as operation: |
|
394 |
resp = app.post_json('/toulouse-axel/test/update_family_info?NameID=yyy', params=update_params) |
|
395 |
assert operation.call_args_list[0][0][1]['PORTAIL']['DUI']['IDDUI'] == 'XXX' |
|
396 |
assert operation.call_args_list[0][0][1]['PORTAIL']['DUI']['DATEDEMANDE'] == datetime.date.today().strftime('%Y-%m-%d') |
|
397 |
assert operation.call_args_list[0][0][1]['PORTAIL']['DUI']['QUIACTUALISEDUI'] == '1' |
|
398 | ||
399 |
link.person_id = '35' |
|
400 |
link.save() |
|
401 |
with mock.patch('passerelle.contrib.toulouse_axel.models.form_maj_famille_dui') as operation: |
|
402 |
resp = app.post_json('/toulouse-axel/test/update_family_info?NameID=yyy', params=update_params) |
|
403 |
assert operation.call_args_list[0][0][1]['PORTAIL']['DUI']['IDDUI'] == 'XXX' |
|
404 |
assert operation.call_args_list[0][0][1]['PORTAIL']['DUI']['DATEDEMANDE'] == datetime.date.today().strftime('%Y-%m-%d') |
|
405 |
assert operation.call_args_list[0][0][1]['PORTAIL']['DUI']['QUIACTUALISEDUI'] == '2' |
|
406 | ||
407 | ||
343 | 408 |
def test_invoices_endpoint_axel_error(app, resource): |
344 | 409 |
Link.objects.create(resource=resource, name_id='yyy', dui='XXX', person_id='42') |
345 | 410 |
with mock.patch('passerelle.contrib.toulouse_axel.models.ref_facture_a_payer') as operation: |
346 |
- |