This test was testing for a 500 status, but this status
is actually a bug in the API (as it's due to an invalid
request), and the API should actually return a 400 status.
To make this test handle both situations, relax the test
to accept either a 4xx or 5xx status.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
`create_api_error_from_http_exception()` is never tested in the original code
and will fail miserably when fed with empty `HTTPError` object
see fixes in requests for this behaviour: https://github.com/requests/requests/pull/3179
Signed-off-by: Constantine Peresypkin <pconstantine@gmail.com>
requests.Response objects evaluate as falsy when the status_code
attribute is in the 400-500 range. Therefore we are assured that
prior to this change, APIError would show `is_server_error() == False`
when generated with a 500-level response and `is_client_error() == False`
when generated with a 400-level response. This is not desirable.
Added some seemingly dry (not DRY) unit tests to ensure nothing silly
slips back in here.
Signed-off-by: alex-dr <alex@datarobot.com>