Projet

Général

Profil

0004-rsa13-add-action-detail-endpoint-48567.patch

Benjamin Dauvergne, 30 novembre 2020 12:23

Télécharger (4,33 ko)

Voir les différences:

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(+)
passerelle/contrib/rsa13/models.py
843 843
            email=email,
844 844
            ip=ip,
845 845
        )
846

  
847
    @endpoint(
848
        name='platform',
849
        pattern=r'^(?P<platform_id>[0-9]{1,10})/'
850
        r'beneficiaire/(?P<beneficiary_id>[0-9]{1,10})/'
851
        r'action/(?P<action_id>[0-9]{1,10})/$',
852
        example_pattern='{platform_id}/beneficiaire/{beneficiary_id}/contrat/{action_id}/',
853
        description=_('Get beneficiary action details'),
854
        perm='can_access',
855
        parameters=parameters(
856
            {
857
                'platform_id': {
858
                    'description': _('Platform numeric identifier'),
859
                    'example_value': '11',
860
                },
861
                'beneficiary_id': {
862
                    'description': _('Beneficiary numeric identifier'),
863
                    'example_value': '12',
864
                },
865
                'action_id': {
866
                    'description': _('Action numeric identifier'),
867
                    'example_value': '7',
868
                },
869
            }
870
        ),
871
        display_category=_('Platform'),
872
        display_order=10,
873
        json_schema_response=response_schema(
874
            {
875
                'type': 'object',
876
                'required': [
877
                    'id',
878
                    'contrat_id',
879
                ],
880
                'properties': {
881
                    'id': {'type': 'integer'},
882
                    'contrat_id': {'type': 'integer'},
883
                    'sac': {'type': 'string'},
884
                    'libelle': {'type': 'string'},
885
                    'date_preconisation': DATE_SCHEMA,
886
                    'date_deb': DATE_SCHEMA,
887
                    'date_fin': DATE_SCHEMA,
888
                    'date_cloture': DATE_SCHEMA,
889
                    'moticlodac': {'type': 'string'},
890
                    'lib_moticlodac': {'type': 'string'},
891
                    'validation': {
892
                        'enum': ['En cours', 'Oui', 'Non'],
893
                    },
894
                    'financement': {
895
                        'properties': {
896
                            'montant_demande': {'type': 'integer'},
897
                            'montant_accorde': {'type': 'integer'},
898
                        }
899
                    },
900
                    'commentaire_ref': {'type': 'string'},
901
                },
902
            }
903
        ),
904
    )
905
    def platform_beneficiaire_action_detail(
906
        self, request, platform_id, beneficiary_id, action_id, email, ip=None
907
    ):
908
        return self.get(
909
            'platform/%s/beneficiaire/%s/action/%s/' % (platform_id, beneficiary_id, action_id),
910
            email=email,
911
            ip=ip,
912
        )
tests/test_rsa13.py
447 447
        'err': 0,
448 448
        'data': BENEFICIAIRE_ACTION,
449 449
    }
450

  
451

  
452
BENEFICIAIRE_ACTION_DETAIL = {
453
    'id': 663774,
454
    'contrat_id': 4,
455
    'sac': 'E3',
456
    'libelle': "Recherche autonome d'emploi",
457
    'date_deb': None,
458
    'date_fin': None,
459
    'date_preconisation': '2011-11-18',
460
    'date_cloture': '2012-01-12',
461
    'moticlodac': None,
462
    'lib_moticlodac': None,
463
    'validation': 'Non',
464
    'financement': {'montant_accorde': None, 'montant_demande': None},
465
    'commentaire_ref': None,
466
}
467

  
468

  
469
@mock_response(['/api/platform/11/beneficiaire/386981/action/663774/', {'err': 0, 'data': BENEFICIAIRE_ACTION_DETAIL}])
470
def test_platform_beneficiaire_action_detail(app, rsa13, url):
471
    response = app.get(url + 'platform/11/beneficiaire/386981/action/663774/')
472
    assert response.json == {
473
        'err': 0,
474
        'data': BENEFICIAIRE_ACTION_DETAIL,
475
    }
450
-