0001-maelis-do-not-pass-any-date-to-subscription-webservi.patch
passerelle/apps/maelis/models.py | ||
---|---|---|
504 | 504 |
description=_('Subscribe'), |
505 | 505 |
parameters={ |
506 | 506 |
'NameID': {'description': _('Publik ID')}, |
507 | 507 |
'childID': {'description': _('Child ID')}, |
508 | 508 |
'activityID': {'description': _('Activity ID')}, |
509 | 509 |
'unitID': {'description': _('Unit ID')}, |
510 | 510 |
'placeID': {'description': _('Place ID')}, |
511 | 511 |
'weeklyPlanning': {'description': _('Week planning (7 chars)')}, |
512 |
'dateStart': {'description': _('Optional start date (YYYY-MM-DD)')} |
|
513 | 512 |
}) |
514 | 513 |
def subscribe(self, request, NameID, childID, activityID, unitID, placeID, |
515 |
weeklyPlanning, startDate=None):
|
|
514 |
weeklyPlanning): |
|
516 | 515 |
self.get_child_info(NameID, childID) |
517 |
if not startDate: |
|
518 |
startDate = timezone.now().date() |
|
519 | 516 |
client = self.get_client('FamilyService?wsdl') |
520 | 517 |
trigram_type = client.get_type('ns1:activityUnitPlaceBean') |
521 | 518 |
trigram = trigram_type( |
522 | 519 |
idActivity=activityID, |
523 | 520 |
idUnit=unitID, |
524 | 521 |
idPlace=placeID) |
525 | 522 |
subscription_type = client.get_type('ns1:subscribeActivityRequestBean') |
526 | 523 |
subpscription = subscription_type( |
527 | 524 |
personNumber=childID, |
528 | 525 |
activityUnitPlace=trigram, |
529 |
weeklyPlanning=weeklyPlanning, |
|
530 |
dateStart=startDate) |
|
526 |
weeklyPlanning=weeklyPlanning) |
|
531 | 527 |
r = self.call('FamilyService?wsdl', 'subscribeActivity', |
532 | 528 |
subscribeActivityRequestBean=subpscription) |
533 | 529 |
return {'data': serialize_object(r)} |
534 | 530 | |
535 | 531 | |
536 | 532 |
@endpoint( |
537 | 533 |
display_category=_('Family'), |
538 | 534 |
perm='can_access', |
tests/data/maelis/subscribeActivityResult.xml | ||
---|---|---|
1 |
<?xml version="1.0"?> |
|
2 | 1 |
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> |
3 | 2 |
<soap:Body> |
4 | 3 |
<ns1:subscribeActivityResponse xmlns:ns1="ws.maelis.sigec.com"> |
5 | 4 |
<subscribeActivityResultBean> |
6 |
<numPerson>198</numPerson>
|
|
5 |
<numPerson>18288</numPerson>
|
|
7 | 6 |
<activity>3 2020-2021 GARDERIE SOIR</activity> |
8 |
<dateStart>2021-01-08T00:00:00+01:00</dateStart>
|
|
7 |
<dateStart>2020-09-02T00:00:00+01:00</dateStart>
|
|
9 | 8 |
<dateEnd>2021-07-03T00:00:00+01:00</dateEnd> |
10 |
<datePreSubscribe>2021-01-08T15:40:25+01:00</datePreSubscribe>
|
|
11 |
<dateSubscribe>2021-01-08T15:40:25+01:00</dateSubscribe>
|
|
9 |
<datePreSubscribe>2021-01-08T18:46:25+01:00</datePreSubscribe>
|
|
10 |
<dateSubscribe>2021-01-08T18:46:25+01:00</dateSubscribe>
|
|
12 | 11 |
<typeConsum>ENF</typeConsum> |
13 |
<place>3 JEAN GIONO</place>
|
|
12 |
<place>2 FRANCOIS FABIE</place>
|
|
14 | 13 |
<state> |
15 | 14 |
<isWaitState>false</isWaitState> |
16 | 15 |
<idState>1</idState> |
17 | 16 |
<libelle>Confirmé</libelle> |
18 | 17 |
</state> |
19 | 18 |
</subscribeActivityResultBean> |
20 | 19 |
</ns1:subscribeActivityResponse> |
21 | 20 |
</soap:Body> |
tests/test_maelis.py | ||
---|---|---|
377 | 377 |
url += parameters |
378 | 378 |
resp = app.get(url) |
379 | 379 |
assert resp.json['err'] |
380 | 380 |
assert err_desc in resp.json['err_desc'] |
381 | 381 | |
382 | 382 | |
383 | 383 |
@mock.patch('passerelle.utils.Request.get') |
384 | 384 |
@mock.patch('passerelle.utils.Request.post') |
385 |
def test_subscribe_info(mocked_post, mocked_get, family_service_wsdl,
|
|
385 |
def test_subscribe(mocked_post, mocked_get, family_service_wsdl, |
|
386 | 386 |
connector, app): |
387 | 387 |
mocked_get.return_value = mock.Mock(content=family_service_wsdl) |
388 | 388 |
mocked_post.side_effect = ( |
389 | 389 |
utils.FakedResponse( |
390 | 390 |
content=get_xml_file('readFamily.xml'), |
391 | 391 |
status_code=200, |
392 | 392 |
headers={'Content-Type': 'text/xml'}), |
393 | 393 |
utils.FakedResponse( |
394 | 394 |
content=get_xml_file('subscribeActivityResult.xml'), |
395 | 395 |
status_code=200, |
396 | 396 |
headers={'Content-Type': 'text/xml'}) |
397 | 397 |
) |
398 | 398 |
Link.objects.create(resource=connector, family_id='3264', name_id='local') |
399 |
resp = app.get('/maelis/test/subscribe/?NameID=local&childID=21293&activityID=A10003123507&unitID=A10003123509&placeID=A10000000201&weeklyPlanning=XXXXXXX')
|
|
399 |
resp = app.get('/maelis/test/subscribe/?NameID=local&childID=21293&activityID=A10003123507&unitID=A10003123507&placeID=A10000000211&weeklyPlanning=XX1XX11')
|
|
400 | 400 |
assert not resp.json['err'] |
401 | 401 |
assert resp.json['data']['state'] == { |
402 | 402 |
"idState" : "1", |
403 | 403 |
"isWaitState" : False, |
404 | 404 |
"libelle" : "Confirmé" |
405 | 405 |
} |
406 |
- |