Ejemplo n.º 1
0
def test_request_format_fallback_is_csv(execute_request):

    api_csv = ApiInsee(key=conf.SIRENE_API_CONSUMER_KEY,
                       secret=conf.SIRENE_API_CONSUMER_SECRET,
                       format='csv')

    request = api_csv.siret('39860733300059')
    assert request.header['Accept'] == 'text/csv'
Ejemplo n.º 2
0
def call_insee_api(siret):

    api_insee = ApiInsee(key=settings.API_INSEE_KEY,
                         secret=settings.API_INSEE_SECRET)

    try:
        data = api_insee.siret(siret).get()
    except urllib.error.HTTPError as err:
        logger.error(
            "HTTP Error `%s` while calling Sirene - V3 API for SIRET %s",
            err.code, siret)
        return None

    return data