def test_symbols_found(self) -> None:
     httpretty.register_uri(
         method=httpretty.GET,
         uri="https://api.blockchain.com/v3/exchange/symbols",
         body=
         '{"LTC-BTC": {"id":23}, "XLM-EUR": {"id": 11}, "BTC-GBP": {"id": 35}, "LTC-EUR": {"id": 21}}',
         content_type="text/json",
     )
     assert ["BTC-GBP", "LTC-BTC"] == Cryptocurrency().find_symbols("btc")
 def test_can_not_list(self) -> None:
     httpretty.register_uri(
         method=httpretty.GET,
         uri="https://api.blockchain.com/v3/exchange/symbols",
         body='{"error": "Internal Server Error"}',
         content_type="text/json",
         status=500,
     )
     with raises(CryptoCLIException):
         Cryptocurrency().symbols()
 def test_unknown_symbol(self) -> None:
     httpretty.register_uri(
         method=httpretty.GET,
         uri="https://api.blockchain.com/v3/exchange/tickers/BTC-XXX",
         body='{"error": "Internal Server Error"}',
         content_type="text/json",
         status=500,
     )
     with raises(CryptoCLIException):
         Cryptocurrency().last_trade_price("BTC-XXX")
 def test_known_symbol(self) -> None:
     httpretty.register_uri(
         method=httpretty.GET,
         uri="https://api.blockchain.com/v3/exchange/tickers/BTC-USD",
         body=
         '{"symbol": "BTC-USD", "price_24h": 57400.6, "volume_24h": 1010.255527, "last_trade_price": 54864.4}',
         content_type="text/json",
     )
     assert {
         "symbol": "BTC-USD",
         "last_trade_price": 54864.4
     } == Cryptocurrency().last_trade_price("BTC-USD")
 def test_list(self) -> None:
     httpretty.register_uri(
         method=httpretty.GET,
         uri="https://api.blockchain.com/v3/exchange/symbols",
         body=
         '{"LTC-BTC": {"id":23}, "XLM-EUR": {"id": 11}, "BTC-GBP": {"id": 35}, "LTC-EUR": {"id": 21}}',
         content_type="text/json",
     )
     assert {
         1: "BTC-GBP",
         2: "LTC-BTC",
         3: "LTC-EUR",
         4: "XLM-EUR"
     } == Cryptocurrency().symbols()
Exemplo n.º 6
0
def find_symbols(args: Namespace) -> None:
    try:
        print(Cryptocurrency().find_symbols(args.symbol))
    except CryptoCLIException as ex:
        print(ex)
Exemplo n.º 7
0
def last_trade_price(symbol: str) -> None:
    try:
        print(Cryptocurrency().last_trade_price(symbol))
    except CryptoCLIException as ex:
        print(ex)