From 39529a72e012cce047de2714eea6e69f9d1715d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Wed, 21 Aug 2019 10:25:00 +0200 Subject: [PATCH] lille urban card: add endpoint with socioprofessional categories (#35500) --- passerelle/contrib/lille_urban_card/models.py | 20 +++++++++++++++++++ tests/test_lille_urban_card.py | 5 +++++ 2 files changed, 25 insertions(+) diff --git a/passerelle/contrib/lille_urban_card/models.py b/passerelle/contrib/lille_urban_card/models.py index abb1aaf5..958f110c 100644 --- a/passerelle/contrib/lille_urban_card/models.py +++ b/passerelle/contrib/lille_urban_card/models.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- +# # passerelle - uniform access to multiple data sources and services # Copyright (C) 2019 Entr'ouvert # @@ -62,6 +64,24 @@ class LilleUrbanCard(BaseResource): raise TokenError(response['erreur']) return response['token'] + @endpoint(description=_('List of socioprofessional categories')) + def csp(self, request, *args, **kwargs): + return {'data': [ + {'id': '2', 'text': "Commerçant·e, chef·ffe d’entreprise"}, + {'id': '3', 'text': "Cadre, profession libérale ou intellectuel·le"}, + {'id': '4', 'text': "Profession intermédiaire"}, + {'id': '5', 'text': "Employé·e"}, + {'id': '6', 'text': "Ouvrier·e"}, + {'id': '1', 'text': "Agriculteur·rice"}, + {'id': '8', 'text': "Sans profession"}, + {'id': '81', 'text': "Demandeur·se d’emploi"}, + {'id': '82', 'text': "Enfant de 0 à 11 ans"}, + {'id': '83', 'text': "Enfant de plus de 12 ans"}, + {'id': '84', 'text': "Étudiant·e"}, + {'id': '7', 'text': "Retraité·e"}, + {'id': '99', 'text': "Ne souhaite pas se prononcer"}, + ]} + @endpoint(perm='can_access', description=_('Card Request'), methods=['post']) def card_request(self, request, *args, **kwargs): data = json.loads(request.body) diff --git a/tests/test_lille_urban_card.py b/tests/test_lille_urban_card.py index 29fb6df8..bab31559 100644 --- a/tests/test_lille_urban_card.py +++ b/tests/test_lille_urban_card.py @@ -43,6 +43,11 @@ def test_get_token(mocked_post, app, connector): connector.get_token() +def test_csp(app, connector): + endpoint = utils.generic_endpoint_url('lille-urban-card', 'csp', slug=connector.slug) + resp = app.get(endpoint) + assert resp.json.get('data') + def test_card_request(app, connector): endpoint = utils.generic_endpoint_url('lille-urban-card', 'card_request', slug=connector.slug) with HTTMock(mocked_http):