Here are the examples of the python api requests.exceptions.HTTPError taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
145 Examples
3
View Complete Implementation : test_api.py
Copyright MIT License
Author : man-c
Copyright MIT License
Author : man-c
@responses.activate
def test_failed_get_global(self):
# Arrange
responses.add(responses.GET, 'https://api.coingecko.com/api/v3/global',
status = 404)
exception = HTTPError("HTTP Error")
# Act astert
with pytest.raises(HTTPError) as HE:
CoinGeckoAPI().get_global()
3
View Complete Implementation : test_api.py
Copyright MIT License
Author : man-c
Copyright MIT License
Author : man-c
@responses.activate
def test_failed_get_exchanges_by_id(self):
# Arrange
responses.add(responses.GET, 'https://api.coingecko.com/api/v3/exchanges/bitforex',
status = 404)
exception = HTTPError("HTTP Error")
# Act astert
with pytest.raises(HTTPError) as HE:
CoinGeckoAPI().get_exchanges_by_id('bitforex')
3
View Complete Implementation : imports.py
Copyright MIT License
Author : cmberryau
Copyright MIT License
Author : cmberryau
def get_import(self, import_id, group_id=None):
if group_id is None:
groups_part = '/'
else:
groups_part = f'/{self.groups_snippet}/{group_id}/'
url = f'{self.base_url}{groups_part}{self.imports_snippet}/{import_id}'
headers = self.client.auth_header
response = requests.get(url, headers=headers)
# 200 OK
if response.status_code == 200:
import_object = self.import_from_response(response)
else:
raise HTTPError(response, f"Get import failed with status code: {response.json()}")
return import_object
3
View Complete Implementation : test_api.py
Copyright MIT License
Author : man-c
Copyright MIT License
Author : man-c
@responses.activate
def test_failed_get_exchanges_list(self):
# Arrange
responses.add(responses.GET, 'https://api.coingecko.com/api/v3/exchanges',
status = 404)
exception = HTTPError("HTTP Error")
# Act astert
with pytest.raises(HTTPError) as HE:
CoinGeckoAPI().get_exchanges_list()
3
View Complete Implementation : test_api.py
Copyright MIT License
Author : man-c
Copyright MIT License
Author : man-c
@responses.activate
def test_failed_get_coins_list(self):
# Arrange
responses.add(responses.GET, 'https://api.coingecko.com/api/v3/coins/list',
status = 404)
exception = HTTPError("HTTP Error")
# Act
with pytest.raises(HTTPError) as HE:
CoinGeckoAPI().get_coins_list()
3
View Complete Implementation : test_api.py
Copyright MIT License
Author : man-c
Copyright MIT License
Author : man-c
@responses.activate
def test_failed_get_coin_info_from_contract_address_by_id(self):
# Arrange
responses.add(responses.GET, 'https://api.coingecko.com/api/v3/coins/ethereum/contract/0x0D8775F648430679A709E98d2b0Cb6250d2887EF',
status = 404)
exception = HTTPError("HTTP Error")
# Act astert
with pytest.raises(HTTPError) as HE:
CoinGeckoAPI().get_coin_info_from_contract_address_by_id(id='ethereum',contract_address='0x0D8775F648430679A709E98d2b0Cb6250d2887EF')
3
View Complete Implementation : test_api.py
Copyright MIT License
Author : man-c
Copyright MIT License
Author : man-c
@responses.activate
def test_failed_get_coin_market_chart_by_id(self):
# Arrange
responses.add(responses.GET, 'https://api.coingecko.com/api/v3/coins/bitcoin/market_chart?vs_currency=usd&days=1',
status = 404)
exception = HTTPError("HTTP Error")
# Act astert
with pytest.raises(HTTPError) as HE:
CoinGeckoAPI().get_coin_market_chart_by_id('bitcoin', 'usd', 1)
3
View Complete Implementation : test_api.py
Copyright MIT License
Author : man-c
Copyright MIT License
Author : man-c
@responses.activate
def test_failed_get_coin_ticker_by_id(self):
# Arrange
responses.add(responses.GET, 'https://api.coingecko.com/api/v3/coins/bitcoin/tickers',
status = 404)
exception = HTTPError("HTTP Error")
# Act astert
with pytest.raises(HTTPError) as HE:
CoinGeckoAPI().get_coin_ticker_by_id('bitcoin')
3
View Complete Implementation : test_api.py
Copyright MIT License
Author : man-c
Copyright MIT License
Author : man-c
@responses.activate
def test_failed_get_price(self):
# Arrange
responses.add(responses.GET, 'https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd',
status = 404)
exception = HTTPError("HTTP Error")
# Act astert
with pytest.raises(HTTPError) as HE:
CoinGeckoAPI().get_price('bitcoin', 'usd')
3
View Complete Implementation : test_api.py
Copyright MIT License
Author : man-c
Copyright MIT License
Author : man-c
@responses.activate
def test_failed_get_coins(self):
# Arrange
responses.add(responses.GET, 'https://api.coingecko.com/api/v3/coins',
status = 404)
exception = HTTPError("HTTP Error")
# Act astert
with pytest.raises(HTTPError) as HE:
CoinGeckoAPI().get_coins()