How to use the mercadopago.errors.NotFoundError function in mercadopago

To help you get started, we’ve selected a few mercadopago examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github federicobond / pymercadopago / tests / test_client.py View on Github external
res = expect(c, 'GET', '/payments')
    res.status_code = 400

    with pytest.raises(errors.BadRequestError):
        c.get('/payments')

    res = expect(c, 'GET', '/payments')
    res.status_code = 401

    with pytest.raises(errors.AuthenticationError):
        c.get('/payments')

    res = expect(c, 'GET', '/payments')
    res.status_code = 404

    with pytest.raises(errors.NotFoundError):
        c.get('/payments')

    res = expect(c, 'GET', '/payments')
    res.status_code = 500

    with pytest.raises(errors.Error):
        c.get('/payments')
github federicobond / pymercadopago / mercadopago / client.py View on Github external
def _handle_request_error(self, error):
        if isinstance(error, requests.HTTPError):
            status = error.response.status_code

            if status == 400:
                raise errors.BadRequestError(error)
            elif status == 401:
                raise errors.AuthenticationError(error)
            elif status == 404:
                raise errors.NotFoundError(error)

        raise errors.Error(error)