import os
import sys

root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))))
sys.path.append(root)

# ----------------------------------------------------------------------------

# PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
# https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code

# ----------------------------------------------------------------------------
# -*- coding: utf-8 -*-

from ccxt.test.exchange.base import test_last_price  # noqa E402
from ccxt.test.exchange.base import test_shared_methods  # noqa E402

async def test_fetch_last_prices(exchange, skipped_properties, symbol):
    method = 'fetchLastprices'
    # log ('fetching all tickers at once...')
    response = None
    checked_symbol = None
    try:
        response = await exchange.fetch_last_prices()
    except Exception as e:
        response = await exchange.fetch_last_prices([symbol])
        checked_symbol = symbol
    assert isinstance(response, dict), exchange.id + ' ' + method + ' ' + checked_symbol + ' must return an object. ' + exchange.json(response)
    values = list(response.values())
    test_shared_methods.assert_non_emtpy_array(exchange, skipped_properties, method, values, checked_symbol)
    at_least_one_passed = False
    for i in range(0, len(values)):
        # todo: symbol check here
        test_last_price(exchange, skipped_properties, method, values[i], checked_symbol)
        at_least_one_passed = at_least_one_passed or (exchange.safe_number(values[i], 'price') > 0)
    assert at_least_one_passed, exchange.id + ' ' + method + ' ' + checked_symbol + ' at least one symbol should pass the test'
    return True
