async def test_get_average_of_trades_last_minute():
    exchange = Exchange(CcxtExchangeWithSomeTrades())

    res = await exchange.get_average_of_trades_last_minute(coin=COIN,
                                                           market=MARKET)

    assert CcxtExchangeWithSomeTrades.TRADES_AVERAGE == res
async def test_get_average_of_trades_last_minute__no_trades__returns_none():
    exchange = Exchange(CcxtExchangeNoTrades())

    res = await exchange.get_average_of_trades_last_minute(coin=COIN,
                                                           market=MARKET)

    assert res is None
async def test_get_last_minute_trades_average_or_last_trade__no_trades_from_last_minute__returns_last_trade(
):
    exchange = Exchange(CcxtExchangeNoTradesFromLastMinute())

    res = await exchange.get_last_minute_trades_average_or_last_trade(
        coin=COIN, market=MARKET)

    assert CcxtExchangeNoTradesFromLastMinute.LAST_TRADE_PRICE == res
async def test_get_volatility__no_trades__returns_0():
    exchange = Exchange(CcxtExchangeNoTrades())

    res = await exchange.get_volatility(coin=COIN,
                                        market=MARKET,
                                        time_period_in_minutes=1)

    assert 0 == res
async def test_get_volatility__exception_raised__returns_none():
    exchange = Exchange(CcxtExchangeThatRaisesException())

    res = await exchange.get_volatility(coin=COIN,
                                        market=MARKET,
                                        time_period_in_minutes=1)

    assert res is None
async def test_get_volatility__some_trades__returns_value():
    exchange = Exchange(CcxtExchangeWithSomeTrades())

    res = await exchange.get_volatility(coin=COIN,
                                        market=MARKET,
                                        time_period_in_minutes=1)

    assert CcxtExchangeWithSomeTrades.TRADES_VOLATILITY == res
async def test_get_last_minute_trades_average_or_last_trade__exception_raised__returns_none(
):
    exchange = Exchange(CcxtExchangeThatRaisesException())

    res = await exchange.get_last_minute_trades_average_or_last_trade(
        coin=COIN, market=MARKET)

    assert res is None
async def test_get_last_trade_price__no_trades__returns_none():
    exchange = Exchange(CcxtExchangeNoTrades())

    res = await exchange.get_last_trade_price(coin=COIN, market=MARKET)

    assert res is None
async def test_get_last_trade_price():
    exchange = Exchange(CcxtExchangeWithSomeTrades())

    res = await exchange.get_last_trade_price(coin=COIN, market=MARKET)

    assert 100 == res