0003-rsa13-add-action-endpoint.patch
passerelle/contrib/rsa13/models.py | ||
---|---|---|
790 | 790 |
email=email, |
791 | 791 |
ip=ip, |
792 | 792 |
) |
793 | ||
794 |
@endpoint( |
|
795 |
name='platform', |
|
796 |
pattern=r'^(?P<platform_id>[0-9]{1,10})/' |
|
797 |
r'beneficiaire/(?P<beneficiary_id>[0-9]{1,10})/' |
|
798 |
r'action/$', |
|
799 |
example_pattern='{platform_id}/beneficiaire/{beneficiary_id}/action/', |
|
800 |
description=_('Get beneficiary actions'), |
|
801 |
perm='can_access', |
|
802 |
parameters=parameters( |
|
803 |
{ |
|
804 |
'platform_id': { |
|
805 |
'description': _('Platform numeric identifier'), |
|
806 |
'example_value': '11', |
|
807 |
}, |
|
808 |
'beneficiary_id': { |
|
809 |
'description': _('Beneficiary numeric identifier'), |
|
810 |
'example_value': '12', |
|
811 |
}, |
|
812 |
} |
|
813 |
), |
|
814 |
display_category=_('Platform'), |
|
815 |
display_order=9, |
|
816 |
json_schema_response=response_schema( |
|
817 |
{ |
|
818 |
'type': 'object', |
|
819 |
'required': [ |
|
820 |
'id', |
|
821 |
'contrat_id', |
|
822 |
], |
|
823 |
'properties': { |
|
824 |
'id': {'type': 'integer'}, |
|
825 |
'contrat_id': {'type': 'integer'}, |
|
826 |
'libelle': {'type': 'string'}, |
|
827 |
'date_preconisation': DATE_SCHEMA, |
|
828 |
'date_deb': DATE_SCHEMA, |
|
829 |
'date_fin': DATE_SCHEMA, |
|
830 |
'validation': { |
|
831 |
'enum': ['En cours', 'Oui', 'Non'], |
|
832 |
}, |
|
833 |
'clos': OUI_NON_ENUM, |
|
834 |
}, |
|
835 |
} |
|
836 |
), |
|
837 |
) |
|
838 |
def platform_beneficiaire_action( |
|
839 |
self, request, platform_id, beneficiary_id, email, ip=None |
|
840 |
): |
|
841 |
return self.get( |
|
842 |
'platform/%s/beneficiaire/%s/action/' % (platform_id, beneficiary_id), |
|
843 |
email=email, |
|
844 |
ip=ip, |
|
845 |
) |
tests/test_rsa13.py | ||
---|---|---|
17 | 17 | |
18 | 18 |
import functools |
19 | 19 |
import json |
20 |
from urllib.parse import urlparse, parse_qs
|
|
20 |
from urllib.parse import parse_qs |
|
21 | 21 | |
22 | 22 |
import httmock |
23 | 23 |
import pytest |
... | ... | |
331 | 331 |
BENEFICIAIRE_TRANSPORT = {'cumuls': [{'duree': 54, 'type': 'GTU'}]} |
332 | 332 | |
333 | 333 | |
334 |
@mock_response( |
|
335 |
['/api/platform/11/beneficiaire/386981/transport/', {'err': 0, 'data': BENEFICIAIRE_TRANSPORT}] |
|
336 |
) |
|
334 |
@mock_response(['/api/platform/11/beneficiaire/386981/transport/', {'err': 0, 'data': BENEFICIAIRE_TRANSPORT}]) |
|
337 | 335 |
def test_platform_beneficiaire_transport(app, rsa13, url): |
338 | 336 |
response = app.get(url + 'platform/11/beneficiaire/386981/transport/') |
339 | 337 |
assert response.json == {'err': 0, 'data': BENEFICIAIRE_TRANSPORT} |
... | ... | |
387 | 385 |
'data': BENEFICIAIRE_CONTRAT, |
388 | 386 |
} |
389 | 387 | |
388 | ||
390 | 389 |
BENEFICIAIRE_CONTRAT_DETAIL = { |
391 | 390 |
'commentaire': 'Gratuité RTM refusée. En tant que bénéficiaire de la ' |
392 | 391 |
'CMUC vous pouvez obtenir un tarif préférentiel sur ' |
... | ... | |
415 | 414 |
'err': 0, |
416 | 415 |
'data': BENEFICIAIRE_CONTRAT_DETAIL, |
417 | 416 |
} |
417 | ||
418 | ||
419 |
BENEFICIAIRE_ACTION = [ |
|
420 |
{ |
|
421 |
'clos': 'Oui', |
|
422 |
'contrat_id': 4, |
|
423 |
'date_deb': None, |
|
424 |
'date_fin': None, |
|
425 |
'date_preconisation': '2011-11-18', |
|
426 |
'id': 663774, |
|
427 |
'libelle': "Recherche autonome d'emploi", |
|
428 |
'validation': 'Non', |
|
429 |
}, |
|
430 |
{ |
|
431 |
'clos': 'Oui', |
|
432 |
'contrat_id': 0, |
|
433 |
'date_deb': '2009-04-03', |
|
434 |
'date_fin': '2009-10-02', |
|
435 |
'date_preconisation': '2009-09-05', |
|
436 |
'id': 7435, |
|
437 |
'libelle': 'Ne plus utilisé-Reprise historique Logiform', |
|
438 |
'validation': 'Oui', |
|
439 |
}, |
|
440 |
] |
|
441 | ||
442 | ||
443 |
@mock_response(['/api/platform/11/beneficiaire/386981/action/', {'err': 0, 'data': BENEFICIAIRE_ACTION}]) |
|
444 |
def test_platform_beneficiaire_action(app, rsa13, url): |
|
445 |
response = app.get(url + 'platform/11/beneficiaire/386981/action/') |
|
446 |
assert response.json == { |
|
447 |
'err': 0, |
|
448 |
'data': BENEFICIAIRE_ACTION, |
|
449 |
} |
|
418 |
- |