def test_http_other_invalid_response(mock_get): http_client = DefaultHttpClient(API_URL) with pytest.raises(TwelveDataError): http_client.get('/fake_url') mock_get.assert_called_once_with(API_URL + '/fake_url', timeout=30, params={'source': 'python'})
def test_http_bad_request_error_response(mock_get): http_client = DefaultHttpClient(API_URL) with pytest.raises(BadRequestError): http_client.get('/fake_url') mock_get.assert_called_once_with(API_URL + '/fake_url', timeout=30, params={'source': 'python'})
def test_http_invalid_api_key_response_in_json(mock_get): http_client = DefaultHttpClient(API_URL) with pytest.raises(InvalidApiKeyError) as err: http_client.get('/fake_url') assert str(err) == 'error message' mock_get.assert_called_once_with(API_URL + '/fake_url', timeout=30, params={'source': 'python'})