Esempio n. 1
0
    def setUpClass(cls):
        cls.datatable = {'datatable': DatatableFactory.build(
            vendor_code='ZACKS',
            datatable_code='FC')}

        cls.error_response = httpretty.Response(
            body=json.dumps({'quandl_error': {'code': 'QEMx01',
                                              'message': 'something went wrong'}}),
            status=500)
        cls.success_response = httpretty.Response(body=json.dumps(cls.datatable), status=200)
Esempio n. 2
0
    def test_quandl_exceptions(self):
        quandl_errors = [('QELx04', 429, LimitExceededError),
                         ('QEMx01', 500, InternalServerError),
                         ('QEAx01', 400, AuthenticationError),
                         ('QEPx02', 403, ForbiddenError),
                         ('QESx03', 422, InvalidRequestError),
                         ('QECx05', 404, NotFoundError),
                         ('QEXx01', 503, ServiceUnavailableError),
                         ('QEZx02', 400, QuandlError)]

        httpretty.register_uri(httpretty.GET,
                               "https://www.quandl.com/api/v3/databases",
                               responses=[
                                   httpretty.Response(body=json.dumps({
                                       'quandl_error': {
                                           'code': x[0],
                                           'message': 'something went wrong'
                                       }
                                   }),
                                                      status=x[1])
                                   for x in quandl_errors
                               ])

        for expected_error in quandl_errors:
            self.assertRaises(expected_error[2],
                              lambda: Connection.request('get', 'databases'))