16 |
16 |
import logging
|
17 |
17 |
import os
|
18 |
18 |
from unittest import mock
|
19 |
19 |
|
20 |
20 |
import pytest
|
21 |
21 |
from lxml import etree
|
22 |
22 |
from requests.exceptions import ConnectionError
|
23 |
23 |
|
24 |
|
from passerelle.contrib.toulouse_maelis.models import Link, ToulouseMaelis
|
|
24 |
from passerelle.contrib.toulouse_maelis.models import Link, Referential, ToulouseMaelis
|
25 |
25 |
from passerelle.utils.jsonresponse import APIError
|
26 |
26 |
from passerelle.utils.soap import SOAPError
|
27 |
27 |
from tests.utils import FakedResponse, generic_endpoint_url, setup_access_rights
|
28 |
28 |
|
29 |
29 |
TEST_BASE_DIR = os.path.join(os.path.dirname(__file__), 'data', 'toulouse_maelis')
|
30 |
30 |
|
31 |
31 |
|
32 |
32 |
def get_xml_file(filename):
|
... | ... | |
40 |
40 |
INVOICE_SERVICE_WSDL = FakedResponse(content=get_xml_file('InvoiceService.wsdl'), status_code=200)
|
41 |
41 |
FAILED_AUTH = FakedResponse(content=get_xml_file('R_failed_authentication.xml'), status_code=500)
|
42 |
42 |
ISWSRUNNING_TRUE = FakedResponse(content=get_xml_file('R_is_ws_running.xml') % b'true', status_code=200)
|
43 |
43 |
ISWSRUNNING_FALSE = FakedResponse(content=get_xml_file('R_is_ws_running.xml') % b'false', status_code=200)
|
44 |
44 |
READ_FAMILY = FakedResponse(content=get_xml_file('R_read_family.xml'), status_code=200)
|
45 |
45 |
READ_FAMILY_LAX = FakedResponse(content=get_xml_file('R_read_family_relax.xml'), status_code=200)
|
46 |
46 |
READ_FAMILY_ORD = FakedResponse(content=get_xml_file('R_read_family_reordered.xml'), status_code=200)
|
47 |
47 |
READ_RL1_FAMILY = FakedResponse(content=get_xml_file('R_read_family_with_only_rl1.xml'), status_code=200)
|
48 |
|
READ_CATEGORIES = FakedResponse(content=get_xml_file('R_read_category_list.xml'), status_code=200)
|
49 |
|
READ_CHILD_INDICATOR = FakedResponse(content=get_xml_file('R_read_child_indicator_list.xml'), status_code=200)
|
50 |
|
READ_CIVILITIES = FakedResponse(content=get_xml_file('R_read_civility_list.xml'), status_code=200)
|
51 |
|
READ_COUNTRY = FakedResponse(content=get_xml_file('R_read_country_list.xml'), status_code=200)
|
52 |
|
READ_CSP = FakedResponse(content=get_xml_file('R_read_csp_list.xml'), status_code=200)
|
53 |
|
READ_DIETCODE = FakedResponse(content=get_xml_file('R_read_dietcode_list.xml'), status_code=200)
|
54 |
|
READ_ORGAN = FakedResponse(content=get_xml_file('R_read_organ_list.xml'), status_code=200)
|
55 |
|
READ_PAI = FakedResponse(content=get_xml_file('R_read_pai_list.xml'), status_code=200)
|
56 |
|
READ_QUALITIES = FakedResponse(content=get_xml_file('R_read_quality_list.xml'), status_code=200)
|
57 |
|
READ_QUOTIENT = FakedResponse(content=get_xml_file('R_read_quotient_list.xml'), status_code=200)
|
58 |
|
READ_RL_INDICATOR = FakedResponse(content=get_xml_file('R_read_rl_indicator_list.xml'), status_code=200)
|
59 |
|
READ_SITUATIONS = FakedResponse(content=get_xml_file('R_read_situation_list.xml'), status_code=200)
|
60 |
|
READ_STREET = FakedResponse(content=get_xml_file('R_read_street_list.xml'), status_code=200)
|
61 |
|
READ_VACCIN = FakedResponse(content=get_xml_file('R_read_vaccin_list.xml'), status_code=200)
|
62 |
48 |
IS_RL_EXISTS_TRUE = FakedResponse(content=get_xml_file('R_is_rl_exists.xml') % b'true', status_code=200)
|
63 |
49 |
IS_RL_EXISTS_FALSE = FakedResponse(content=get_xml_file('R_is_rl_exists.xml') % b'false', status_code=200)
|
64 |
50 |
IS_CHILD_EXISTS_TRUE = FakedResponse(content=get_xml_file('R_is_child_exists.xml') % b'true', status_code=200)
|
65 |
51 |
IS_CHILD_EXISTS_FALSE = FakedResponse(
|
66 |
52 |
content=get_xml_file('R_is_child_exists.xml') % b'false', status_code=200
|
67 |
53 |
)
|
68 |
54 |
CREATE_FAMILY = FakedResponse(content=get_xml_file('R_create_family.xml'), status_code=200)
|
69 |
55 |
CREATE_FAMILY_ERR = FakedResponse(content=get_xml_file('R_create_family_error.xml'), status_code=200)
|
... | ... | |
100 |
86 |
ToulouseMaelis.objects.create(
|
101 |
87 |
slug='test',
|
102 |
88 |
zeep_wsse_username='maelis-webservice',
|
103 |
89 |
zeep_wsse_password='maelis-password',
|
104 |
90 |
)
|
105 |
91 |
)
|
106 |
92 |
|
107 |
93 |
|
|
94 |
@pytest.fixture
|
|
95 |
def ref(con, caplog):
|
|
96 |
mocked_get = mock.patch('passerelle.utils.Request.get', return_value=FAMILY_SERVICE_WSDL)
|
|
97 |
mocked_post = mock.patch(
|
|
98 |
'passerelle.utils.Request.post',
|
|
99 |
side_effect=[
|
|
100 |
FakedResponse(content=get_xml_file('R_read_category_list.xml'), status_code=200),
|
|
101 |
FakedResponse(content=get_xml_file('R_read_child_indicator_list.xml'), status_code=200),
|
|
102 |
FakedResponse(content=get_xml_file('R_read_civility_list.xml'), status_code=200),
|
|
103 |
FakedResponse(content=get_xml_file('R_read_country_list.xml'), status_code=200),
|
|
104 |
FakedResponse(content=get_xml_file('R_read_csp_list.xml'), status_code=200),
|
|
105 |
FakedResponse(content=get_xml_file('R_read_dietcode_list.xml'), status_code=200),
|
|
106 |
FakedResponse(content=get_xml_file('R_read_organ_list.xml'), status_code=200),
|
|
107 |
FakedResponse(content=get_xml_file('R_read_pai_list.xml'), status_code=200),
|
|
108 |
FakedResponse(content=get_xml_file('R_read_quality_list.xml'), status_code=200),
|
|
109 |
FakedResponse(content=get_xml_file('R_read_quotient_list.xml'), status_code=200),
|
|
110 |
FakedResponse(content=get_xml_file('R_read_rl_indicator_list.xml'), status_code=200),
|
|
111 |
FakedResponse(content=get_xml_file('R_read_situation_list.xml'), status_code=200),
|
|
112 |
FakedResponse(content=get_xml_file('R_read_street_list.xml'), status_code=200),
|
|
113 |
FakedResponse(content=get_xml_file('R_read_vaccin_list.xml'), status_code=200),
|
|
114 |
],
|
|
115 |
)
|
|
116 |
mocked_get.start()
|
|
117 |
mocked_post.start()
|
|
118 |
con.daily()
|
|
119 |
assert caplog.messages[-1] == 'Réferentiels mis à jour.'
|
|
120 |
|
|
121 |
|
108 |
122 |
@mock.patch('passerelle.utils.Request.get')
|
109 |
123 |
def test_call_with_wrong_wsdl_url(mocked_get, con):
|
110 |
124 |
mocked_get.side_effect = CONNECTION_ERROR
|
111 |
125 |
with pytest.raises(
|
112 |
126 |
SOAPError,
|
113 |
127 |
match='cannot be loaded: No address associated with hostname',
|
114 |
128 |
) as e:
|
115 |
129 |
con.call('Family', 'isWSRunning')
|
... | ... | |
201 |
215 |
'street1': 'Chateau',
|
202 |
216 |
'street2': '',
|
203 |
217 |
'town': 'Paris',
|
204 |
218 |
'zipcode': '75014',
|
205 |
219 |
}
|
206 |
220 |
}
|
207 |
221 |
|
208 |
222 |
|
|
223 |
@mock.patch('passerelle.utils.Request.get')
|
|
224 |
def test_update_referential(mocked_get, con):
|
|
225 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
|
226 |
|
|
227 |
with mock.patch('passerelle.utils.Request.post') as mocked_post:
|
|
228 |
mocked_post.return_value = FakedResponse(
|
|
229 |
content=get_xml_file('R_read_category_list.xml'), status_code=200
|
|
230 |
)
|
|
231 |
con.update_referential('Category')
|
|
232 |
assert [
|
|
233 |
(x.item_id, x.item_text) for x in Referential.objects.filter(referential_name='Category')
|
|
234 |
] == [('BI', 'BIPARENTALE'), ('ACCEUI', "FAMILLE D'ACCUEIL"), ('MONO', 'MONOPARENTALE')]
|
|
235 |
|
|
236 |
with mock.patch('passerelle.utils.Request.post') as mocked_post:
|
|
237 |
mocked_post.return_value = FakedResponse(
|
|
238 |
content=get_xml_file('R_read_category_list_2_items.xml'), status_code=200
|
|
239 |
)
|
|
240 |
con.update_referential('Category')
|
|
241 |
assert [
|
|
242 |
(x.item_id, x.item_text) for x in Referential.objects.filter(referential_name='Category')
|
|
243 |
] == [('BI', 'BIPARENTALE'), ('ACCEUI', 'Famille acceuillante')]
|
|
244 |
|
|
245 |
|
|
246 |
def test_cron(ref):
|
|
247 |
assert Referential.objects.filter(referential_name='Category').count() == 3
|
|
248 |
assert sorted(list({x.referential_name for x in Referential.objects.all()})) == [
|
|
249 |
'CSP',
|
|
250 |
'Category',
|
|
251 |
'ChildIndicator',
|
|
252 |
'Civility',
|
|
253 |
'Complement',
|
|
254 |
'Country',
|
|
255 |
'DietCode',
|
|
256 |
'Organ',
|
|
257 |
'PAI',
|
|
258 |
'Quality',
|
|
259 |
'Quotient',
|
|
260 |
'RLIndicator',
|
|
261 |
'Sex',
|
|
262 |
'Situation',
|
|
263 |
'Street',
|
|
264 |
'Vaccin',
|
|
265 |
]
|
|
266 |
assert Referential.objects.count() == 230
|
|
267 |
|
|
268 |
|
209 |
269 |
@mock.patch('passerelle.utils.Request.get')
|
210 |
270 |
@mock.patch('passerelle.utils.Request.post')
|
211 |
271 |
def test_link(mocked_post, mocked_get, con, app):
|
212 |
272 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
213 |
273 |
mocked_post.return_value = READ_FAMILY
|
214 |
274 |
url = get_endpoint('link')
|
215 |
275 |
assert Link.objects.count() == 0
|
216 |
276 |
|
... | ... | |
256 |
316 |
assert resp.json['err'] == 0
|
257 |
317 |
assert resp.json['data'] == 'ok'
|
258 |
318 |
|
259 |
319 |
resp = app.post_json(url + '?NameID=local')
|
260 |
320 |
assert resp.json['err'] == 'not-linked'
|
261 |
321 |
assert resp.json['err_desc'] == 'User not linked to family'
|
262 |
322 |
|
263 |
323 |
|
264 |
|
@mock.patch('passerelle.utils.Request.get')
|
265 |
|
@mock.patch('passerelle.utils.Request.post')
|
266 |
|
def test_get_referential_using_cache(mocked_post, mocked_get, con, freezer):
|
267 |
|
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
268 |
|
mocked_post.return_value = READ_CATEGORIES
|
269 |
|
|
270 |
|
freezer.move_to('2021-11-10 00:00')
|
271 |
|
con.get_referential('Category')
|
272 |
|
assert mocked_post.call_count == 1
|
273 |
|
|
274 |
|
con.get_referential('Category')
|
275 |
|
assert mocked_post.call_count == 1
|
276 |
|
|
277 |
|
freezer.move_to('2021-11-10 02:00')
|
278 |
|
con.get_referential('Category')
|
279 |
|
assert mocked_post.call_count == 2
|
280 |
|
|
|
324 |
def test_get_referential(con, ref):
|
|
325 |
assert con.get_referential('Category') == [
|
|
326 |
{'code': 'BI', 'id': 'BI', 'libelle': 'BIPARENTALE', 'text': 'BIPARENTALE'},
|
|
327 |
{'code': 'ACCEUI', 'id': 'ACCEUI', 'libelle': "FAMILLE D'ACCUEIL", 'text': "FAMILLE D'ACCUEIL"},
|
|
328 |
{'code': 'MONO', 'id': 'MONO', 'libelle': 'MONOPARENTALE', 'text': 'MONOPARENTALE'},
|
|
329 |
]
|
281 |
330 |
|
282 |
|
@mock.patch('passerelle.utils.Request.get')
|
283 |
|
@mock.patch('passerelle.utils.Request.post')
|
284 |
|
def test_get_referential_value(mocked_post, mocked_get, con):
|
285 |
|
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
286 |
|
mocked_post.return_value = READ_CSP
|
287 |
331 |
|
|
332 |
def test_get_referential_value(con, ref):
|
288 |
333 |
assert con.get_referential_value('CSP', '1') == 'AGRICULTEUR'
|
289 |
334 |
assert con.get_referential_value('CSP', 'AGR') == 'AGRICULTEUR'
|
290 |
335 |
|
291 |
336 |
|
292 |
|
@mock.patch('passerelle.utils.Request.get')
|
293 |
|
@mock.patch('passerelle.utils.Request.post')
|
294 |
|
def test_get_referential_value_not_found(mocked_post, mocked_get, con, caplog):
|
295 |
|
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
296 |
|
mocked_post.return_value = READ_CIVILITIES
|
297 |
|
|
|
337 |
def test_get_referential_value_not_found(con, ref, caplog):
|
298 |
338 |
assert con.get_referential_value('Civility', 'MR') == 'MR'
|
299 |
339 |
assert len(caplog.records) == 1
|
300 |
340 |
assert caplog.records[0].levelno == logging.WARNING
|
301 |
341 |
assert caplog.records[0].message == "No 'MR' key into Maelis 'Civility' referential"
|
302 |
342 |
|
303 |
343 |
|
304 |
|
@mock.patch('passerelle.utils.Request.get')
|
305 |
|
@mock.patch('passerelle.utils.Request.post')
|
306 |
|
def test_read_category_list(mocked_post, mocked_get, con, app):
|
307 |
|
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
308 |
|
mocked_post.return_value = READ_CATEGORIES
|
|
344 |
def test_read_category_list(con, ref, app):
|
309 |
345 |
url = get_endpoint('read-category-list')
|
310 |
346 |
|
311 |
347 |
resp = app.get(url)
|
312 |
348 |
assert resp.json['err'] == 0
|
313 |
349 |
assert resp.json['data'] == [
|
314 |
|
{'id': 'BI', 'text': 'BIPARENTALE'},
|
315 |
|
{'id': 'ACCEUI', 'text': "FAMILLE D'ACCUEIL"},
|
316 |
|
{'id': 'MONO', 'text': 'MONOPARENTALE'},
|
|
350 |
{'id': 'BI', 'text': 'BIPARENTALE', 'code': 'BI', 'libelle': 'BIPARENTALE'},
|
|
351 |
{'id': 'ACCEUI', 'text': "FAMILLE D'ACCUEIL", 'code': 'ACCEUI', 'libelle': "FAMILLE D'ACCUEIL"},
|
|
352 |
{'id': 'MONO', 'text': 'MONOPARENTALE', 'code': 'MONO', 'libelle': 'MONOPARENTALE'},
|
317 |
353 |
]
|
318 |
354 |
|
319 |
355 |
|
320 |
|
@mock.patch('passerelle.utils.Request.get')
|
321 |
|
@mock.patch('passerelle.utils.Request.post')
|
322 |
|
def test_read_country_list(mocked_post, mocked_get, con, app):
|
323 |
|
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
324 |
|
mocked_post.return_value = READ_COUNTRY
|
|
356 |
def test_read_country_list(con, ref, app):
|
325 |
357 |
url = get_endpoint('read-country-list')
|
326 |
358 |
|
327 |
359 |
resp = app.get(url)
|
328 |
360 |
assert resp.json['err'] == 0
|
329 |
361 |
assert len(resp.json['data']) == 3
|
330 |
362 |
assert resp.json['data'] == [
|
331 |
|
{'id': '212', 'text': 'AFGHANISTAN'},
|
332 |
|
{'id': '303', 'text': 'AFRIQUE DU SUD'},
|
333 |
|
{'id': '125', 'text': 'ALBANIE'},
|
|
363 |
{'id': '212', 'code': '212', 'text': 'AFGHANISTAN', 'libelle': 'AFGHANISTAN'},
|
|
364 |
{'id': '303', 'code': '303', 'text': 'AFRIQUE DU SUD', 'libelle': 'AFRIQUE DU SUD'},
|
|
365 |
{'id': '125', 'code': '125', 'text': 'ALBANIE', 'libelle': 'ALBANIE'},
|
334 |
366 |
]
|
335 |
367 |
|
336 |
368 |
|
337 |
|
@mock.patch('passerelle.utils.Request.get')
|
338 |
|
@mock.patch('passerelle.utils.Request.post')
|
339 |
|
def test_read_child_indicator_list(mocked_post, mocked_get, con, app):
|
340 |
|
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
341 |
|
mocked_post.return_value = READ_CHILD_INDICATOR
|
|
369 |
def test_read_child_indicator_list(con, ref, app):
|
342 |
370 |
url = get_endpoint('read-child-indicator-list')
|
343 |
|
|
344 |
371 |
resp = app.get(url)
|
345 |
372 |
assert resp.json['err'] == 0
|
346 |
373 |
assert len(resp.json['data']) == 8
|
347 |
374 |
assert resp.json['data'][0:2] == [
|
348 |
375 |
{
|
349 |
376 |
'id': 'AUTRE',
|
350 |
377 |
'text': 'Autre',
|
351 |
378 |
'choiceList': [],
|
... | ... | |
359 |
386 |
'choiceList': [],
|
360 |
387 |
'code': 'AVL',
|
361 |
388 |
'label': 'Auxiliaire de Vie loisirs',
|
362 |
389 |
'typeDesc': 'NONE',
|
363 |
390 |
},
|
364 |
391 |
]
|
365 |
392 |
|
366 |
393 |
|
367 |
|
@mock.patch('passerelle.utils.Request.get')
|
368 |
|
@mock.patch('passerelle.utils.Request.post')
|
369 |
|
def test_read_civility_list(mocked_post, mocked_get, con, app):
|
370 |
|
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
371 |
|
mocked_post.return_value = READ_CIVILITIES
|
|
394 |
def test_read_civility_list(con, ref, app):
|
372 |
395 |
url = get_endpoint('read-civility-list')
|
373 |
|
|
374 |
396 |
resp = app.get(url)
|
375 |
397 |
assert resp.json['err'] == 0
|
376 |
398 |
assert resp.json['data'] == [
|
377 |
|
{"id": "MME", "text": "Madame"},
|
378 |
|
{"id": "M.", "text": "Monsieur"},
|
|
399 |
{'id': 'MME', 'code': 'MME', 'text': 'Madame', 'libelle': 'Madame'},
|
|
400 |
{'id': 'M.', 'code': 'M.', 'text': 'Monsieur', 'libelle': 'Monsieur'},
|
379 |
401 |
]
|
380 |
402 |
|
381 |
403 |
|
382 |
|
def test_read_complement_list(con, app):
|
|
404 |
def test_read_complement_list(con, ref, app):
|
383 |
405 |
url = get_endpoint('read-complement-list')
|
384 |
|
|
385 |
406 |
resp = app.get(url)
|
386 |
407 |
assert resp.json['err'] == 0
|
387 |
408 |
assert resp.json['data'] == [
|
388 |
409 |
{'id': 'B', 'text': 'bis'},
|
389 |
410 |
{'id': 'Q', 'text': 'quater'},
|
390 |
411 |
{'id': 'T', 'text': 'ter'},
|
391 |
412 |
]
|
392 |
413 |
|
393 |
414 |
|
394 |
|
@mock.patch('passerelle.utils.Request.get')
|
395 |
|
@mock.patch('passerelle.utils.Request.post')
|
396 |
|
def test_read_csp_list(mocked_post, mocked_get, con, app):
|
397 |
|
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
398 |
|
mocked_post.return_value = READ_CSP
|
|
415 |
def test_read_csp_list(con, ref, app):
|
399 |
416 |
url = get_endpoint('read-csp-list')
|
400 |
|
|
401 |
417 |
resp = app.get(url)
|
402 |
418 |
assert resp.json['err'] == 0
|
403 |
|
assert resp.json['data'] == [
|
404 |
|
{'id': '14', 'text': 'AGENT DE MAITRISE'},
|
405 |
|
{'id': '1', 'text': 'AGRICULTEUR'},
|
406 |
|
{'id': 'ART', 'text': 'ARTISAN'},
|
407 |
|
{'id': '2', 'text': 'ARTISAN-COMMERCANT'},
|
408 |
|
{'id': '15', 'text': 'AUTRES'},
|
409 |
|
{'id': '4', 'text': 'CADRE'},
|
410 |
|
{'id': '13', 'text': 'CADRE SUPERIEUR'},
|
411 |
|
{'id': '3', 'text': "CHEF D'ENTREPRISE"},
|
412 |
|
{'id': 'CHOM', 'text': 'CHOMEUR'},
|
413 |
|
{'id': '7', 'text': 'COMMERCANT'},
|
414 |
|
{'id': '10', 'text': "DEMANDEUR D'EMPLOI"},
|
415 |
|
{'id': 'DIV', 'text': 'DIVERS'},
|
416 |
|
{'id': '5', 'text': 'EMPLOYE'},
|
417 |
|
{'id': '17', 'text': 'ENSEIGNANT'},
|
418 |
|
{'id': '8', 'text': 'ETUDIANT'},
|
419 |
|
{'id': '11', 'text': 'FONCTIONNAIRE'},
|
420 |
|
{'id': 'MAIR', 'text': 'MAIRIE DE NICE'},
|
421 |
|
{'id': '6', 'text': 'OUVRIER'},
|
422 |
|
{'id': 'PERENS', 'text': 'PERISCO ENSEIGNANT'},
|
423 |
|
{'id': 'PEREXT', 'text': 'PERISCO EXTERNE'},
|
424 |
|
{'id': 'PERMAI', 'text': 'PERISCO MAIRIE DE NICE'},
|
425 |
|
{'id': 'PERANI', 'text': 'PERISCO S.ANIMATION'},
|
426 |
|
{'id': '9', 'text': 'PROFESSION LIBERALE'},
|
427 |
|
{'id': '12', 'text': 'RETRAITE'},
|
428 |
|
{'id': 'RMI', 'text': "REVENU MINIMUM D'INSERTION"},
|
429 |
|
{'id': '16', 'text': 'SANS PROFESSION'},
|
430 |
|
{'id': 'SEC', 'text': 'SECRETAIRE'},
|
|
419 |
assert resp.json['data'][:5] == [
|
|
420 |
{'code': '14', 'id': '14', 'libelle': 'AGENT DE MAITRISE', 'text': 'AGENT DE MAITRISE'},
|
|
421 |
{'code': '1', 'id': '1', 'libelle': 'AGRICULTEUR', 'text': 'AGRICULTEUR'},
|
|
422 |
{'code': 'ART', 'id': 'ART', 'libelle': 'ARTISAN', 'text': 'ARTISAN'},
|
|
423 |
{'code': '2', 'id': '2', 'libelle': 'ARTISAN-COMMERCANT', 'text': 'ARTISAN-COMMERCANT'},
|
|
424 |
{'code': '15', 'id': '15', 'libelle': 'AUTRES', 'text': 'AUTRES'},
|
431 |
425 |
]
|
432 |
426 |
|
433 |
427 |
|
434 |
|
@mock.patch('passerelle.utils.Request.get')
|
435 |
|
@mock.patch('passerelle.utils.Request.post')
|
436 |
|
def test_read_dietcode_list(mocked_post, mocked_get, con, app):
|
437 |
|
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
438 |
|
mocked_post.return_value = READ_DIETCODE
|
|
428 |
def test_read_dietcode_list(con, ref, app):
|
439 |
429 |
url = get_endpoint('read-dietcode-list')
|
440 |
|
|
441 |
430 |
resp = app.get(url)
|
442 |
431 |
assert resp.json['err'] == 0
|
443 |
432 |
assert resp.json['data'] == [
|
444 |
|
{'id': 'STD', 'text': '1- REPAS STANDARD'},
|
445 |
|
{'id': 'RSP', 'text': '2- RÉGIME SANS PORC'},
|
446 |
|
{'id': 'RSV', 'text': '3- RÉGIME SANS VIANDE'},
|
447 |
|
{'id': 'PAI', 'text': "4- PROTOCOLE D'ACCUEIL INDIVIDUALISÉ"},
|
448 |
|
{'id': 'BB', 'text': 'REPAS BEBE'},
|
449 |
|
{'id': 'MSP', 'text': 'REPAS MOYEN SANS PORC'},
|
450 |
|
{'id': 'MSV', 'text': 'REPAS MOYEN SANS VIANDE'},
|
451 |
|
{'id': 'MST', 'text': 'REPAS MOYEN STANDARD'},
|
|
433 |
{'id': 'STD', 'code': 'STD', 'text': '1- REPAS STANDARD', 'libelle': '1- REPAS STANDARD'},
|
|
434 |
{'id': 'RSP', 'code': 'RSP', 'text': '2- RÉGIME SANS PORC', 'libelle': '2- RÉGIME SANS PORC'},
|
|
435 |
{'id': 'RSV', 'code': 'RSV', 'text': '3- RÉGIME SANS VIANDE', 'libelle': '3- RÉGIME SANS VIANDE'},
|
|
436 |
{
|
|
437 |
'id': 'PAI',
|
|
438 |
'code': 'PAI',
|
|
439 |
'text': "4- PROTOCOLE D'ACCUEIL INDIVIDUALISÉ",
|
|
440 |
'libelle': "4- PROTOCOLE D'ACCUEIL INDIVIDUALISÉ",
|
|
441 |
},
|
|
442 |
{'id': 'BB', 'code': 'BB', 'text': 'REPAS BEBE', 'libelle': 'REPAS BEBE'},
|
|
443 |
{'id': 'MSP', 'code': 'MSP', 'text': 'REPAS MOYEN SANS PORC', 'libelle': 'REPAS MOYEN SANS PORC'},
|
|
444 |
{'id': 'MSV', 'code': 'MSV', 'text': 'REPAS MOYEN SANS VIANDE', 'libelle': 'REPAS MOYEN SANS VIANDE'},
|
|
445 |
{'id': 'MST', 'code': 'MST', 'text': 'REPAS MOYEN STANDARD', 'libelle': 'REPAS MOYEN STANDARD'},
|
452 |
446 |
]
|
453 |
447 |
|
454 |
448 |
|
455 |
|
@mock.patch('passerelle.utils.Request.get')
|
456 |
|
@mock.patch('passerelle.utils.Request.post')
|
457 |
|
def test_read_organ_list(mocked_post, mocked_get, con, app):
|
458 |
|
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
459 |
|
mocked_post.return_value = READ_ORGAN
|
|
449 |
def test_read_organ_list(con, ref, app):
|
460 |
450 |
url = get_endpoint('read-organ-list')
|
461 |
|
|
462 |
451 |
resp = app.get(url)
|
463 |
452 |
assert resp.json['err'] == 0
|
464 |
453 |
assert len(resp.json['data']) == 92
|
465 |
454 |
assert resp.json['data'][:5] == [
|
466 |
|
{'id': 'A10000979374', 'text': 'ALC L OLIVIER'},
|
467 |
|
{'id': 'A10000979372', 'text': 'ALVA 06'},
|
468 |
|
{'id': 'A10000980566', 'text': 'ANTIBES'},
|
469 |
|
{'id': 'A10000980388', 'text': 'APAJH'},
|
470 |
|
{'id': 'A10016401771', 'text': 'ASCROS'},
|
|
455 |
{'id': 'A10000979374', 'code': 'ALC L OLIVIER', 'text': 'ALC L OLIVIER', 'libelle': None},
|
|
456 |
{'id': 'A10000979372', 'code': 'ALVA 06', 'text': 'ALVA 06', 'libelle': None},
|
|
457 |
{'id': 'A10000980566', 'code': 'ANTIBES', 'text': 'ANTIBES', 'libelle': None},
|
|
458 |
{'id': 'A10000980388', 'code': 'APAJH', 'text': 'APAJH', 'libelle': None},
|
|
459 |
{'id': 'A10016401771', 'code': 'ASCROS', 'text': 'ASCROS', 'libelle': None},
|
471 |
460 |
]
|
472 |
461 |
|
473 |
462 |
|
474 |
|
@mock.patch('passerelle.utils.Request.get')
|
475 |
|
@mock.patch('passerelle.utils.Request.post')
|
476 |
|
def test_read_pai_list(mocked_post, mocked_get, con, app):
|
477 |
|
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
478 |
|
mocked_post.return_value = READ_PAI
|
|
463 |
def test_read_pai_list(con, ref, app):
|
479 |
464 |
url = get_endpoint('read-pai-list')
|
480 |
|
|
481 |
465 |
resp = app.get(url)
|
482 |
466 |
assert resp.json['err'] == 0
|
483 |
467 |
assert resp.json['data'] == [
|
484 |
|
{'id': 'PAIALI', 'text': 'ALIMENTAIRE'},
|
485 |
|
{'id': 'PAIO', 'text': 'AUTRE'},
|
486 |
|
{'id': 'PAIMED', 'text': 'MEDICAL'},
|
487 |
|
{'id': 'PAI2', 'text': 'MEDICAL ET ALIMENTAIRE'},
|
|
468 |
{'id': 'PAIALI', 'code': 'PAIALI', 'text': 'ALIMENTAIRE', 'libelle': 'ALIMENTAIRE'},
|
|
469 |
{'id': 'PAIO', 'code': 'PAIO', 'text': 'AUTRE', 'libelle': 'AUTRE'},
|
|
470 |
{'id': 'PAIMED', 'code': 'PAIMED', 'text': 'MEDICAL', 'libelle': 'MEDICAL'},
|
|
471 |
{'id': 'PAI2', 'code': 'PAI2', 'text': 'MEDICAL ET ALIMENTAIRE', 'libelle': 'MEDICAL ET ALIMENTAIRE'},
|
488 |
472 |
]
|
489 |
473 |
|
490 |
474 |
|
491 |
|
@mock.patch('passerelle.utils.Request.get')
|
492 |
|
@mock.patch('passerelle.utils.Request.post')
|
493 |
|
def test_read_quality_list(mocked_post, mocked_get, con, app):
|
494 |
|
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
495 |
|
mocked_post.return_value = READ_QUALITIES
|
|
475 |
def test_read_quality_list(con, ref, app):
|
496 |
476 |
url = get_endpoint('read-quality-list')
|
497 |
|
|
498 |
477 |
resp = app.get(url)
|
499 |
478 |
assert resp.json['err'] == 0
|
500 |
|
assert resp.json['data'] == [
|
501 |
|
{'id': 'AU', 'text': 'AUTRE'},
|
502 |
|
{'id': 'BP', 'text': 'BEAU PERE'},
|
503 |
|
{'id': 'BM', 'text': 'BELLE MERE'},
|
504 |
|
{'id': 'CONSO', 'text': 'CONSOMMATEUR'},
|
505 |
|
{'id': 'EN', 'text': 'ENFANT'},
|
506 |
|
{'id': 'FS', 'text': 'FRERES ET SOEURS'},
|
507 |
|
{'id': 'GM', 'text': 'GRAND MERE MATERNELLE'},
|
508 |
|
{'id': 'GP', 'text': 'GRAND PERE MATERNEL'},
|
509 |
|
{'id': 'GMP', 'text': 'GRAND-MERE PATERNELLE'},
|
510 |
|
{'id': 'GPP', 'text': 'GRAND-PERE PATERNEL'},
|
511 |
|
{'id': 'MAIRIE', 'text': 'MAIRIE'},
|
512 |
|
{'id': 'MERE', 'text': 'MERE'},
|
513 |
|
{'id': 'O', 'text': 'ONCLE'},
|
514 |
|
{'id': 'OS', 'text': 'ORGANISME SOCIAL'},
|
515 |
|
{'id': 'PERE', 'text': 'PERE'},
|
516 |
|
{'id': 'T', 'text': 'TANTE'},
|
517 |
|
{'id': 'TUTEUR', 'text': 'TUTEUR'},
|
|
479 |
assert resp.json['data'][:5] == [
|
|
480 |
{'id': 'AU', 'code': 'AU', 'text': 'AUTRE', 'libelle': 'AUTRE'},
|
|
481 |
{'id': 'BP', 'code': 'BP', 'text': 'BEAU PERE', 'libelle': 'BEAU PERE'},
|
|
482 |
{'id': 'BM', 'code': 'BM', 'text': 'BELLE MERE', 'libelle': 'BELLE MERE'},
|
|
483 |
{'id': 'CONSO', 'code': 'CONSO', 'text': 'CONSOMMATEUR', 'libelle': 'CONSOMMATEUR'},
|
|
484 |
{'id': 'EN', 'code': 'EN', 'text': 'ENFANT', 'libelle': 'ENFANT'},
|
518 |
485 |
]
|
519 |
486 |
|
520 |
487 |
|
521 |
|
@mock.patch('passerelle.utils.Request.get')
|
522 |
|
@mock.patch('passerelle.utils.Request.post')
|
523 |
|
def test_read_quotient_list(mocked_post, mocked_get, con, app):
|
524 |
|
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
525 |
|
mocked_post.return_value = READ_QUOTIENT
|
|
488 |
def test_read_quotient_list(con, ref, app):
|
526 |
489 |
url = get_endpoint('read-quotient-list')
|
527 |
|
|
528 |
490 |
resp = app.get(url)
|
529 |
491 |
assert resp.json['err'] == 0
|
530 |
492 |
assert resp.json['data'] == [
|
531 |
|
{'id': 'QF', 'text': 'GRILLE DE QUOTIENT'},
|
532 |
|
{'id': 'QCLSH', 'text': 'QUOTIENT CENTRE AERE'},
|
533 |
|
{'id': 'QJEU', 'text': 'QUOTIENT JEUNESSE'},
|
534 |
|
{'id': 'QS', 'text': 'QUOTIENT SCOLAIRE'},
|
535 |
|
{'id': 'QSPORT', 'text': 'QUOTIENT SPORT'},
|
536 |
|
{'id': 'MOY ECO', 'text': 'REVENU MOYEN ( MENSUEL OU ANNUEL)'},
|
|
493 |
{'id': 'QF', 'code': 'QF', 'text': 'GRILLE DE QUOTIENT', 'libelle': 'GRILLE DE QUOTIENT'},
|
|
494 |
{'id': 'QCLSH', 'code': 'QCLSH', 'text': 'QUOTIENT CENTRE AERE', 'libelle': 'QUOTIENT CENTRE AERE'},
|
|
495 |
{'id': 'QJEU', 'code': 'QJEU', 'text': 'QUOTIENT JEUNESSE', 'libelle': 'QUOTIENT JEUNESSE'},
|
|
496 |
{'id': 'QS', 'code': 'QS', 'text': 'QUOTIENT SCOLAIRE', 'libelle': 'QUOTIENT SCOLAIRE'},
|
|
497 |
{'id': 'QSPORT', 'code': 'QSPORT', 'text': 'QUOTIENT SPORT', 'libelle': 'QUOTIENT SPORT'},
|
|
498 |
{
|
|
499 |
'id': 'MOY ECO',
|
|
500 |
'code': 'MOY ECO',
|
|
501 |
'text': 'REVENU MOYEN ( MENSUEL OU ANNUEL)',
|
|
502 |
'libelle': 'REVENU MOYEN ( MENSUEL OU ANNUEL)',
|
|
503 |
},
|
537 |
504 |
]
|
538 |
505 |
|
539 |
506 |
|
540 |
|
@mock.patch('passerelle.utils.Request.get')
|
541 |
|
@mock.patch('passerelle.utils.Request.post')
|
542 |
|
def test_read_rl_indicator_list(mocked_post, mocked_get, con, app):
|
543 |
|
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
544 |
|
mocked_post.return_value = READ_RL_INDICATOR
|
|
507 |
def test_read_rl_indicator_list(con, ref, app):
|
545 |
508 |
url = get_endpoint('read-rl-indicator-list')
|
546 |
|
|
547 |
509 |
resp = app.get(url)
|
548 |
510 |
assert resp.json['err'] == 0
|
549 |
511 |
assert len(resp.json['data']) == 4
|
550 |
512 |
assert resp.json['data'][1:3] == [
|
551 |
513 |
{
|
552 |
514 |
'id': 'AVS',
|
553 |
515 |
'text': 'Auxiliaire de Vie scolaire',
|
554 |
516 |
'choiceList': [],
|
... | ... | |
562 |
524 |
'choiceList': [],
|
563 |
525 |
'code': 'ETABSPEC',
|
564 |
526 |
'label': 'Etablissement spécialisé',
|
565 |
527 |
'typeDesc': 'NOTE',
|
566 |
528 |
},
|
567 |
529 |
]
|
568 |
530 |
|
569 |
531 |
|
570 |
|
def test_read_sex_list(con, app):
|
|
532 |
def test_read_sex_list(con, app, ref):
|
571 |
533 |
url = get_endpoint('read-sex-list')
|
572 |
534 |
|
573 |
535 |
resp = app.get(url)
|
574 |
536 |
assert resp.json['err'] == 0
|
575 |
537 |
assert resp.json['data'] == [
|
576 |
538 |
{'id': 'F', 'text': 'Féminin'},
|
577 |
539 |
{'id': 'M', 'text': 'Masculin'},
|
578 |
540 |
]
|
579 |
541 |
|
580 |
542 |
|
581 |
|
@mock.patch('passerelle.utils.Request.get')
|
582 |
|
@mock.patch('passerelle.utils.Request.post')
|
583 |
|
def test_read_situation_list(mocked_post, mocked_get, con, app):
|
584 |
|
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
585 |
|
mocked_post.return_value = READ_SITUATIONS
|
|
543 |
def test_read_situation_list(con, ref, app):
|
586 |
544 |
url = get_endpoint('read-situation-list')
|
587 |
|
|
588 |
545 |
resp = app.get(url)
|
589 |
546 |
assert resp.json['err'] == 0
|
590 |
|
assert resp.json['data'] == [
|
591 |
|
{'id': 'C', 'text': 'Célibataire'},
|
592 |
|
{'id': 'D', 'text': 'Divorcé (e)'},
|
593 |
|
{'id': 'CS', 'text': 'EN COURS DE SEPARATION'},
|
594 |
|
{'id': 'M', 'text': 'Marié (e)'},
|
595 |
|
{'id': 'P', 'text': 'Pacsé (e)'},
|
596 |
|
{'id': 'S', 'text': 'Séparé (e)'},
|
597 |
|
{'id': 'UL', 'text': 'UNION LIBRE'},
|
598 |
|
{'id': 'V', 'text': 'Veuf (ve)'},
|
599 |
|
{'id': 'VM', 'text': 'Vivant maritalement'},
|
|
547 |
assert resp.json['data'][:5] == [
|
|
548 |
{'id': 'C', 'code': 'C', 'text': 'Célibataire', 'libelle': 'Célibataire'},
|
|
549 |
{'id': 'D', 'code': 'D', 'text': 'Divorcé (e)', 'libelle': 'Divorcé (e)'},
|
|
550 |
{'id': 'CS', 'code': 'CS', 'text': 'EN COURS DE SEPARATION', 'libelle': 'EN COURS DE SEPARATION'},
|
|
551 |
{'id': 'M', 'code': 'M', 'text': 'Marié (e)', 'libelle': 'Marié (e)'},
|
|
552 |
{'id': 'P', 'code': 'P', 'text': 'Pacsé (e)', 'libelle': 'Pacsé (e)'},
|
600 |
553 |
]
|
601 |
554 |
|
602 |
555 |
|
603 |
|
@mock.patch('passerelle.utils.Request.get')
|
604 |
|
@mock.patch('passerelle.utils.Request.post')
|
605 |
|
def test_read_street_list(mocked_post, mocked_get, con, app):
|
606 |
|
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
607 |
|
mocked_post.return_value = READ_STREET
|
|
556 |
def test_read_street_list(con, ref, app):
|
608 |
557 |
url = get_endpoint('read-street-list')
|
609 |
|
|
610 |
558 |
resp = app.get(url)
|
611 |
559 |
assert resp.json['err'] == 0
|
612 |
560 |
assert len(resp.json['data']) == 3
|
613 |
561 |
assert resp.json['data'] == [
|
614 |
|
{'id': 'AP0594', 'text': 'AVENUE PAULIANI'},
|
615 |
|
{'id': 'AS0264', 'text': 'RUE SAINT FRANCOIS DE PAULE'},
|
616 |
|
{'id': 'AM0330', 'text': 'TRAVERSE DES MARAICHERS'},
|
|
562 |
{'id': 'AP0594', 'text': 'AVENUE PAULIANI', 'idStreet': 'AP0594', 'libelleStreet': 'AVENUE PAULIANI'},
|
|
563 |
{
|
|
564 |
'id': 'AS0264',
|
|
565 |
'text': 'RUE SAINT FRANCOIS DE PAULE',
|
|
566 |
'idStreet': 'AS0264',
|
|
567 |
'libelleStreet': 'RUE SAINT FRANCOIS DE PAULE',
|
|
568 |
},
|
|
569 |
{
|
|
570 |
'id': 'AM0330',
|
|
571 |
'text': 'TRAVERSE DES MARAICHERS',
|
|
572 |
'idStreet': 'AM0330',
|
|
573 |
'libelleStreet': 'TRAVERSE DES MARAICHERS',
|
|
574 |
},
|
617 |
575 |
]
|
618 |
576 |
|
619 |
577 |
|
620 |
|
@mock.patch('passerelle.utils.Request.get')
|
621 |
|
@mock.patch('passerelle.utils.Request.post')
|
622 |
|
def test_read_vaccin_list(mocked_post, mocked_get, con, app):
|
623 |
|
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
624 |
|
mocked_post.return_value = READ_VACCIN
|
|
578 |
def test_read_vaccin_list(con, ref, app):
|
625 |
579 |
url = get_endpoint('read-vaccin-list')
|
626 |
|
|
627 |
580 |
resp = app.get(url)
|
628 |
581 |
assert resp.json['err'] == 0
|
629 |
582 |
assert len(resp.json['data']) == 20
|
630 |
583 |
assert resp.json['data'][:5] == [
|
631 |
|
{'id': 'BCG', 'text': 'BCG'},
|
632 |
|
{'id': 'CIB', 'text': 'CONTRE-INDICATION TEMPORAIRE AU BCG'},
|
633 |
|
{'id': 'MONO', 'text': 'CONTROLE DU BCG (+)'},
|
634 |
|
{'id': 'MONON', 'text': 'CONTROLE DU BCG (-)'},
|
635 |
|
{'id': 'DTC', 'text': 'DIPHTERIE TETANOS COQUELUCHE'},
|
|
584 |
{'id': 'BCG', 'code': 'BCG', 'text': 'BCG', 'libelle': 'BCG'},
|
|
585 |
{
|
|
586 |
'id': 'CIB',
|
|
587 |
'code': 'CIB',
|
|
588 |
'text': 'CONTRE-INDICATION TEMPORAIRE AU BCG',
|
|
589 |
'libelle': 'CONTRE-INDICATION TEMPORAIRE AU BCG',
|
|
590 |
},
|
|
591 |
{'id': 'MONO', 'code': 'MONO', 'text': 'CONTROLE DU BCG (+)', 'libelle': 'CONTROLE DU BCG (+)'},
|
|
592 |
{'id': 'MONON', 'code': 'MONON', 'text': 'CONTROLE DU BCG (-)', 'libelle': 'CONTROLE DU BCG (-)'},
|
|
593 |
{
|
|
594 |
'id': 'DTC',
|
|
595 |
'code': 'DTC',
|
|
596 |
'text': 'DIPHTERIE TETANOS COQUELUCHE',
|
|
597 |
'libelle': 'DIPHTERIE TETANOS COQUELUCHE',
|
|
598 |
},
|
636 |
599 |
]
|
637 |
600 |
|
638 |
601 |
|
639 |
602 |
@pytest.mark.parametrize("read_family", [READ_FAMILY, READ_FAMILY_LAX, READ_FAMILY_ORD])
|
640 |
603 |
@mock.patch('passerelle.utils.Request.get')
|
641 |
604 |
@mock.patch('passerelle.utils.Request.post')
|
642 |
|
def test_read_family(mocked_post, mocked_get, read_family, con, app):
|
|
605 |
def test_read_family(mocked_post, mocked_get, read_family, con, ref, app):
|
643 |
606 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
644 |
|
mocked_post.side_effect = [
|
645 |
|
read_family,
|
646 |
|
READ_CATEGORIES,
|
647 |
|
READ_SITUATIONS,
|
648 |
|
READ_CIVILITIES,
|
649 |
|
READ_QUALITIES,
|
650 |
|
READ_CSP,
|
651 |
|
READ_ORGAN,
|
652 |
|
READ_DIETCODE,
|
653 |
|
READ_PAI,
|
654 |
|
]
|
|
607 |
mocked_post.return_value = read_family
|
655 |
608 |
url = get_endpoint('read-family')
|
656 |
609 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
657 |
610 |
|
658 |
611 |
resp = app.get(url + '?NameID=local')
|
659 |
612 |
assert resp.json['err'] == 0
|
660 |
613 |
data = resp.json['data']
|
661 |
614 |
del data['RL1']
|
662 |
615 |
del data['RL2']
|
... | ... | |
827 |
780 |
|
828 |
781 |
resp = app.get(url + '?NameID=')
|
829 |
782 |
assert resp.json['err'] == 'not-linked'
|
830 |
783 |
assert resp.json['err_desc'] == 'User not linked to family'
|
831 |
784 |
|
832 |
785 |
|
833 |
786 |
@mock.patch('passerelle.utils.Request.get')
|
834 |
787 |
@mock.patch('passerelle.utils.Request.post')
|
835 |
|
def test_read_rl1(mocked_post, mocked_get, con, app):
|
|
788 |
def test_read_rl1(mocked_post, mocked_get, con, ref, app):
|
836 |
789 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
837 |
|
mocked_post.side_effect = [
|
838 |
|
READ_FAMILY,
|
839 |
|
READ_CIVILITIES,
|
840 |
|
READ_QUALITIES,
|
841 |
|
READ_CSP,
|
842 |
|
]
|
|
790 |
mocked_post.return_value = READ_FAMILY
|
843 |
791 |
url = get_endpoint('read-rl')
|
844 |
792 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
845 |
793 |
|
846 |
794 |
resp = app.get(url + '?NameID=local&rl_id=613878')
|
847 |
795 |
assert resp.json['err'] == 0
|
848 |
796 |
assert resp.json['data']['firstname'] == 'JHON'
|
849 |
797 |
|
850 |
798 |
|
851 |
799 |
@mock.patch('passerelle.utils.Request.get')
|
852 |
800 |
@mock.patch('passerelle.utils.Request.post')
|
853 |
|
def test_read_rl2(mocked_post, mocked_get, con, app):
|
|
801 |
def test_read_rl2(mocked_post, mocked_get, con, ref, app):
|
854 |
802 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
855 |
|
mocked_post.side_effect = [
|
856 |
|
READ_FAMILY,
|
857 |
|
READ_CIVILITIES,
|
858 |
|
READ_QUALITIES,
|
859 |
|
READ_CSP,
|
860 |
|
READ_ORGAN,
|
861 |
|
]
|
|
803 |
mocked_post.return_value = READ_FAMILY
|
862 |
804 |
url = get_endpoint('read-rl')
|
863 |
805 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
864 |
806 |
|
865 |
807 |
resp = app.get(url + '?NameID=local&rl_id=613879')
|
866 |
808 |
assert resp.json['err'] == 0
|
867 |
809 |
assert resp.json['data'] == {
|
868 |
810 |
'num': '613879',
|
869 |
811 |
'lastname': 'DOE',
|
... | ... | |
920 |
862 |
|
921 |
863 |
resp = app.get(url + '?NameID=local&rl_id=613879')
|
922 |
864 |
assert resp.json['err'] == 'not-linked'
|
923 |
865 |
assert resp.json['err_desc'] == 'User not linked to family'
|
924 |
866 |
|
925 |
867 |
|
926 |
868 |
@mock.patch('passerelle.utils.Request.get')
|
927 |
869 |
@mock.patch('passerelle.utils.Request.post')
|
928 |
|
def test_read_rl_not_found(mocked_post, mocked_get, con, app):
|
|
870 |
def test_read_rl_not_found(mocked_post, mocked_get, con, ref, app):
|
929 |
871 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
930 |
|
mocked_post.side_effect = [READ_FAMILY]
|
|
872 |
mocked_post.return_value = READ_FAMILY
|
931 |
873 |
url = get_endpoint('read-rl')
|
932 |
874 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
933 |
875 |
|
934 |
876 |
resp = app.get(url + '?NameID=local&rl_id=000000')
|
935 |
877 |
assert resp.json['err'] == 'not-found'
|
936 |
878 |
assert resp.json['err_desc'] == "no '000000' RL on '1312' family"
|
937 |
879 |
|
938 |
880 |
|
939 |
881 |
@mock.patch('passerelle.utils.Request.get')
|
940 |
882 |
@mock.patch('passerelle.utils.Request.post')
|
941 |
|
def test_read_person(mocked_post, mocked_get, con, app):
|
|
883 |
def test_read_person(mocked_post, mocked_get, con, ref, app):
|
942 |
884 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
943 |
|
mocked_post.side_effect = [
|
944 |
|
READ_FAMILY,
|
945 |
|
READ_CIVILITIES,
|
946 |
|
READ_QUALITIES,
|
947 |
|
]
|
|
885 |
mocked_post.return_value = READ_FAMILY
|
948 |
886 |
url = get_endpoint('read-person')
|
949 |
887 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
950 |
888 |
|
951 |
889 |
resp = app.get(url + '?NameID=local&person_id=614059')
|
952 |
890 |
assert resp.json['err'] == 0
|
953 |
891 |
assert resp.json['data']['firstname'] == 'KENY'
|
954 |
892 |
|
955 |
893 |
|
... | ... | |
958 |
896 |
|
959 |
897 |
resp = app.get(url + '?NameID=local&person_id=614059')
|
960 |
898 |
assert resp.json['err'] == 'not-linked'
|
961 |
899 |
assert resp.json['err_desc'] == 'User not linked to family'
|
962 |
900 |
|
963 |
901 |
|
964 |
902 |
@mock.patch('passerelle.utils.Request.get')
|
965 |
903 |
@mock.patch('passerelle.utils.Request.post')
|
966 |
|
def test_read_person_not_found(mocked_post, mocked_get, con, app):
|
|
904 |
def test_read_person_not_found(mocked_post, mocked_get, con, ref, app):
|
967 |
905 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
968 |
|
mocked_post.side_effect = [READ_FAMILY]
|
|
906 |
mocked_post.return_value = READ_FAMILY
|
969 |
907 |
url = get_endpoint('read-person')
|
970 |
908 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
971 |
909 |
|
972 |
910 |
resp = app.get(url + '?NameID=local&person_id=000000')
|
973 |
911 |
assert resp.json['err'] == 'not-found'
|
974 |
912 |
assert resp.json['err_desc'] == "no '000000' emergency person on '1312' family"
|
975 |
913 |
|
976 |
914 |
|
977 |
915 |
@mock.patch('passerelle.utils.Request.get')
|
978 |
916 |
@mock.patch('passerelle.utils.Request.post')
|
979 |
|
def test_read_child(mocked_post, mocked_get, con, app):
|
|
917 |
def test_read_child(mocked_post, mocked_get, con, ref, app):
|
980 |
918 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
981 |
|
mocked_post.side_effect = [
|
982 |
|
READ_FAMILY,
|
983 |
|
READ_DIETCODE,
|
984 |
|
READ_PAI,
|
985 |
|
READ_CIVILITIES,
|
986 |
|
READ_QUALITIES,
|
987 |
|
]
|
|
919 |
mocked_post.return_value = READ_FAMILY
|
988 |
920 |
url = get_endpoint('read-child')
|
989 |
921 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
990 |
922 |
|
991 |
923 |
resp = app.get(url + '?NameID=local&child_id=613880')
|
992 |
924 |
assert resp.json['err'] == 0
|
993 |
925 |
assert resp.json['data']['firstname'] == 'JANNIS'
|
994 |
926 |
|
995 |
927 |
|
... | ... | |
998 |
930 |
|
999 |
931 |
resp = app.get(url + '?NameID=local&child_id=613880')
|
1000 |
932 |
assert resp.json['err'] == 'not-linked'
|
1001 |
933 |
assert resp.json['err_desc'] == 'User not linked to family'
|
1002 |
934 |
|
1003 |
935 |
|
1004 |
936 |
@mock.patch('passerelle.utils.Request.get')
|
1005 |
937 |
@mock.patch('passerelle.utils.Request.post')
|
1006 |
|
def test_read_child_not_found(mocked_post, mocked_get, con, app):
|
|
938 |
def test_read_child_not_found(mocked_post, mocked_get, con, ref, app):
|
1007 |
939 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1008 |
|
mocked_post.side_effect = [
|
1009 |
|
READ_FAMILY,
|
1010 |
|
READ_DIETCODE,
|
1011 |
|
READ_PAI,
|
1012 |
|
]
|
|
940 |
mocked_post.return_value = READ_FAMILY
|
1013 |
941 |
url = get_endpoint('read-child')
|
1014 |
942 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
1015 |
943 |
|
1016 |
944 |
resp = app.get(url + '?NameID=local&child_id=000000')
|
1017 |
945 |
assert resp.json['err'] == 'not-found'
|
1018 |
946 |
assert resp.json['err_desc'] == "no '000000' child on '1312' family"
|
1019 |
947 |
|
1020 |
948 |
|
1021 |
949 |
@mock.patch('passerelle.utils.Request.get')
|
1022 |
950 |
@mock.patch('passerelle.utils.Request.post')
|
1023 |
|
def test_read_child_person(mocked_post, mocked_get, con, app):
|
|
951 |
def test_read_child_person(mocked_post, mocked_get, con, ref, app):
|
1024 |
952 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1025 |
|
mocked_post.side_effect = [
|
1026 |
|
READ_FAMILY,
|
1027 |
|
READ_CIVILITIES,
|
1028 |
|
READ_QUALITIES,
|
1029 |
|
]
|
|
953 |
mocked_post.return_value = READ_FAMILY
|
1030 |
954 |
url = get_endpoint('read-child-person')
|
1031 |
955 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
1032 |
956 |
|
1033 |
957 |
resp = app.get(url + '?NameID=local&child_id=613880&person_id=614719')
|
1034 |
958 |
assert resp.json['err'] == 0
|
1035 |
959 |
assert resp.json['data']['personInfo']['firstname'] == 'AMEL'
|
1036 |
960 |
|
1037 |
961 |
|
... | ... | |
1040 |
964 |
|
1041 |
965 |
resp = app.get(url + '?NameID=local&child_id=613880&person_id=614719')
|
1042 |
966 |
assert resp.json['err'] == 'not-linked'
|
1043 |
967 |
assert resp.json['err_desc'] == 'User not linked to family'
|
1044 |
968 |
|
1045 |
969 |
|
1046 |
970 |
@mock.patch('passerelle.utils.Request.get')
|
1047 |
971 |
@mock.patch('passerelle.utils.Request.post')
|
1048 |
|
def test_read_child_person_no_child_error(mocked_post, mocked_get, con, app):
|
|
972 |
def test_read_child_person_no_child_error(mocked_post, mocked_get, con, ref, app):
|
1049 |
973 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1050 |
|
mocked_post.side_effect = [
|
1051 |
|
READ_FAMILY,
|
1052 |
|
]
|
|
974 |
mocked_post.return_value = READ_FAMILY
|
1053 |
975 |
url = get_endpoint('read-child-person')
|
1054 |
976 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
1055 |
977 |
|
1056 |
978 |
resp = app.get(url + '?NameID=local&child_id=42&person_id=614719')
|
1057 |
979 |
assert resp.json['err'] == 'not-found'
|
1058 |
980 |
assert resp.json['err_desc'] == "no '42' child on '1312' family"
|
1059 |
981 |
|
1060 |
982 |
|
1061 |
983 |
@mock.patch('passerelle.utils.Request.get')
|
1062 |
984 |
@mock.patch('passerelle.utils.Request.post')
|
1063 |
|
def test_read_child_person_no_person_error(mocked_post, mocked_get, con, app):
|
|
985 |
def test_read_child_person_no_person_error(mocked_post, mocked_get, con, ref, app):
|
1064 |
986 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1065 |
|
mocked_post.side_effect = [
|
1066 |
|
READ_FAMILY,
|
1067 |
|
READ_CIVILITIES,
|
1068 |
|
READ_QUALITIES,
|
1069 |
|
]
|
|
987 |
mocked_post.return_value = READ_FAMILY
|
1070 |
988 |
url = get_endpoint('read-child-person')
|
1071 |
989 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
1072 |
990 |
|
1073 |
991 |
resp = app.get(url + '?NameID=local&child_id=613880&person_id=000000')
|
1074 |
992 |
assert resp.json['err'] == 'not-found'
|
1075 |
993 |
assert resp.json['err_desc'] == "no '000000' authorized person on '613880' child"
|
1076 |
994 |
|
1077 |
995 |
|
... | ... | |
1133 |
1051 |
}
|
1134 |
1052 |
resp = app.post_json(url, params=params)
|
1135 |
1053 |
assert resp.json['err'] == 0
|
1136 |
1054 |
assert resp.json['data'] == result
|
1137 |
1055 |
|
1138 |
1056 |
|
1139 |
1057 |
@mock.patch('passerelle.utils.Request.get')
|
1140 |
1058 |
@mock.patch('passerelle.utils.Request.post')
|
1141 |
|
def test_create_family(mocked_post, mocked_get, con, app):
|
|
1059 |
def test_create_family(mocked_post, mocked_get, con, ref, app):
|
1142 |
1060 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1143 |
|
mocked_post.side_effect = [
|
1144 |
|
READ_CATEGORIES,
|
1145 |
|
READ_SITUATIONS,
|
1146 |
|
READ_CIVILITIES,
|
1147 |
|
READ_QUALITIES,
|
1148 |
|
READ_CSP,
|
1149 |
|
READ_ORGAN,
|
1150 |
|
READ_DIETCODE,
|
1151 |
|
READ_VACCIN,
|
1152 |
|
CREATE_FAMILY,
|
1153 |
|
]
|
|
1061 |
mocked_post.return_value = CREATE_FAMILY
|
1154 |
1062 |
url = get_endpoint('create-family')
|
1155 |
1063 |
params = {
|
1156 |
1064 |
'category': 'ACCEUI',
|
1157 |
1065 |
'situation': 'C',
|
1158 |
1066 |
'rl1/civility': 'M.',
|
1159 |
1067 |
'rl1/firstname': 'Jhon',
|
1160 |
1068 |
'rl1/lastname': 'Doe',
|
1161 |
1069 |
'rl1/quality': 'AU',
|
... | ... | |
1231 |
1139 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
1232 |
1140 |
resp = app.post_json(url + '?NameID=local', params=params)
|
1233 |
1141 |
assert resp.json['err'] == 'already-linked'
|
1234 |
1142 |
assert resp.json['err_desc'] == 'User already linked to family'
|
1235 |
1143 |
|
1236 |
1144 |
|
1237 |
1145 |
@mock.patch('passerelle.utils.Request.get')
|
1238 |
1146 |
@mock.patch('passerelle.utils.Request.post')
|
1239 |
|
def test_create_family_maelis_error(mocked_post, mocked_get, con, app):
|
|
1147 |
def test_create_family_maelis_error(mocked_post, mocked_get, con, ref, app):
|
1240 |
1148 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1241 |
|
mocked_post.side_effect = [
|
1242 |
|
READ_CATEGORIES,
|
1243 |
|
READ_SITUATIONS,
|
1244 |
|
READ_CIVILITIES,
|
1245 |
|
READ_QUALITIES,
|
1246 |
|
CREATE_FAMILY_ERR,
|
1247 |
|
]
|
|
1149 |
mocked_post.return_value = CREATE_FAMILY_ERR
|
1248 |
1150 |
url = get_endpoint('create-family')
|
1249 |
1151 |
params = {
|
1250 |
1152 |
'category': 'ACCEUI',
|
1251 |
1153 |
'situation': 'C',
|
1252 |
1154 |
'rl1/civility': 'M.',
|
1253 |
1155 |
'rl1/firstname': 'Jhon',
|
1254 |
1156 |
'rl1/lastname': 'Doe',
|
1255 |
1157 |
'rl1/quality': 'AU',
|
... | ... | |
1259 |
1161 |
'rl1/adresse/zipcode': '75014',
|
1260 |
1162 |
}
|
1261 |
1163 |
|
1262 |
1164 |
resp = app.post_json(url + '?NameID=local', params=params)
|
1263 |
1165 |
assert resp.json['err'] == 'E54a, E54a'
|
1264 |
1166 |
assert 'Il existe déjà' in resp.json['err_desc']
|
1265 |
1167 |
|
1266 |
1168 |
|
1267 |
|
@mock.patch('passerelle.utils.Request.get')
|
1268 |
|
@mock.patch('passerelle.utils.Request.post')
|
1269 |
|
def test_create_family_wrong_referential_key_error(mocked_post, mocked_get, con, app):
|
1270 |
|
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1271 |
|
mocked_post.side_effect = [
|
1272 |
|
READ_CATEGORIES,
|
1273 |
|
READ_SITUATIONS,
|
1274 |
|
READ_CIVILITIES,
|
1275 |
|
READ_QUALITIES,
|
1276 |
|
READ_CSP,
|
1277 |
|
READ_ORGAN,
|
1278 |
|
READ_DIETCODE,
|
1279 |
|
READ_VACCIN,
|
1280 |
|
]
|
|
1169 |
def test_create_family_wrong_referential_key_error(con, ref, app):
|
1281 |
1170 |
url = get_endpoint('create-family')
|
1282 |
1171 |
params = {
|
1283 |
1172 |
'category': 'ACCEUI',
|
1284 |
1173 |
'situation': 'C',
|
1285 |
1174 |
'rl1/civility': 'M.',
|
1286 |
1175 |
'rl1/firstname': 'Jhon',
|
1287 |
1176 |
'rl1/lastname': 'Doe',
|
1288 |
1177 |
'rl1/quality': 'AU',
|
... | ... | |
1313 |
1202 |
assert (
|
1314 |
1203 |
resp.json['err_desc']
|
1315 |
1204 |
== "childList/0/medicalRecord/vaccinList/0/code key value 'plop' do not belong to 'Vaccin' referential"
|
1316 |
1205 |
)
|
1317 |
1206 |
|
1318 |
1207 |
|
1319 |
1208 |
@mock.patch('passerelle.utils.Request.get')
|
1320 |
1209 |
@mock.patch('passerelle.utils.Request.post')
|
1321 |
|
def test_update_family(mocked_post, mocked_get, con, app):
|
|
1210 |
def test_update_family(mocked_post, mocked_get, con, ref, app):
|
1322 |
1211 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1323 |
|
mocked_post.side_effect = [
|
1324 |
|
READ_CATEGORIES,
|
1325 |
|
READ_SITUATIONS,
|
1326 |
|
READ_CIVILITIES,
|
1327 |
|
READ_QUALITIES,
|
1328 |
|
READ_CSP,
|
1329 |
|
READ_ORGAN,
|
1330 |
|
READ_DIETCODE,
|
1331 |
|
READ_PAI,
|
1332 |
|
READ_VACCIN,
|
1333 |
|
UPDATE_FAMILY,
|
1334 |
|
]
|
|
1212 |
mocked_post.return_value = UPDATE_FAMILY
|
1335 |
1213 |
url = get_endpoint('update-family')
|
1336 |
1214 |
params = {
|
1337 |
1215 |
'category': 'BI',
|
1338 |
1216 |
'situation': 'C',
|
1339 |
1217 |
'rl1/civility': 'M.',
|
1340 |
1218 |
'rl1/firstname': 'Jhon',
|
1341 |
1219 |
'rl1/lastname': 'Doe',
|
1342 |
1220 |
'rl1/quality': 'AU',
|
... | ... | |
1397 |
1275 |
|
1398 |
1276 |
resp = app.post_json(url + '?NameID=local', params=params)
|
1399 |
1277 |
assert resp.json['err'] == 'not-linked'
|
1400 |
1278 |
assert resp.json['err_desc'] == 'User not linked to family'
|
1401 |
1279 |
|
1402 |
1280 |
|
1403 |
1281 |
@mock.patch('passerelle.utils.Request.get')
|
1404 |
1282 |
@mock.patch('passerelle.utils.Request.post')
|
1405 |
|
def test_update_family_maelis_error(mocked_post, mocked_get, con, app):
|
|
1283 |
def test_update_family_maelis_error(mocked_post, mocked_get, con, ref, app):
|
1406 |
1284 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1407 |
|
mocked_post.side_effect = [
|
1408 |
|
READ_CATEGORIES,
|
1409 |
|
READ_SITUATIONS,
|
1410 |
|
UPDATE_FAMILY_ERR,
|
1411 |
|
]
|
|
1285 |
mocked_post.return_value = UPDATE_FAMILY_ERR
|
1412 |
1286 |
url = get_endpoint('update-family')
|
1413 |
1287 |
params = {
|
1414 |
1288 |
'category': 'ACCEUI',
|
1415 |
1289 |
'situation': 'C',
|
1416 |
1290 |
'childList/0/lastname': 'Zimmerman',
|
1417 |
1291 |
'childList/0/firstname': 'Robert',
|
1418 |
1292 |
'childList/0/sexe': 'M',
|
1419 |
1293 |
'childList/0/birth/dateBirth': '1941-05-24',
|
... | ... | |
1423 |
1297 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
1424 |
1298 |
resp = app.post_json(url + '?NameID=local', params=params)
|
1425 |
1299 |
assert resp.json['err'] == 'E65a'
|
1426 |
1300 |
assert "E65a : Il existe déjà un enfant" in resp.json['err_desc']
|
1427 |
1301 |
|
1428 |
1302 |
|
1429 |
1303 |
@mock.patch('passerelle.utils.Request.get')
|
1430 |
1304 |
@mock.patch('passerelle.utils.Request.post')
|
1431 |
|
def test_update_family_soap_error(mocked_post, mocked_get, con, app):
|
|
1305 |
def test_update_family_soap_error(mocked_post, mocked_get, con, ref, app):
|
1432 |
1306 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1433 |
1307 |
mocked_post.return_value = UPDATE_FAMILY_500
|
1434 |
1308 |
url = get_endpoint('update-family')
|
1435 |
1309 |
params = {
|
1436 |
1310 |
'nbChild': '100',
|
1437 |
1311 |
'category': 'BI',
|
1438 |
1312 |
'situation': 'C',
|
1439 |
1313 |
'rl1/civility': 'M.',
|
... | ... | |
1443 |
1317 |
'rl1/birth/dateBirth': '1938-07-26',
|
1444 |
1318 |
'rl1/adresse/street1': 'Chateau',
|
1445 |
1319 |
'rl1/adresse/town': 'Paris',
|
1446 |
1320 |
'rl1/adresse/zipcode': '75014',
|
1447 |
1321 |
}
|
1448 |
1322 |
|
1449 |
1323 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
1450 |
1324 |
resp = app.post_json(url + '?NameID=local', params=params)
|
1451 |
|
assert resp.json['err'] == 'Family-readCategoryList-soap:Server'
|
|
1325 |
assert resp.json['err'] == 'Family-updateFamily-soap:Server'
|
1452 |
1326 |
assert 'Une erreur est survenue' in resp.json['err_desc']
|
1453 |
1327 |
|
1454 |
1328 |
|
1455 |
|
@mock.patch('passerelle.utils.Request.get')
|
1456 |
|
@mock.patch('passerelle.utils.Request.post')
|
1457 |
|
def test_update_family_wrong_referential_key_error(mocked_post, mocked_get, con, app):
|
1458 |
|
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1459 |
|
mocked_post.side_effect = [
|
1460 |
|
READ_CATEGORIES,
|
1461 |
|
READ_SITUATIONS,
|
1462 |
|
READ_CIVILITIES,
|
1463 |
|
READ_QUALITIES,
|
1464 |
|
READ_CSP,
|
1465 |
|
READ_ORGAN,
|
1466 |
|
READ_DIETCODE,
|
1467 |
|
READ_PAI,
|
1468 |
|
READ_VACCIN,
|
1469 |
|
]
|
|
1329 |
def test_update_family_wrong_referential_key_error(con, ref, app):
|
1470 |
1330 |
url = get_endpoint('update-family')
|
1471 |
1331 |
params = {
|
1472 |
1332 |
'category': 'BI',
|
1473 |
1333 |
'situation': 'C',
|
1474 |
1334 |
'rl1/civility': 'M.',
|
1475 |
1335 |
'rl1/firstname': 'Jhon',
|
1476 |
1336 |
'rl1/lastname': 'Doe',
|
1477 |
1337 |
'rl1/quality': 'AU',
|
... | ... | |
1508 |
1368 |
assert (
|
1509 |
1369 |
resp.json['err_desc']
|
1510 |
1370 |
== "childList/0/medicalRecord/vaccinList/0/code key value 'plop' do not belong to 'Vaccin' referential"
|
1511 |
1371 |
)
|
1512 |
1372 |
|
1513 |
1373 |
|
1514 |
1374 |
@mock.patch('passerelle.utils.Request.get')
|
1515 |
1375 |
@mock.patch('passerelle.utils.Request.post')
|
1516 |
|
def test_create_rl1(mocked_post, mocked_get, con, app):
|
|
1376 |
def test_create_rl1(mocked_post, mocked_get, con, ref, app):
|
1517 |
1377 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1518 |
|
mocked_post.side_effect = [
|
1519 |
|
READ_CATEGORIES,
|
1520 |
|
READ_SITUATIONS,
|
1521 |
|
READ_CIVILITIES,
|
1522 |
|
READ_QUALITIES,
|
1523 |
|
CREATE_FAMILY,
|
1524 |
|
]
|
|
1378 |
mocked_post.return_value = CREATE_FAMILY
|
1525 |
1379 |
url = get_endpoint('create-rl1')
|
1526 |
1380 |
params = {
|
1527 |
1381 |
'category': 'ACCEUI',
|
1528 |
1382 |
'situation': 'C',
|
1529 |
1383 |
'rl1/civility': 'M.',
|
1530 |
1384 |
'rl1/firstname': 'Jhon',
|
1531 |
1385 |
'rl1/lastname': 'Doe',
|
1532 |
1386 |
'rl1/quality': 'AU',
|
... | ... | |
1579 |
1433 |
}
|
1580 |
1434 |
|
1581 |
1435 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
1582 |
1436 |
resp = app.post_json(url + '?NameID=local', params=params)
|
1583 |
1437 |
assert resp.json['err'] == 'already-linked'
|
1584 |
1438 |
assert resp.json['err_desc'] == 'User already linked to family'
|
1585 |
1439 |
|
1586 |
1440 |
|
1587 |
|
@mock.patch('passerelle.utils.Request.get')
|
1588 |
|
@mock.patch('passerelle.utils.Request.post')
|
1589 |
|
def test_create_rl1_wrong_referential_key_error(mocked_post, mocked_get, con, app):
|
1590 |
|
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1591 |
|
mocked_post.side_effect = [READ_CATEGORIES, READ_SITUATIONS, READ_CIVILITIES, READ_QUALITIES]
|
|
1441 |
def test_create_rl1_wrong_referential_key_error(con, ref, app):
|
1592 |
1442 |
url = get_endpoint('create-rl1')
|
1593 |
1443 |
params = {
|
1594 |
1444 |
'category': 'ACCEUI',
|
1595 |
1445 |
'situation': 'C',
|
1596 |
1446 |
'rl1/civility': 'M.',
|
1597 |
1447 |
'rl1/firstname': 'Jhon',
|
1598 |
1448 |
'rl1/lastname': 'Doe',
|
1599 |
1449 |
'rl1/quality': 'AU',
|
... | ... | |
1609 |
1459 |
assert (
|
1610 |
1460 |
resp.json['err_desc']
|
1611 |
1461 |
== "rl1/adresse/numComp key value 'plop' do not belong to 'Complement' referential"
|
1612 |
1462 |
)
|
1613 |
1463 |
|
1614 |
1464 |
|
1615 |
1465 |
@mock.patch('passerelle.utils.Request.get')
|
1616 |
1466 |
@mock.patch('passerelle.utils.Request.post')
|
1617 |
|
def test_create_rl1_maelis_error(mocked_post, mocked_get, con, app):
|
|
1467 |
def test_create_rl1_maelis_error(mocked_post, mocked_get, con, ref, app):
|
1618 |
1468 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1619 |
|
mocked_post.side_effect = [
|
1620 |
|
READ_CATEGORIES,
|
1621 |
|
READ_SITUATIONS,
|
1622 |
|
READ_CIVILITIES,
|
1623 |
|
READ_QUALITIES,
|
1624 |
|
CREATE_FAMILY_ERR,
|
1625 |
|
]
|
|
1469 |
mocked_post.return_value = CREATE_FAMILY_ERR
|
1626 |
1470 |
url = get_endpoint('create-rl1')
|
1627 |
1471 |
params = {
|
1628 |
1472 |
'category': 'ACCEUI',
|
1629 |
1473 |
'situation': 'C',
|
1630 |
1474 |
'rl1/civility': 'M.',
|
1631 |
1475 |
'rl1/firstname': 'Jhon',
|
1632 |
1476 |
'rl1/lastname': 'Doe',
|
1633 |
1477 |
'rl1/quality': 'AU',
|
... | ... | |
1639 |
1483 |
|
1640 |
1484 |
resp = app.post_json(url + '?NameID=local', params=params)
|
1641 |
1485 |
assert resp.json['err'] == 'already-rl1'
|
1642 |
1486 |
assert 'Il existe déjà' in resp.json['err_desc']
|
1643 |
1487 |
|
1644 |
1488 |
|
1645 |
1489 |
@mock.patch('passerelle.utils.Request.get')
|
1646 |
1490 |
@mock.patch('passerelle.utils.Request.post')
|
1647 |
|
def test_update_rl1(mocked_post, mocked_get, con, app):
|
|
1491 |
def test_update_rl1(mocked_post, mocked_get, con, ref, app):
|
1648 |
1492 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1649 |
|
mocked_post.side_effect = [READ_CIVILITIES, READ_QUALITIES, READ_RL1_FAMILY, UPDATE_FAMILY]
|
|
1493 |
mocked_post.side_effect = [READ_RL1_FAMILY, UPDATE_FAMILY]
|
1650 |
1494 |
url = get_endpoint('update-rl1')
|
1651 |
1495 |
params = {
|
1652 |
1496 |
'civility': 'M.',
|
1653 |
1497 |
'firstname': 'Jhonny',
|
1654 |
1498 |
'lastname': 'Doe',
|
1655 |
1499 |
'quality': 'PERE',
|
1656 |
1500 |
'birth/dateBirth': '1943-06-15',
|
1657 |
1501 |
}
|
... | ... | |
1674 |
1518 |
|
1675 |
1519 |
resp = app.post_json(url + '?NameID=local', params=params)
|
1676 |
1520 |
assert resp.json['err'] == 'not-linked'
|
1677 |
1521 |
assert resp.json['err_desc'] == 'User not linked to family'
|
1678 |
1522 |
|
1679 |
1523 |
|
1680 |
1524 |
@mock.patch('passerelle.utils.Request.get')
|
1681 |
1525 |
@mock.patch('passerelle.utils.Request.post')
|
1682 |
|
def test_update_rl1_connection_error(mocked_post, mocked_get, con, app):
|
|
1526 |
def test_update_rl1_connection_error(mocked_post, mocked_get, con, ref, app):
|
1683 |
1527 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1684 |
1528 |
mocked_post.side_effect = CONNECTION_ERROR
|
1685 |
1529 |
url = get_endpoint('update-rl1')
|
1686 |
1530 |
params = {
|
1687 |
1531 |
'civility': 'M.',
|
1688 |
1532 |
'firstname': 'Jhonny',
|
1689 |
1533 |
'lastname': 'Doe',
|
1690 |
1534 |
'quality': 'PERE',
|
... | ... | |
1692 |
1536 |
}
|
1693 |
1537 |
|
1694 |
1538 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
1695 |
1539 |
resp = app.post_json(url + '?NameID=local', params=params, status=500)
|
1696 |
1540 |
assert resp.json['err']
|
1697 |
1541 |
assert resp.json['err_desc'] == 'No address associated with hostname'
|
1698 |
1542 |
|
1699 |
1543 |
|
1700 |
|
@mock.patch('passerelle.utils.Request.get')
|
1701 |
|
@mock.patch('passerelle.utils.Request.post')
|
1702 |
|
def test_update_rl1_wrong_referential_key_error(mocked_post, mocked_get, con, app):
|
1703 |
|
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1704 |
|
mocked_post.side_effect = [READ_CIVILITIES, READ_QUALITIES]
|
|
1544 |
def test_update_rl1_wrong_referential_key_error(con, ref, app):
|
1705 |
1545 |
url = get_endpoint('update-rl1')
|
1706 |
1546 |
params = {
|
1707 |
1547 |
'civility': 'M.',
|
1708 |
1548 |
'firstname': 'Jhonny',
|
1709 |
1549 |
'lastname': 'Doe',
|
1710 |
1550 |
'quality': 'plop',
|
1711 |
1551 |
'birth/dateBirth': '1943-06-15',
|
1712 |
1552 |
}
|
... | ... | |
1714 |
1554 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
1715 |
1555 |
resp = app.post_json(url + '?NameID=local', params=params)
|
1716 |
1556 |
assert resp.json['err'] == 'wrong-key'
|
1717 |
1557 |
assert resp.json['err_desc'] == "quality key value 'plop' do not belong to 'Quality' required referential"
|
1718 |
1558 |
|
1719 |
1559 |
|
1720 |
1560 |
@mock.patch('passerelle.utils.Request.get')
|
1721 |
1561 |
@mock.patch('passerelle.utils.Request.post')
|
1722 |
|
def test_create_rl2(mocked_post, mocked_get, con, app):
|
|
1562 |
def test_create_rl2(mocked_post, mocked_get, con, ref, app):
|
1723 |
1563 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1724 |
|
mocked_post.side_effect = [READ_CIVILITIES, READ_QUALITIES, READ_RL1_FAMILY, UPDATE_FAMILY]
|
|
1564 |
mocked_post.side_effect = [READ_RL1_FAMILY, UPDATE_FAMILY]
|
1725 |
1565 |
url = get_endpoint('create-rl2')
|
1726 |
1566 |
params = {
|
1727 |
1567 |
'civility': 'MME',
|
1728 |
1568 |
'firstname': 'JANE',
|
1729 |
1569 |
'lastname': 'DOE',
|
1730 |
1570 |
'maidenName': 'Smith',
|
1731 |
1571 |
'quality': 'MERE',
|
1732 |
1572 |
'birth/dateBirth': '1940-06-22',
|
... | ... | |
1760 |
1600 |
|
1761 |
1601 |
resp = app.post_json(url + '?NameID=local', params=params)
|
1762 |
1602 |
assert resp.json['err'] == 'not-linked'
|
1763 |
1603 |
assert resp.json['err_desc'] == 'User not linked to family'
|
1764 |
1604 |
|
1765 |
1605 |
|
1766 |
1606 |
@mock.patch('passerelle.utils.Request.get')
|
1767 |
1607 |
@mock.patch('passerelle.utils.Request.post')
|
1768 |
|
def test_create_rl2_connection_error(mocked_post, mocked_get, con, app):
|
|
1608 |
def test_create_rl2_connection_error(mocked_post, mocked_get, con, ref, app):
|
1769 |
1609 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1770 |
1610 |
mocked_post.side_effect = CONNECTION_ERROR
|
1771 |
1611 |
url = get_endpoint('create-rl2')
|
1772 |
1612 |
params = {
|
1773 |
1613 |
'civility': 'MME',
|
1774 |
1614 |
'firstname': 'JANE',
|
1775 |
1615 |
'lastname': 'DOE',
|
1776 |
1616 |
'maidenName': 'Smith',
|
... | ... | |
1785 |
1625 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
1786 |
1626 |
resp = app.post_json(url + '?NameID=local', params=params, status=500)
|
1787 |
1627 |
assert resp.json['err']
|
1788 |
1628 |
assert resp.json['err_desc'] == 'No address associated with hostname'
|
1789 |
1629 |
|
1790 |
1630 |
|
1791 |
1631 |
@mock.patch('passerelle.utils.Request.get')
|
1792 |
1632 |
@mock.patch('passerelle.utils.Request.post')
|
1793 |
|
def test_create_rl2_already_exists_error(mocked_post, mocked_get, con, app):
|
|
1633 |
def test_create_rl2_already_exists_error(mocked_post, mocked_get, con, ref, app):
|
1794 |
1634 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1795 |
|
mocked_post.side_effect = [READ_CIVILITIES, READ_QUALITIES, READ_FAMILY, READ_FAMILY]
|
|
1635 |
mocked_post.side_effect = [READ_FAMILY, READ_FAMILY]
|
1796 |
1636 |
url = get_endpoint('create-rl2')
|
1797 |
1637 |
params = {
|
1798 |
1638 |
'civility': 'MME',
|
1799 |
1639 |
'firstname': 'JANE',
|
1800 |
1640 |
'lastname': 'DOE',
|
1801 |
1641 |
'maidenName': 'Smith',
|
1802 |
1642 |
'quality': 'MERE',
|
1803 |
1643 |
'birth/dateBirth': '1940-06-22',
|
... | ... | |
1808 |
1648 |
}
|
1809 |
1649 |
|
1810 |
1650 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
1811 |
1651 |
resp = app.post_json(url + '?NameID=local', params=params)
|
1812 |
1652 |
assert resp.json['err'] == 'already-rl2'
|
1813 |
1653 |
assert resp.json['err_desc'] == 'RL2 already defined on family'
|
1814 |
1654 |
|
1815 |
1655 |
|
1816 |
|
@mock.patch('passerelle.utils.Request.get')
|
1817 |
|
@mock.patch('passerelle.utils.Request.post')
|
1818 |
|
def test_create_rl2_wrong_referential_key_error(mocked_post, mocked_get, con, app):
|
1819 |
|
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1820 |
|
mocked_post.side_effect = [READ_CIVILITIES, READ_QUALITIES, READ_RL1_FAMILY]
|
|
1656 |
def test_create_rl2_wrong_referential_key_error(con, ref, app):
|
1821 |
1657 |
url = get_endpoint('create-rl2')
|
1822 |
1658 |
params = {
|
1823 |
1659 |
'civility': 'MME',
|
1824 |
1660 |
'firstname': 'JANE',
|
1825 |
1661 |
'lastname': 'DOE',
|
1826 |
1662 |
'maidenName': 'Smith',
|
1827 |
1663 |
'quality': 'plop',
|
1828 |
1664 |
'birth/dateBirth': '1940-06-22',
|
... | ... | |
1835 |
1671 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
1836 |
1672 |
resp = app.post_json(url + '?NameID=local', params=params)
|
1837 |
1673 |
assert resp.json['err'] == 'wrong-key'
|
1838 |
1674 |
assert resp.json['err_desc'] == "quality key value 'plop' do not belong to 'Quality' required referential"
|
1839 |
1675 |
|
1840 |
1676 |
|
1841 |
1677 |
@mock.patch('passerelle.utils.Request.get')
|
1842 |
1678 |
@mock.patch('passerelle.utils.Request.post')
|
1843 |
|
def test_update_rl2(mocked_post, mocked_get, con, app):
|
|
1679 |
def test_update_rl2(mocked_post, mocked_get, con, ref, app):
|
1844 |
1680 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1845 |
|
mocked_post.side_effect = [READ_CIVILITIES, READ_QUALITIES, READ_FAMILY, UPDATE_FAMILY]
|
|
1681 |
mocked_post.side_effect = [READ_FAMILY, UPDATE_FAMILY]
|
1846 |
1682 |
url = get_endpoint('update-rl2')
|
1847 |
1683 |
params = {
|
1848 |
1684 |
'civility': 'MME',
|
1849 |
1685 |
'firstname': 'JANE',
|
1850 |
1686 |
'lastname': 'DOE',
|
1851 |
1687 |
'maidenName': 'Smith',
|
1852 |
1688 |
'quality': 'MERE',
|
1853 |
1689 |
'birth/dateBirth': '1940-06-22',
|
... | ... | |
1872 |
1708 |
|
1873 |
1709 |
resp = app.post_json(url + '?NameID=local', params=params)
|
1874 |
1710 |
assert resp.json['err'] == 'not-linked'
|
1875 |
1711 |
assert resp.json['err_desc'] == 'User not linked to family'
|
1876 |
1712 |
|
1877 |
1713 |
|
1878 |
1714 |
@mock.patch('passerelle.utils.Request.get')
|
1879 |
1715 |
@mock.patch('passerelle.utils.Request.post')
|
1880 |
|
def test_update_rl2_connection_error(mocked_post, mocked_get, con, app):
|
|
1716 |
def test_update_rl2_connection_error(mocked_post, mocked_get, con, ref, app):
|
1881 |
1717 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1882 |
1718 |
mocked_post.side_effect = CONNECTION_ERROR
|
1883 |
1719 |
url = get_endpoint('update-rl2')
|
1884 |
1720 |
params = {
|
1885 |
1721 |
'civility': 'MME',
|
1886 |
1722 |
'firstname': 'JANE',
|
1887 |
1723 |
'lastname': 'DOE',
|
1888 |
1724 |
'maidenName': 'Smith',
|
... | ... | |
1893 |
1729 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
1894 |
1730 |
resp = app.post_json(url + '?NameID=local', params=params, status=500)
|
1895 |
1731 |
assert resp.json['err']
|
1896 |
1732 |
assert resp.json['err_desc'] == 'No address associated with hostname'
|
1897 |
1733 |
|
1898 |
1734 |
|
1899 |
1735 |
@mock.patch('passerelle.utils.Request.get')
|
1900 |
1736 |
@mock.patch('passerelle.utils.Request.post')
|
1901 |
|
def test_update_rl2_not_exists_error(mocked_post, mocked_get, con, app):
|
|
1737 |
def test_update_rl2_not_exists_error(mocked_post, mocked_get, con, ref, app):
|
1902 |
1738 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1903 |
|
mocked_post.side_effect = [READ_CIVILITIES, READ_QUALITIES, READ_RL1_FAMILY]
|
|
1739 |
mocked_post.return_value = READ_RL1_FAMILY
|
1904 |
1740 |
url = get_endpoint('update-rl2')
|
1905 |
1741 |
params = {
|
1906 |
1742 |
'civility': 'MME',
|
1907 |
1743 |
'firstname': 'JANE',
|
1908 |
1744 |
'lastname': 'DOE',
|
1909 |
1745 |
'maidenName': 'Smith',
|
1910 |
1746 |
'quality': 'MERE',
|
1911 |
1747 |
'birth/dateBirth': '1940-06-22',
|
1912 |
1748 |
}
|
1913 |
1749 |
|
1914 |
1750 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
1915 |
1751 |
resp = app.post_json(url + '?NameID=local', params=params)
|
1916 |
1752 |
assert resp.json['err'] == 'no-rl2'
|
1917 |
1753 |
assert resp.json['err_desc'] == 'No RL2 to update on family'
|
1918 |
1754 |
|
1919 |
1755 |
|
1920 |
|
@mock.patch('passerelle.utils.Request.get')
|
1921 |
|
@mock.patch('passerelle.utils.Request.post')
|
1922 |
|
def test_update_rl2_wrong_referential_key_error(mocked_post, mocked_get, con, app):
|
1923 |
|
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1924 |
|
mocked_post.side_effect = [READ_CIVILITIES, READ_QUALITIES]
|
|
1756 |
def test_update_rl2_wrong_referential_key_error(con, ref, app):
|
1925 |
1757 |
url = get_endpoint('update-rl2')
|
1926 |
1758 |
params = {
|
1927 |
1759 |
'civility': 'MME',
|
1928 |
1760 |
'firstname': 'JANE',
|
1929 |
1761 |
'lastname': 'DOE',
|
1930 |
1762 |
'maidenName': 'Smith',
|
1931 |
1763 |
'quality': 'plop',
|
1932 |
1764 |
'birth/dateBirth': '1940-06-22',
|
... | ... | |
1935 |
1767 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
1936 |
1768 |
resp = app.post_json(url + '?NameID=local', params=params)
|
1937 |
1769 |
assert resp.json['err'] == 'wrong-key'
|
1938 |
1770 |
assert resp.json['err_desc'] == "quality key value 'plop' do not belong to 'Quality' required referential"
|
1939 |
1771 |
|
1940 |
1772 |
|
1941 |
1773 |
@mock.patch('passerelle.utils.Request.get')
|
1942 |
1774 |
@mock.patch('passerelle.utils.Request.post')
|
1943 |
|
def test_create_child(mocked_post, mocked_get, con, app):
|
|
1775 |
def test_create_child(mocked_post, mocked_get, con, ref, app):
|
1944 |
1776 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1945 |
1777 |
mocked_post.return_value = CREATE_CHILD
|
1946 |
1778 |
url = get_endpoint('create-child')
|
1947 |
1779 |
params = {
|
1948 |
1780 |
'lastname': 'DOE',
|
1949 |
1781 |
'firstname': 'JANNIS',
|
1950 |
1782 |
'sexe': 'F',
|
1951 |
1783 |
'birth/dateBirth': '1943-01-19',
|
... | ... | |
1984 |
1816 |
'birth/place': 'Port Arthur',
|
1985 |
1817 |
}
|
1986 |
1818 |
|
1987 |
1819 |
resp = app.post_json(url + '?NameID=local', params=params)
|
1988 |
1820 |
assert resp.json['err'] == 'not-linked'
|
1989 |
1821 |
assert resp.json['err_desc'] == 'User not linked to family'
|
1990 |
1822 |
|
1991 |
1823 |
|
1992 |
|
@mock.patch('passerelle.utils.Request.get')
|
1993 |
|
@mock.patch('passerelle.utils.Request.post')
|
1994 |
|
def test_create_child_wrong_referential_key_error(mocked_post, mocked_get, con, app):
|
1995 |
|
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
1996 |
|
mocked_post.side_effect = []
|
|
1824 |
def test_create_child_wrong_referential_key_error(con, ref, app):
|
1997 |
1825 |
url = get_endpoint('create-child')
|
1998 |
1826 |
params = {
|
1999 |
1827 |
'lastname': 'DOE',
|
2000 |
1828 |
'firstname': 'JANNIS',
|
2001 |
1829 |
'sexe': 'plop',
|
2002 |
1830 |
'birth/dateBirth': '1943-01-19',
|
2003 |
1831 |
'birth/place': 'Port Arthur',
|
2004 |
1832 |
}
|
... | ... | |
2006 |
1834 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
2007 |
1835 |
resp = app.post_json(url + '?NameID=local', params=params)
|
2008 |
1836 |
assert resp.json['err'] == 'wrong-key'
|
2009 |
1837 |
assert resp.json['err_desc'] == "sexe key value 'plop' do not belong to 'Sex' required referential"
|
2010 |
1838 |
|
2011 |
1839 |
|
2012 |
1840 |
@mock.patch('passerelle.utils.Request.get')
|
2013 |
1841 |
@mock.patch('passerelle.utils.Request.post')
|
2014 |
|
def test_create_child_connection_error(mocked_post, mocked_get, con, app):
|
|
1842 |
def test_create_child_connection_error(mocked_post, mocked_get, con, ref, app):
|
2015 |
1843 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
2016 |
1844 |
mocked_post.side_effect = CONNECTION_ERROR
|
2017 |
1845 |
url = get_endpoint('create-child')
|
2018 |
1846 |
params = {
|
2019 |
1847 |
'lastname': 'DOE',
|
2020 |
1848 |
'firstname': 'JANNIS',
|
2021 |
1849 |
'sexe': 'F',
|
2022 |
1850 |
'birth/dateBirth': '1943-01-19',
|
... | ... | |
2026 |
1854 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
2027 |
1855 |
resp = app.post_json(url + '?NameID=local', params=params, status=500)
|
2028 |
1856 |
assert resp.json['err']
|
2029 |
1857 |
assert resp.json['err_desc'] == 'No address associated with hostname'
|
2030 |
1858 |
|
2031 |
1859 |
|
2032 |
1860 |
@mock.patch('passerelle.utils.Request.get')
|
2033 |
1861 |
@mock.patch('passerelle.utils.Request.post')
|
2034 |
|
def test_create_child_maelis_error(mocked_post, mocked_get, con, app):
|
|
1862 |
def test_create_child_maelis_error(mocked_post, mocked_get, con, ref, app):
|
2035 |
1863 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
2036 |
1864 |
mocked_post.return_value = CREATE_CHILD_ERR
|
2037 |
1865 |
url = get_endpoint('create-child')
|
2038 |
1866 |
params = {
|
2039 |
1867 |
'lastname': 'DOE',
|
2040 |
1868 |
'firstname': 'JANNIS',
|
2041 |
1869 |
'sexe': 'F',
|
2042 |
1870 |
'birth/dateBirth': '1943-01-19',
|
... | ... | |
2046 |
1874 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
2047 |
1875 |
resp = app.post_json(url + '?NameID=local', params=params)
|
2048 |
1876 |
assert resp.json['err'] == 'already-child'
|
2049 |
1877 |
assert 'Il existe déjà' in resp.json['err_desc']
|
2050 |
1878 |
|
2051 |
1879 |
|
2052 |
1880 |
@mock.patch('passerelle.utils.Request.get')
|
2053 |
1881 |
@mock.patch('passerelle.utils.Request.post')
|
2054 |
|
def test_update_child(mocked_post, mocked_get, con, app):
|
|
1882 |
def test_update_child(mocked_post, mocked_get, con, ref, app):
|
2055 |
1883 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
2056 |
1884 |
mocked_post.side_effect = [READ_FAMILY, UPDATE_FAMILY]
|
2057 |
1885 |
url = get_endpoint('update-child')
|
2058 |
1886 |
params = {
|
2059 |
1887 |
'lastname': 'DOE',
|
2060 |
1888 |
'firstname': 'JANNIS',
|
2061 |
1889 |
'sexe': 'F',
|
2062 |
1890 |
'birth/dateBirth': '1943-01-19',
|
... | ... | |
2081 |
1909 |
'birth/place': 'Port Arthur',
|
2082 |
1910 |
}
|
2083 |
1911 |
|
2084 |
1912 |
resp = app.post_json(url + '?NameID=local&child_id=613880', params=params)
|
2085 |
1913 |
assert resp.json['err'] == 'not-linked'
|
2086 |
1914 |
assert resp.json['err_desc'] == 'User not linked to family'
|
2087 |
1915 |
|
2088 |
1916 |
|
2089 |
|
@mock.patch('passerelle.utils.Request.get')
|
2090 |
|
@mock.patch('passerelle.utils.Request.post')
|
2091 |
|
def test_update_child_wrong_referential_key_error(mocked_post, mocked_get, con, app):
|
2092 |
|
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
2093 |
|
mocked_post.side_effect = []
|
|
1917 |
def test_update_child_wrong_referential_key_error(con, ref, app):
|
2094 |
1918 |
url = get_endpoint('create-child')
|
2095 |
1919 |
params = {
|
2096 |
1920 |
'lastname': 'DOE',
|
2097 |
1921 |
'firstname': 'JANNIS',
|
2098 |
1922 |
'sexe': 'plop',
|
2099 |
1923 |
'birth/dateBirth': '1943-01-19',
|
2100 |
1924 |
'birth/place': 'Port Arthur',
|
2101 |
1925 |
}
|
... | ... | |
2103 |
1927 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
2104 |
1928 |
resp = app.post_json(url + '?NameID=local', params=params)
|
2105 |
1929 |
assert resp.json['err'] == 'wrong-key'
|
2106 |
1930 |
assert resp.json['err_desc'] == "sexe key value 'plop' do not belong to 'Sex' required referential"
|
2107 |
1931 |
|
2108 |
1932 |
|
2109 |
1933 |
@mock.patch('passerelle.utils.Request.get')
|
2110 |
1934 |
@mock.patch('passerelle.utils.Request.post')
|
2111 |
|
def test_update_child_connection_error(mocked_post, mocked_get, con, app):
|
|
1935 |
def test_update_child_connection_error(mocked_post, mocked_get, con, ref, app):
|
2112 |
1936 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
2113 |
1937 |
mocked_post.side_effect = CONNECTION_ERROR
|
2114 |
1938 |
url = get_endpoint('update-child')
|
2115 |
1939 |
params = {
|
2116 |
1940 |
'lastname': 'DOE',
|
2117 |
1941 |
'firstname': 'JANNIS',
|
2118 |
1942 |
'sexe': 'F',
|
2119 |
1943 |
'birth/dateBirth': '1943-01-19',
|
... | ... | |
2123 |
1947 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
2124 |
1948 |
resp = app.post_json(url + '?NameID=local&child_id=613880', params=params, status=500)
|
2125 |
1949 |
assert resp.json['err']
|
2126 |
1950 |
assert resp.json['err_desc'] == 'No address associated with hostname'
|
2127 |
1951 |
|
2128 |
1952 |
|
2129 |
1953 |
@mock.patch('passerelle.utils.Request.get')
|
2130 |
1954 |
@mock.patch('passerelle.utils.Request.post')
|
2131 |
|
def test_update_child_not_exists_error(mocked_post, mocked_get, con, app):
|
|
1955 |
def test_update_child_not_exists_error(mocked_post, mocked_get, con, ref, app):
|
2132 |
1956 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
2133 |
1957 |
mocked_post.return_value = READ_RL1_FAMILY
|
2134 |
1958 |
url = get_endpoint('update-child')
|
2135 |
1959 |
params = {
|
2136 |
1960 |
'lastname': 'DOE',
|
2137 |
1961 |
'firstname': 'JANNIS',
|
2138 |
1962 |
'sexe': 'F',
|
2139 |
1963 |
'birth/dateBirth': '1943-01-19',
|
... | ... | |
2143 |
1967 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
2144 |
1968 |
resp = app.post_json(url + '?NameID=local&child_id=42', params=params)
|
2145 |
1969 |
assert resp.json['err'] == 'no-child'
|
2146 |
1970 |
assert resp.json['err_desc'] == 'No child 42 to update on family'
|
2147 |
1971 |
|
2148 |
1972 |
|
2149 |
1973 |
@mock.patch('passerelle.utils.Request.get')
|
2150 |
1974 |
@mock.patch('passerelle.utils.Request.post')
|
2151 |
|
def test_update_coordinate(mocked_post, mocked_get, con, app):
|
|
1975 |
def test_update_coordinate(mocked_post, mocked_get, con, ref, app):
|
2152 |
1976 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
2153 |
|
mocked_post.side_effect = [READ_CSP, READ_ORGAN, UPDATE_FAMILY]
|
|
1977 |
mocked_post.return_value = UPDATE_FAMILY
|
2154 |
1978 |
url = get_endpoint('update-coordinate')
|
2155 |
1979 |
params = {
|
2156 |
1980 |
'adresse/num': '169',
|
2157 |
1981 |
'adresse/numComp': 'B',
|
2158 |
1982 |
'adresse/street1': 'Château',
|
2159 |
1983 |
'adresse/street2': None,
|
2160 |
1984 |
'adresse/town': 'Paris',
|
2161 |
1985 |
'adresse/zipcode': '75014',
|
... | ... | |
2193 |
2017 |
}
|
2194 |
2018 |
resp = app.post_json(url + '?NameID=local&rl_id=613878', params=params, status=400)
|
2195 |
2019 |
assert resp.json['err'] == 1
|
2196 |
2020 |
assert resp.json['err_desc'] == "'true more text' is not of type 'boolean'"
|
2197 |
2021 |
|
2198 |
2022 |
|
2199 |
2023 |
@mock.patch('passerelle.utils.Request.get')
|
2200 |
2024 |
@mock.patch('passerelle.utils.Request.post')
|
2201 |
|
def test_update_coordinate_wrong_referential_key_error(mocked_post, mocked_get, con, app):
|
|
2025 |
def test_update_coordinate_wrong_referential_key_error(mocked_post, mocked_get, con, ref, app):
|
2202 |
2026 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
2203 |
2027 |
mocked_post.return_value = UPDATE_FAMILY
|
2204 |
2028 |
url = get_endpoint('update-coordinate')
|
2205 |
2029 |
params = {
|
2206 |
2030 |
'adresse/num': '169',
|
2207 |
2031 |
'adresse/numComp': 'plop',
|
2208 |
2032 |
'adresse/street1': 'Château',
|
2209 |
2033 |
'adresse/street2': None,
|
... | ... | |
2216 |
2040 |
assert resp.json['err'] == 'wrong-key'
|
2217 |
2041 |
assert (
|
2218 |
2042 |
resp.json['err_desc'] == "adresse/numComp key value 'plop' do not belong to 'Complement' referential"
|
2219 |
2043 |
)
|
2220 |
2044 |
|
2221 |
2045 |
|
2222 |
2046 |
@mock.patch('passerelle.utils.Request.get')
|
2223 |
2047 |
@mock.patch('passerelle.utils.Request.post')
|
2224 |
|
def test_create_person(mocked_post, mocked_get, con, app):
|
|
2048 |
def test_create_person(mocked_post, mocked_get, con, ref, app):
|
2225 |
2049 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
2226 |
|
mocked_post.side_effect = [READ_QUALITIES, READ_FAMILY, UPDATE_FAMILY]
|
|
2050 |
mocked_post.side_effect = [READ_FAMILY, UPDATE_FAMILY]
|
2227 |
2051 |
url = get_endpoint('create-person')
|
2228 |
2052 |
params = {
|
2229 |
2053 |
'civility': None,
|
2230 |
2054 |
'firstname': 'Mathias',
|
2231 |
2055 |
'lastname': 'Cassel',
|
2232 |
2056 |
'quality': 'O',
|
2233 |
2057 |
'sexe': 'M',
|
2234 |
2058 |
'dateBirth': '1972-01-01',
|
... | ... | |
2294 |
2118 |
'contact/mail': None,
|
2295 |
2119 |
}
|
2296 |
2120 |
|
2297 |
2121 |
resp = app.post_json(url + '?NameID=local', params=params)
|
2298 |
2122 |
assert resp.json['err'] == 'not-linked'
|
2299 |
2123 |
assert resp.json['err_desc'] == 'User not linked to family'
|
2300 |
2124 |
|
2301 |
2125 |
|
2302 |
|
@mock.patch('passerelle.utils.Request.get')
|
2303 |
|
@mock.patch('passerelle.utils.Request.post')
|
2304 |
|
def test_create_person_wrong_referential_key_error(mocked_post, mocked_get, con, app):
|
2305 |
|
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
2306 |
|
mocked_post.side_effect = [READ_QUALITIES]
|
|
2126 |
def test_create_person_wrong_referential_key_error(con, ref, app):
|
2307 |
2127 |
url = get_endpoint('create-person')
|
2308 |
2128 |
params = {
|
2309 |
2129 |
'civility': None,
|
2310 |
2130 |
'firstname': 'Mathias',
|
2311 |
2131 |
'lastname': 'Cassel',
|
2312 |
2132 |
'quality': 'O',
|
2313 |
2133 |
'sexe': 'plop',
|
2314 |
2134 |
'dateBirth': '1972-01-01',
|
... | ... | |
2320 |
2140 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
2321 |
2141 |
resp = app.post_json(url + '?NameID=local', params=params)
|
2322 |
2142 |
assert resp.json['err'] == 'wrong-key'
|
2323 |
2143 |
assert resp.json['err_desc'] == "sexe key value 'plop' do not belong to 'Sex' referential"
|
2324 |
2144 |
|
2325 |
2145 |
|
2326 |
2146 |
@mock.patch('passerelle.utils.Request.get')
|
2327 |
2147 |
@mock.patch('passerelle.utils.Request.post')
|
2328 |
|
def test_update_person(mocked_post, mocked_get, con, app):
|
|
2148 |
def test_update_person(mocked_post, mocked_get, con, ref, app):
|
2329 |
2149 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
2330 |
|
mocked_post.side_effect = [READ_QUALITIES, READ_FAMILY, UPDATE_FAMILY]
|
|
2150 |
mocked_post.side_effect = [READ_FAMILY, UPDATE_FAMILY]
|
2331 |
2151 |
url = get_endpoint('update-person')
|
2332 |
2152 |
params = {
|
2333 |
2153 |
'civility': None,
|
2334 |
2154 |
'firstname': 'Mathias',
|
2335 |
2155 |
'lastname': 'Cassel',
|
2336 |
2156 |
'quality': 'O',
|
2337 |
2157 |
'sexe': 'M',
|
2338 |
2158 |
'dateBirth': '1972-01-01',
|
... | ... | |
2363 |
2183 |
|
2364 |
2184 |
resp = app.post_json(url + '?NameID=local&person_id=614059', params=params)
|
2365 |
2185 |
assert resp.json['err'] == 'not-linked'
|
2366 |
2186 |
assert resp.json['err_desc'] == 'User not linked to family'
|
2367 |
2187 |
|
2368 |
2188 |
|
2369 |
2189 |
@mock.patch('passerelle.utils.Request.get')
|
2370 |
2190 |
@mock.patch('passerelle.utils.Request.post')
|
2371 |
|
def test_update_person_not_found(mocked_post, mocked_get, con, app):
|
|
2191 |
def test_update_person_not_found(mocked_post, mocked_get, con, ref, app):
|
2372 |
2192 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
2373 |
|
mocked_post.side_effect = [READ_QUALITIES, READ_FAMILY]
|
|
2193 |
mocked_post.return_value = READ_FAMILY
|
2374 |
2194 |
url = get_endpoint('update-person')
|
2375 |
2195 |
params = {
|
2376 |
2196 |
'civility': None,
|
2377 |
2197 |
'firstname': 'Mathias',
|
2378 |
2198 |
'lastname': 'Cassel',
|
2379 |
2199 |
'quality': 'O',
|
2380 |
2200 |
'sexe': 'M',
|
2381 |
2201 |
'dateBirth': '1972-01-01',
|
... | ... | |
2409 |
2229 |
assert resp.json['err'] == 'not-linked'
|
2410 |
2230 |
assert resp.json['err_desc'] == 'User not linked to family'
|
2411 |
2231 |
|
2412 |
2232 |
|
2413 |
2233 |
@mock.patch('passerelle.utils.Request.get')
|
2414 |
2234 |
@mock.patch('passerelle.utils.Request.post')
|
2415 |
2235 |
def test_delete_person_not_found(mocked_post, mocked_get, con, app):
|
2416 |
2236 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
2417 |
|
mocked_post.side_effect = [READ_FAMILY]
|
|
2237 |
mocked_post.return_value = READ_FAMILY
|
2418 |
2238 |
url = get_endpoint('delete-person')
|
2419 |
2239 |
|
2420 |
2240 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
2421 |
2241 |
resp = app.post_json(url + '?NameID=local&person_id=000000')
|
2422 |
2242 |
assert resp.json['err'] == 'not-found'
|
2423 |
2243 |
assert resp.json['err_desc'] == "no '000000' authorized person on '1312' family"
|
2424 |
2244 |
|
2425 |
2245 |
|
2426 |
2246 |
@mock.patch('passerelle.utils.Request.get')
|
2427 |
2247 |
@mock.patch('passerelle.utils.Request.post')
|
2428 |
|
def test_create_child_person(mocked_post, mocked_get, con, app):
|
|
2248 |
def test_create_child_person(mocked_post, mocked_get, con, ref, app):
|
2429 |
2249 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
2430 |
|
mocked_post.side_effect = [READ_CIVILITIES, READ_QUALITIES, READ_FAMILY, UPDATE_CHILD_AUTO]
|
|
2250 |
mocked_post.side_effect = [READ_FAMILY, UPDATE_CHILD_AUTO]
|
2431 |
2251 |
url = get_endpoint('create-child-person')
|
2432 |
2252 |
params = {
|
2433 |
2253 |
'personInfo/civility': 'MME',
|
2434 |
2254 |
'personInfo/firstname': 'Diana',
|
2435 |
2255 |
'personInfo/lastname': 'Ross',
|
2436 |
2256 |
'personInfo/sexe': 'F',
|
2437 |
2257 |
'personInfo/dateBirth': '1944-03-26',
|
2438 |
2258 |
'personInfo/contact/phone': '0199999999',
|
... | ... | |
2480 |
2300 |
'personQuality/code': 'TUTEUR',
|
2481 |
2301 |
}
|
2482 |
2302 |
|
2483 |
2303 |
resp = app.post_json(url + '?NameID=local&child_id=613880', params=params)
|
2484 |
2304 |
assert resp.json['err'] == 'not-linked'
|
2485 |
2305 |
assert resp.json['err_desc'] == 'User not linked to family'
|
2486 |
2306 |
|
2487 |
2307 |
|
2488 |
|
@mock.patch('passerelle.utils.Request.get')
|
2489 |
|
@mock.patch('passerelle.utils.Request.post')
|
2490 |
|
def test_create_child_person_wrong_referential_key_error(mocked_post, mocked_get, con, app):
|
2491 |
|
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
2492 |
|
mocked_post.side_effect = [READ_CIVILITIES]
|
|
2308 |
def test_create_child_person_wrong_referential_key_error(con, ref, app):
|
2493 |
2309 |
url = get_endpoint('create-child-person')
|
2494 |
2310 |
params = {
|
2495 |
2311 |
'personInfo/civility': 'MME',
|
2496 |
2312 |
'personInfo/firstname': 'Diana',
|
2497 |
2313 |
'personInfo/lastname': 'Ross',
|
2498 |
2314 |
'personInfo/sexe': 'plop',
|
2499 |
2315 |
'personInfo/dateBirth': '1944-03-26',
|
2500 |
2316 |
'personInfo/contact/phone': '0199999999',
|
... | ... | |
2506 |
2322 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
2507 |
2323 |
resp = app.post_json(url + '?NameID=local&child_id=613880', params=params)
|
2508 |
2324 |
assert resp.json['err'] == 'wrong-key'
|
2509 |
2325 |
assert resp.json['err_desc'] == "personInfo/sexe key value 'plop' do not belong to 'Sex' referential"
|
2510 |
2326 |
|
2511 |
2327 |
|
2512 |
2328 |
@mock.patch('passerelle.utils.Request.get')
|
2513 |
2329 |
@mock.patch('passerelle.utils.Request.post')
|
2514 |
|
def test_create_child_person_no_child_error(mocked_post, mocked_get, con, app):
|
|
2330 |
def test_create_child_person_no_child_error(mocked_post, mocked_get, con, ref, app):
|
2515 |
2331 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
2516 |
|
mocked_post.side_effect = [READ_CIVILITIES, READ_QUALITIES, READ_FAMILY]
|
|
2332 |
mocked_post.return_value = READ_FAMILY
|
2517 |
2333 |
url = get_endpoint('create-child-person')
|
2518 |
2334 |
params = {
|
2519 |
2335 |
'personInfo/civility': 'MME',
|
2520 |
2336 |
'personInfo/firstname': 'Diana',
|
2521 |
2337 |
'personInfo/lastname': 'Ross',
|
2522 |
2338 |
'personInfo/sexe': 'F',
|
2523 |
2339 |
'personInfo/dateBirth': '1944-03-26',
|
2524 |
2340 |
'personInfo/contact/phone': '01999999999',
|
... | ... | |
2530 |
2346 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
2531 |
2347 |
resp = app.post_json(url + '?NameID=local&child_id=42', params=params)
|
2532 |
2348 |
assert resp.json['err'] == 'not-found'
|
2533 |
2349 |
assert resp.json['err_desc'] == "no '42' child on '1312' family"
|
2534 |
2350 |
|
2535 |
2351 |
|
2536 |
2352 |
@mock.patch('passerelle.utils.Request.get')
|
2537 |
2353 |
@mock.patch('passerelle.utils.Request.post')
|
2538 |
|
def test_update_child_person(mocked_post, mocked_get, con, app):
|
|
2354 |
def test_update_child_person(mocked_post, mocked_get, con, ref, app):
|
2539 |
2355 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
2540 |
|
mocked_post.side_effect = [READ_CIVILITIES, READ_QUALITIES, READ_FAMILY, UPDATE_FAMILY]
|
|
2356 |
mocked_post.side_effect = [READ_FAMILY, UPDATE_FAMILY]
|
2541 |
2357 |
url = get_endpoint('update-child-person')
|
2542 |
2358 |
params = {
|
2543 |
2359 |
'personInfo/civility': 'M.',
|
2544 |
2360 |
'personInfo/firstname': 'Angelo',
|
2545 |
2361 |
'personInfo/lastname': 'Bent',
|
2546 |
2362 |
'personInfo/sexe': 'M',
|
2547 |
2363 |
'personInfo/dateBirth': '1985-06-22',
|
2548 |
2364 |
'personInfo/contact/phone': '0102030405',
|
... | ... | |
2570 |
2386 |
'personQuality/code': 'O',
|
2571 |
2387 |
}
|
2572 |
2388 |
|
2573 |
2389 |
resp = app.post_json(url + '?NameID=local&child_id=613880&person_id=614719', params=params)
|
2574 |
2390 |
assert resp.json['err'] == 'not-linked'
|
2575 |
2391 |
assert resp.json['err_desc'] == 'User not linked to family'
|
2576 |
2392 |
|
2577 |
2393 |
|
2578 |
|
@mock.patch('passerelle.utils.Request.get')
|
2579 |
|
@mock.patch('passerelle.utils.Request.post')
|
2580 |
|
def test_update_child_person_wrong_referential_key_error(mocked_post, mocked_get, con, app):
|
2581 |
|
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
2582 |
|
mocked_post.side_effect = [READ_CIVILITIES, READ_QUALITIES]
|
|
2394 |
def test_update_child_person_wrong_referential_key_error(con, ref, app):
|
2583 |
2395 |
url = get_endpoint('update-child-person')
|
2584 |
2396 |
params = {
|
2585 |
2397 |
'personInfo/civility': 'M.',
|
2586 |
2398 |
'personInfo/firstname': 'Angelo',
|
2587 |
2399 |
'personInfo/lastname': 'Bent',
|
2588 |
2400 |
'personInfo/sexe': 'plop',
|
2589 |
2401 |
'personInfo/dateBirth': '1985-06-22',
|
2590 |
2402 |
'personInfo/contact/phone': '0102030405',
|
... | ... | |
2596 |
2408 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
2597 |
2409 |
resp = app.post_json(url + '?NameID=local&child_id=613880&person_id=614719', params=params)
|
2598 |
2410 |
assert resp.json['err'] == 'wrong-key'
|
2599 |
2411 |
assert resp.json['err_desc'] == "personInfo/sexe key value 'plop' do not belong to 'Sex' referential"
|
2600 |
2412 |
|
2601 |
2413 |
|
2602 |
2414 |
@mock.patch('passerelle.utils.Request.get')
|
2603 |
2415 |
@mock.patch('passerelle.utils.Request.post')
|
2604 |
|
def test_update_child_person_no_child_error(mocked_post, mocked_get, con, app):
|
|
2416 |
def test_update_child_person_no_child_error(mocked_post, mocked_get, con, ref, app):
|
2605 |
2417 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
2606 |
|
mocked_post.side_effect = [READ_CIVILITIES, READ_QUALITIES, READ_FAMILY]
|
|
2418 |
mocked_post.return_value = READ_FAMILY
|
2607 |
2419 |
url = get_endpoint('update-child-person')
|
2608 |
2420 |
params = {
|
2609 |
2421 |
'personInfo/civility': 'M.',
|
2610 |
2422 |
'personInfo/firstname': 'Angelo',
|
2611 |
2423 |
'personInfo/lastname': 'Bent',
|
2612 |
2424 |
'personInfo/dateBirth': '1985-06-22',
|
2613 |
2425 |
'personInfo/contact/phone': '0102030405',
|
2614 |
2426 |
'personInfo/contact/mobile': None,
|
... | ... | |
2619 |
2431 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
2620 |
2432 |
resp = app.post_json(url + '?NameID=local&child_id=42&person_id=614719', params=params)
|
2621 |
2433 |
assert resp.json['err'] == 'not-found'
|
2622 |
2434 |
assert resp.json['err_desc'] == "no '42' child on '1312' family"
|
2623 |
2435 |
|
2624 |
2436 |
|
2625 |
2437 |
@mock.patch('passerelle.utils.Request.get')
|
2626 |
2438 |
@mock.patch('passerelle.utils.Request.post')
|
2627 |
|
def test_update_child_person_not_found(mocked_post, mocked_get, con, app):
|
|
2439 |
def test_update_child_person_not_found(mocked_post, mocked_get, con, ref, app):
|
2628 |
2440 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
2629 |
|
mocked_post.side_effect = [READ_CIVILITIES, READ_QUALITIES, READ_FAMILY]
|
|
2441 |
mocked_post.return_value = READ_FAMILY
|
2630 |
2442 |
url = get_endpoint('update-child-person')
|
2631 |
2443 |
params = {
|
2632 |
2444 |
'personInfo/civility': 'M.',
|
2633 |
2445 |
'personInfo/firstname': 'Angelo',
|
2634 |
2446 |
'personInfo/lastname': 'Bent',
|
2635 |
2447 |
'personInfo/dateBirth': '1985-06-22',
|
2636 |
2448 |
'personInfo/contact/phone': '0102030405',
|
2637 |
2449 |
'personInfo/contact/mobile': None,
|
... | ... | |
2665 |
2477 |
assert resp.json['err'] == 'not-linked'
|
2666 |
2478 |
assert resp.json['err_desc'] == 'User not linked to family'
|
2667 |
2479 |
|
2668 |
2480 |
|
2669 |
2481 |
@mock.patch('passerelle.utils.Request.get')
|
2670 |
2482 |
@mock.patch('passerelle.utils.Request.post')
|
2671 |
2483 |
def test_delete_child_person_no_child_error(mocked_post, mocked_get, con, app):
|
2672 |
2484 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
2673 |
|
mocked_post.side_effect = [READ_FAMILY]
|
|
2485 |
mocked_post.return_value = READ_FAMILY
|
2674 |
2486 |
url = get_endpoint('delete-child-person')
|
2675 |
2487 |
|
2676 |
2488 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
2677 |
2489 |
resp = app.post_json(url + '?NameID=local&child_id=42&person_id=614719')
|
2678 |
2490 |
assert resp.json['err'] == 'not-found'
|
2679 |
2491 |
assert resp.json['err_desc'] == "no '42' child on '1312' family"
|
2680 |
2492 |
|
2681 |
2493 |
|
2682 |
2494 |
@mock.patch('passerelle.utils.Request.get')
|
2683 |
2495 |
@mock.patch('passerelle.utils.Request.post')
|
2684 |
2496 |
def test_delete_child_person_no_person_error(mocked_post, mocked_get, con, app):
|
2685 |
2497 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
2686 |
|
mocked_post.side_effect = [READ_FAMILY]
|
|
2498 |
mocked_post.return_value = READ_FAMILY
|
2687 |
2499 |
url = get_endpoint('delete-child-person')
|
2688 |
2500 |
|
2689 |
2501 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
2690 |
2502 |
resp = app.post_json(url + '?NameID=local&child_id=613880&person_id=000000')
|
2691 |
2503 |
assert resp.json['err'] == 'not-found'
|
2692 |
2504 |
assert resp.json['err_desc'] == "No '000000' authorized person on '613880' child"
|
2693 |
2505 |
|
2694 |
2506 |
|
2695 |
2507 |
@mock.patch('passerelle.utils.Request.get')
|
2696 |
2508 |
@mock.patch('passerelle.utils.Request.post')
|
2697 |
|
def test_update_child_dietcode(mocked_post, mocked_get, con, app):
|
|
2509 |
def test_update_child_dietcode(mocked_post, mocked_get, con, ref, app):
|
2698 |
2510 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
2699 |
|
mocked_post.side_effect = [READ_DIETCODE, UPDATE_DIETCODE]
|
|
2511 |
mocked_post.return_value = UPDATE_DIETCODE
|
2700 |
2512 |
url = get_endpoint('update-child-dietcode')
|
2701 |
2513 |
|
2702 |
2514 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
2703 |
2515 |
resp = app.post_json(url + '?NameID=local&child_id=613878&dietcode=RSV')
|
2704 |
2516 |
assert_sent_payload(mocked_post, 'Q_update_child_dietcode.xml')
|
2705 |
2517 |
assert resp.json['err'] == 0
|
2706 |
2518 |
assert resp.json['data'] == 'ok'
|
2707 |
2519 |
|
... | ... | |
2709 |
2521 |
def test_update_child_dietcode_not_linked_error(con, app):
|
2710 |
2522 |
url = get_endpoint('update-child-dietcode')
|
2711 |
2523 |
|
2712 |
2524 |
resp = app.post_json(url + '?NameID=local&child_id=613878&dietcode=RVS')
|
2713 |
2525 |
assert resp.json['err'] == 'not-linked'
|
2714 |
2526 |
assert resp.json['err_desc'] == 'User not linked to family'
|
2715 |
2527 |
|
2716 |
2528 |
|
2717 |
|
@mock.patch('passerelle.utils.Request.get')
|
2718 |
|
@mock.patch('passerelle.utils.Request.post')
|
2719 |
|
def test_update_child_dietcode_wrong_referential_key_error(mocked_post, mocked_get, con, app):
|
2720 |
|
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
2721 |
|
mocked_post.side_effect = [READ_DIETCODE, UPDATE_DIETCODE]
|
|
2529 |
def test_update_child_dietcode_wrong_referential_key_error(con, ref, app):
|
2722 |
2530 |
url = get_endpoint('update-child-dietcode')
|
2723 |
2531 |
|
2724 |
2532 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
2725 |
2533 |
resp = app.post_json(url + '?NameID=local&child_id=613878&dietcode=plop')
|
2726 |
2534 |
assert resp.json['err'] == 'wrong-key'
|
2727 |
2535 |
assert (
|
2728 |
2536 |
resp.json['err_desc'] == "dietcode parameter key value 'plop' do not belong to 'DietCode' referential"
|
2729 |
2537 |
)
|
2730 |
2538 |
|
2731 |
2539 |
|
2732 |
2540 |
@mock.patch('passerelle.utils.Request.get')
|
2733 |
2541 |
@mock.patch('passerelle.utils.Request.post')
|
2734 |
|
def test_update_child_pai(mocked_post, mocked_get, con, app):
|
|
2542 |
def test_update_child_pai(mocked_post, mocked_get, con, ref, app):
|
2735 |
2543 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
2736 |
|
mocked_post.side_effect = [READ_PAI, UPDATE_PAI]
|
|
2544 |
mocked_post.return_value = UPDATE_PAI
|
2737 |
2545 |
url = get_endpoint('update-child-pai')
|
2738 |
2546 |
params = {
|
2739 |
2547 |
'code': 'PAIALI',
|
2740 |
2548 |
'dateDeb': '2022-01-01',
|
2741 |
2549 |
'dateFin': '',
|
2742 |
2550 |
'description': 'some text',
|
2743 |
2551 |
}
|
2744 |
2552 |
|
... | ... | |
2794 |
2602 |
|
2795 |
2603 |
resp = app.post_json(url + '?NameID=local&child_id=613878', params=params)
|
2796 |
2604 |
assert resp.json['err'] == 'not-linked'
|
2797 |
2605 |
assert resp.json['err_desc'] == 'User not linked to family'
|
2798 |
2606 |
|
2799 |
2607 |
|
2800 |
2608 |
@mock.patch('passerelle.utils.Request.get')
|
2801 |
2609 |
@mock.patch('passerelle.utils.Request.post')
|
2802 |
|
def test_update_child_pai_soap_error(mocked_post, mocked_get, con, app):
|
|
2610 |
def test_update_child_pai_soap_error(mocked_post, mocked_get, con, ref, app):
|
2803 |
2611 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
2804 |
|
mocked_post.side_effect = [READ_PAI, UPDATE_PAI_500]
|
|
2612 |
mocked_post.return_value = UPDATE_PAI_500
|
2805 |
2613 |
url = get_endpoint('update-child-pai')
|
2806 |
2614 |
params = {
|
2807 |
2615 |
'code': 'PAIALI',
|
2808 |
2616 |
'dateDeb': '2022-01-01',
|
2809 |
2617 |
'dateFin': '',
|
2810 |
2618 |
'description': 'a' * 501,
|
2811 |
2619 |
}
|
2812 |
2620 |
|
... | ... | |
2815 |
2623 |
assert resp.json['err'] == 'Family-updateChildPAI-soap:Server'
|
2816 |
2624 |
assert 'Une erreur est survenue' in resp.json['err_desc']
|
2817 |
2625 |
assert 'valeur trop grande' in resp.json['err_desc']
|
2818 |
2626 |
assert 'maximum : 500' in resp.json['err_desc']
|
2819 |
2627 |
|
2820 |
2628 |
|
2821 |
2629 |
@mock.patch('passerelle.utils.Request.get')
|
2822 |
2630 |
@mock.patch('passerelle.utils.Request.post')
|
2823 |
|
def test_update_child_medical_record(mocked_post, mocked_get, con, app):
|
|
2631 |
def test_update_child_medical_record(mocked_post, mocked_get, con, ref, app):
|
2824 |
2632 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
2825 |
|
mocked_post.side_effect = [READ_VACCIN, UPDATE_MEDICAL]
|
|
2633 |
mocked_post.return_value = UPDATE_MEDICAL
|
2826 |
2634 |
url = get_endpoint('update-child-medical-record')
|
2827 |
2635 |
params = {
|
2828 |
2636 |
'familyDoctor/name': 'Dre',
|
2829 |
2637 |
'familyDoctor/phone': '0612341234',
|
2830 |
2638 |
'familyDoctor/address/street1': 'Alameda',
|
2831 |
2639 |
'familyDoctor/address/zipcode': '90220',
|
2832 |
2640 |
'familyDoctor/address/town': 'Compton',
|
2833 |
2641 |
'allergy1': 'butterscotch, imitation butterscotch, glow-in-the-dark monster make-up, and shrimp',
|
... | ... | |
2848 |
2656 |
resp = app.post_json(url + '?NameID=local&child_id=613878', params=params)
|
2849 |
2657 |
assert_sent_payload(mocked_post, 'Q_update_child_medical_record.xml')
|
2850 |
2658 |
assert resp.json['err'] == 0
|
2851 |
2659 |
assert resp.json['data'] == 'ok'
|
2852 |
2660 |
|
2853 |
2661 |
|
2854 |
2662 |
@mock.patch('passerelle.utils.Request.get')
|
2855 |
2663 |
@mock.patch('passerelle.utils.Request.post')
|
2856 |
|
def test_update_child_medical_record_with_empty_vaccin_list(mocked_post, mocked_get, con, app):
|
|
2664 |
def test_update_child_medical_record_with_empty_vaccin_list(mocked_post, mocked_get, con, ref, app):
|
2857 |
2665 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
2858 |
|
mocked_post.side_effect = [READ_VACCIN, UPDATE_MEDICAL]
|
|
2666 |
mocked_post.return_value = UPDATE_MEDICAL
|
2859 |
2667 |
url = get_endpoint('update-child-medical-record')
|
2860 |
2668 |
params = {
|
2861 |
2669 |
'familyDoctor/name': 'Dre',
|
2862 |
2670 |
'familyDoctor/phone': '0612341234',
|
2863 |
2671 |
'familyDoctor/address/street1': 'Alameda',
|
2864 |
2672 |
'familyDoctor/address/zipcode': '90220',
|
2865 |
2673 |
'familyDoctor/address/town': 'Compton',
|
2866 |
2674 |
'allergy1': 'butterscotch, imitation butterscotch, glow-in-the-dark monster make-up, and shrimp',
|
... | ... | |
2884 |
2692 |
|
2885 |
2693 |
resp = app.post_json(url + '?NameID=local&child_id=613878', params={})
|
2886 |
2694 |
assert resp.json['err'] == 'not-linked'
|
2887 |
2695 |
assert resp.json['err_desc'] == 'User not linked to family'
|
2888 |
2696 |
|
2889 |
2697 |
|
2890 |
2698 |
@mock.patch('passerelle.utils.Request.get')
|
2891 |
2699 |
@mock.patch('passerelle.utils.Request.post')
|
2892 |
|
def test_update_child_medical_record_soap_error(mocked_post, mocked_get, con, app):
|
|
2700 |
def test_update_child_medical_record_soap_error(mocked_post, mocked_get, con, ref, app):
|
2893 |
2701 |
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
2894 |
|
mocked_post.side_effect = [READ_VACCIN, UPDATE_MEDICAL_500]
|
|
2702 |
mocked_post.return_value = UPDATE_MEDICAL_500
|
2895 |
2703 |
url = get_endpoint('update-child-medical-record')
|
2896 |
2704 |
params = {
|
2897 |
2705 |
'vaccinList/0/code': 'DTC',
|
2898 |
2706 |
'vaccinList/0/vaccinationDate': '2022-02-31',
|
2899 |
2707 |
}
|
2900 |
2708 |
|
2901 |
2709 |
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
2902 |
2710 |
resp = app.post_json(url + '?NameID=local&child_id=613878', params=params)
|
2903 |
2711 |
assert resp.json['err'] == 'Family-updateChildMedicalRecord-soap:Client'
|
2904 |
2712 |
assert 'Unmarshalling Error' in resp.json['err_desc']
|
2905 |
2713 |
assert 'pas une valeur de calendrier grégorien' in resp.json['err_desc']
|
2906 |
2714 |
|
2907 |
2715 |
|
2908 |
|
@mock.patch('passerelle.utils.Request.get')
|
2909 |
|
@mock.patch('passerelle.utils.Request.post')
|
2910 |
|
def test_update_child_medical_record_wrong_referential_key_error(mocked_post, mocked_get, con, app):
|
2911 |
|
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
2912 |
|
mocked_post.side_effect = [READ_VACCIN]
|
|
2716 |
def test_update_child_medical_record_wrong_referential_key_error(con, ref, app):
|
2913 |
2717 |
url = get_endpoint('update-child-medical-record')
|
2914 |
2718 |
params = {
|
2915 |
2719 |
'familyDoctor/name': 'Dre',
|
2916 |
2720 |
'familyDoctor/phone': '0612341234',
|
2917 |
2721 |
'familyDoctor/address/street1': 'Alameda',
|
2918 |
2722 |
'familyDoctor/address/zipcode': '90220',
|
2919 |
2723 |
'familyDoctor/address/town': 'Compton',
|
2920 |
2724 |
'vaccinList/0/code': 'DTC',
|
2921 |
|
-
|