Projet

Général

Profil

0005-api_entreprise-use-v3-in-associations-endpoint-70610.patch

Emmanuel Cazenave, 25 octobre 2022 18:13

Télécharger (2,38 ko)

Voir les différences:

Subject: [PATCH 5/7] api_entreprise: use v3 in associations endpoint (#70610)

 passerelle/apps/api_entreprise/models.py | 6 +++++-
 tests/test_api_entreprise.py             | 9 ++++++---
 2 files changed, 11 insertions(+), 4 deletions(-)
passerelle/apps/api_entreprise/models.py
306 306
        },
307 307
    )
308 308
    def associations(self, request, association_id, **kwargs):
309
        return self.get('v2/associations/%s/' % association_id, **kwargs)
309
        raw_data = self.get('v3/ministere_interieur/rna/associations/%s' % association_id, raw=True, **kwargs)
310
        res = {}
311
        res['association'] = raw_data['data']
312
        res['association']['id'] = res['association']['rna_id']
313
        return {'data': res}
310 314

  
311 315
    @endpoint(
312 316
        perm='can_access',
tests/test_api_entreprise.py
160 160
}
161 161

  
162 162
ASSOCIATIONS_RESPONSE = {
163
    "association": {
164
        "id": "W751135389",
163
    "data": {
164
        "rna_id": "W751135389",
165 165
        "titre": "ALLIANCE DU COEUR: UNION NATIONALE DES FEDERATIONS ET ASSOCIATIONS DE MALADES CARDIOVASCULAIRES",
166 166
        "objet": "information, soutien, solidarité et accompagnement psycho médico social des personnes malades cardiovasculaires et de leurs proches...",
167 167
        "siret": "42135938100025",
......
423 423

  
424 424
def test_associations_endpoint(app, resource):
425 425
    with responses.RequestsMock() as rsps:
426
        rsps.get('https://entreprise.api.gouv.fr/v2/associations/443170139/', json=ASSOCIATIONS_RESPONSE)
426
        rsps.get(
427
            'https://entreprise.api.gouv.fr/v3/ministere_interieur/rna/associations/443170139',
428
            json=ASSOCIATIONS_RESPONSE,
429
        )
427 430
        response = app.get('/api-entreprise/test/associations/443170139/', params=REQUEST_PARAMS)
428 431
    assert 'data' in response.json
429 432
    data = response.json['data']
430
-