api_entreprise: use v3 in extraits_rcs endpoint (#70610)

This commit is contained in:
Emmanuel Cazenave 2022-10-24 15:41:12 +02:00
parent f2d3c24c0a
commit 4df3791e52
2 changed files with 18 additions and 14 deletions

View File

@ -290,7 +290,8 @@ class APIEntreprise(BaseResource):
},
)
def extraits_rcs(self, request, siren, **kwargs):
return self.get('v2/extraits_rcs_infogreffe/%s/' % siren, **kwargs)
raw_data = self.get('v3/infogreffe/rcs/unites_legales/%s/extrait_kbis' % siren, raw=True, **kwargs)
return {'data': raw_data['data']}
@endpoint(
perm='can_access',

View File

@ -143,18 +143,20 @@ ENTREPRISES_RESPONSE = {
}
EXTRAITS_RCS_RESPONSE = {
"siren": "418166096",
"date_immatriculation": "1998-03-27",
"date_immatriculation_timestamp": 890953200,
"date_extrait": "21 AVRIL 2017",
"observations": [
{
"date": "2000-02-23",
"date_timestamp": 951260400,
"numero": "12197",
"libelle": " LA SOCIETE NE CONSERVE AUCUNE ACTIVITE A SON ANCIEN SIEGE ",
}
],
"data": {
"siren": "418166096",
"date_immatriculation": "1998-03-27",
"date_immatriculation_timestamp": 890953200,
"date_extrait": "21 AVRIL 2017",
"observations": [
{
"date": "2000-02-23",
"date_timestamp": 951260400,
"numero": "12197",
"libelle": " LA SOCIETE NE CONSERVE AUCUNE ACTIVITE A SON ANCIEN SIEGE ",
}
],
}
}
ASSOCIATIONS_RESPONSE = {
@ -479,7 +481,8 @@ def test_associations_last_document_of_type_endpoint(app, resource):
def test_extraits_rcs(app, resource):
with responses.RequestsMock() as rsps:
rsps.get(
'https://entreprise.api.gouv.fr/v2/extraits_rcs_infogreffe/443170139/', json=EXTRAITS_RCS_RESPONSE
'https://entreprise.api.gouv.fr/v3/infogreffe/rcs/unites_legales/443170139/extrait_kbis',
json=EXTRAITS_RCS_RESPONSE,
)
response = app.get('/api-entreprise/test/extraits_rcs/443170139/', params=REQUEST_PARAMS)
assert 'data' in response.json