From d94b15920258abff6b670171eb4308b62fbc4292 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Mon, 16 Nov 2020 12:50:19 +0100 Subject: [PATCH 4/4] rsa13: add action detail endpoint (#48567) --- passerelle/contrib/rsa13/models.py | 67 ++++++++++++++++++++++++++++++ tests/test_rsa13.py | 26 ++++++++++++ 2 files changed, 93 insertions(+) diff --git a/passerelle/contrib/rsa13/models.py b/passerelle/contrib/rsa13/models.py index c33eb05b..4303418f 100644 --- a/passerelle/contrib/rsa13/models.py +++ b/passerelle/contrib/rsa13/models.py @@ -843,3 +843,70 @@ class RSA13Resource(BaseResource, HTTPResource): email=email, ip=ip, ) + + @endpoint( + name='platform', + pattern=r'^(?P[0-9]{1,10})/' + r'beneficiaire/(?P[0-9]{1,10})/' + r'action/(?P[0-9]{1,10})/$', + example_pattern='{platform_id}/beneficiaire/{beneficiary_id}/contrat/{action_id}/', + description=_('Get beneficiary action details'), + perm='can_access', + parameters=parameters( + { + 'platform_id': { + 'description': _('Platform numeric identifier'), + 'example_value': '11', + }, + 'beneficiary_id': { + 'description': _('Beneficiary numeric identifier'), + 'example_value': '12', + }, + 'action_id': { + 'description': _('Action numeric identifier'), + 'example_value': '7', + }, + } + ), + display_category=_('Platform'), + display_order=10, + json_schema_response=response_schema( + { + 'type': 'object', + 'required': [ + 'id', + 'contrat_id', + ], + 'properties': { + 'id': {'type': 'integer'}, + 'contrat_id': {'type': 'integer'}, + 'sac': {'type': 'string'}, + 'libelle': {'type': 'string'}, + 'date_preconisation': DATE_SCHEMA, + 'date_deb': DATE_SCHEMA, + 'date_fin': DATE_SCHEMA, + 'date_cloture': DATE_SCHEMA, + 'moticlodac': {'type': 'string'}, + 'lib_moticlodac': {'type': 'string'}, + 'validation': { + 'enum': ['En cours', 'Oui', 'Non'], + }, + 'financement': { + 'properties': { + 'montant_demande': {'type': 'integer'}, + 'montant_accorde': {'type': 'integer'}, + } + }, + 'commentaire_ref': {'type': 'string'}, + }, + } + ), + ) + def platform_beneficiaire_action_detail( + self, request, platform_id, beneficiary_id, action_id, email, ip=None + ): + return self.get( + 'platform/%s/beneficiaire/%s/action/%s/' % (platform_id, beneficiary_id, action_id), + email=email, + ip=ip, + ) diff --git a/tests/test_rsa13.py b/tests/test_rsa13.py index 9bf6e9c5..7f3cd63c 100644 --- a/tests/test_rsa13.py +++ b/tests/test_rsa13.py @@ -447,3 +447,29 @@ def test_platform_beneficiaire_action(app, rsa13, url): 'err': 0, 'data': BENEFICIAIRE_ACTION, } + + +BENEFICIAIRE_ACTION_DETAIL = { + 'id': 663774, + 'contrat_id': 4, + 'sac': 'E3', + 'libelle': "Recherche autonome d'emploi", + 'date_deb': None, + 'date_fin': None, + 'date_preconisation': '2011-11-18', + 'date_cloture': '2012-01-12', + 'moticlodac': None, + 'lib_moticlodac': None, + 'validation': 'Non', + 'financement': {'montant_accorde': None, 'montant_demande': None}, + 'commentaire_ref': None, +} + + +@mock_response(['/api/platform/11/beneficiaire/386981/action/663774/', {'err': 0, 'data': BENEFICIAIRE_ACTION_DETAIL}]) +def test_platform_beneficiaire_action_detail(app, rsa13, url): + response = app.get(url + 'platform/11/beneficiaire/386981/action/663774/') + assert response.json == { + 'err': 0, + 'data': BENEFICIAIRE_ACTION_DETAIL, + } -- 2.29.2