예제 #1
0
def test_all_json_files():
    all_cryptos = select_cryptocurrencies()
    assert type(all_cryptos) is dict and len(
        all_cryptos) > 0, "all_cryptos Cryptos dictionary is invalid."

    all_etfs = select_etfs()
    assert type(all_etfs) is dict and len(
        all_etfs) > 0, "all_etfs dictionary is invalid."

    all_equities = select_equities()
    assert type(all_equities) is dict and len(
        all_equities) > 0, "all_equities dictionary is invalid."

    all_funds = select_funds()
    assert type(all_funds) is dict and len(
        all_funds) > 0, "all_funds dictionary is invalid."

    all_currencies = select_currencies()
    assert type(all_currencies) is dict and len(
        all_currencies) > 0, "all_currencies dictionary is invalid."

    all_indices = select_indices()
    assert type(all_indices) is dict and len(
        all_indices) > 0, "all_indices dictionary is invalid."

    all_moneymarkets = select_moneymarkets()
    assert type(all_moneymarkets) is dict and len(
        all_moneymarkets) > 0, "all_moneymarkets dictionary is invalid."
예제 #2
0
def test_local_urls():
    crypto = select_cryptocurrencies(
        base_url=rf'{LOCAL_URL}/Cryptocurrencies/', use_local_location=True)
    assert type(crypto) is dict and len(
        crypto) > 0, "crypto dictionary is invalid."

    etfs = select_etfs(base_url=rf'{LOCAL_URL}/ETFs/', use_local_location=True)
    assert type(etfs) is dict and len(etfs) > 0, "etfs dictionary is invalid."

    equity = select_equities(base_url=rf'{LOCAL_URL}/Equities/',
                             use_local_location=True)
    assert type(equity) is dict and len(
        equity) > 0, "equity dictionary is invalid."

    funds = select_funds(base_url=rf'{LOCAL_URL}/Funds/',
                         use_local_location=True)
    assert type(funds) is dict and len(
        funds) > 0, "funds dictionary is invalid."

    currency = select_currencies(base_url=rf'{LOCAL_URL}/Currencies/',
                                 use_local_location=True)
    assert type(currency) is dict and len(
        currency) > 0, "currency dictionary is invalid."

    index = select_indices(base_url=rf'{LOCAL_URL}/Indices/',
                           use_local_location=True)
    assert type(index) is dict and len(
        index) > 0, "index dictionary is invalid."

    moneymarket = select_moneymarkets(base_url=rf'{LOCAL_URL}/Moneymarkets/',
                                      use_local_location=True)
    assert type(moneymarket) is dict and len(
        moneymarket) > 0, "moneymarket dictionary is invalid."
예제 #3
0
def test_random_options():
    random_number = np.random.randint(0, 10)

    crypto_option = show_options('cryptocurrencies')[random_number]
    random_crypto = select_cryptocurrencies(crypto_option)
    assert type(random_crypto) is dict and len(
        random_crypto) > 0, "all_cryptos Cryptos dictionary is invalid."

    currencies_option = show_options('currencies')[random_number]
    random_currency = select_currencies(currencies_option)
    assert type(random_currency) is dict and len(
        random_currency) > 0, "random_currency dictionary is invalid."

    etfs_option = show_options('etfs')[random_number]
    random_etf = select_etfs(etfs_option)
    assert type(random_etf) is dict and len(
        random_etf) > 0, "random_etf dictionary is invalid."

    equity_option_countries = show_options(
        'equities')['countries'][random_number]
    random_equity = select_equities(country=equity_option_countries)
    assert type(random_equity) is dict and len(
        random_equity) > 0, "random_equity (countries) dictionary is invalid."

    equity_option_sectors = show_options('equities')['sectors'][random_number]
    random_equity = select_equities(sector=equity_option_sectors)
    assert type(random_equity) is dict and len(
        random_equity) > 0, "random_equity (sectors) dictionary is invalid."

    equity_option_industries = show_options(
        'equities')['industries'][random_number]
    random_equity = select_equities(industry=equity_option_industries)
    assert type(random_equity) is dict and len(
        random_equity) > 0, "random_equity (industries) dictionary is invalid."

    random_equity = select_equities(country='United States',
                                    sector='Basic Materials')
    assert type(random_equity) is dict and len(random_equity) > 0, (
        "random_equity (country + sector) "
        "dictionary is invalid.")

    random_equity = select_equities(country='United States',
                                    industry='Waste Management')
    assert type(random_equity) is dict and len(random_equity) > 0, (
        "random_equity (country + industry) "
        "dictionary is invalid.")

    random_equity = select_equities(country='United States',
                                    sector='Consumer Cyclical',
                                    industry='Auto Parts')
    assert type(random_equity) is dict and len(random_equity) > 0, (
        "random_equity (country + sector + industry) "
        "dictionary is invalid.")

    funds_option = show_options('funds')[random_number]
    random_fund = select_funds(funds_option)
    assert type(random_fund) is dict and len(
        random_fund) > 0, "random_fund dictionary is invalid."

    random_index = select_indices('us_market')
    assert type(random_index) is dict and len(
        random_index) > 0, "random_index dictionary is invalid."

    random_moneymarket = select_moneymarkets('us_market')
    assert type(random_moneymarket) is dict and len(
        random_moneymarket) > 0, "random_moneymarket dictionary is invalid."
def test_local_urls_specific():
    crypto = select_cryptocurrencies(
        cryptocurrency='BTC',
        base_url=rf'{LOCAL_URL}/Cryptocurrencies/',
        use_local_location=True)
    assert type(crypto) is dict and len(
        crypto) > 0, "crypto BTC dictionary is invalid."

    etfs = select_etfs(category='China Region',
                       base_url=rf'{LOCAL_URL}/ETFs/',
                       use_local_location=True,
                       exclude_exchanges=False)
    assert type(etfs) is dict and len(
        etfs) > 0, "etfs China Region dictionary is invalid."

    equity = select_equities(country='Canada',
                             base_url=rf'{LOCAL_URL}/Equities/',
                             use_local_location=True,
                             exclude_exchanges=False)
    assert type(equity) is dict and len(
        equity) > 0, "equity Canada dictionary is invalid."

    equity = select_equities(sector='Energy',
                             base_url=rf'{LOCAL_URL}/Equities/',
                             use_local_location=True,
                             exclude_exchanges=False)
    assert type(equity) is dict and len(
        equity) > 0, "equity Energy dictionary is invalid."

    equity = select_equities(industry='Biotechnology',
                             base_url=rf'{LOCAL_URL}/Equities/',
                             use_local_location=True,
                             exclude_exchanges=False)
    assert type(equity) is dict and len(
        equity) > 0, "equity Biotechnology dictionary is invalid."

    equity = select_equities(country='United States',
                             sector='Financial',
                             base_url=rf'{LOCAL_URL}/Equities/',
                             use_local_location=True,
                             exclude_exchanges=False)
    assert type(equity) is dict and len(
        equity) > 0, "equity United States + Financial dictionary is invalid."

    equity = select_equities(country='Slovakia',
                             industry='Resorts & Casinos',
                             base_url=rf'{LOCAL_URL}/Equities/',
                             use_local_location=True,
                             exclude_exchanges=False)
    assert type(equity) is dict and len(
        equity
    ) > 0, "equity Slovakia + Resorts & Casinos dictionary is invalid."

    with pytest.raises(ValueError):
        equity = select_equities(country='Slovakia',
                                 industry='Resorts & Casinos',
                                 base_url=rf'{LOCAL_URL}/Equities/',
                                 use_local_location=True,
                                 exclude_exchanges=True)

    equity = select_equities(country='Panama',
                             sector='Industrials',
                             industry='Airlines',
                             base_url=rf'{LOCAL_URL}/Equities/',
                             use_local_location=True,
                             exclude_exchanges=False)
    assert type(equity) is dict and len(
        equity) > 0, "equity Panama + Industrials + Airlines is invalid."

    funds = select_funds(category='Alt - Currency',
                         base_url=rf'{LOCAL_URL}/Funds/',
                         use_local_location=True,
                         exclude_exchanges=False)
    assert type(funds) is dict and len(
        funds) > 0, "funds Alt - Currency dictionary is invalid."

    currency = select_currencies(currency='EUR',
                                 base_url=rf'{LOCAL_URL}/Currencies/',
                                 use_local_location=True)
    assert type(currency) is dict and len(
        currency) > 0, "currency EUR dictionary is invalid."

    index = select_indices(market='cn_market',
                           base_url=rf'{LOCAL_URL}/Indices/',
                           use_local_location=True,
                           exclude_exchanges=False)
    assert type(index) is dict and len(
        index) > 0, "index cn_market dictionary is invalid."

    moneymarket = select_moneymarkets(market='us_market',
                                      base_url=rf'{LOCAL_URL}/Moneymarkets/',
                                      use_local_location=True,
                                      exclude_exchanges=False)
    assert type(moneymarket) is dict and len(
        moneymarket) > 0, "moneymarket us_market dictionary is invalid."
예제 #5
0
from Searcher.json_picker import (select_cryptocurrencies, select_equities,
                                  select_moneymarkets, select_etfs,
                                  select_funds, select_indices,
                                  select_currencies)
from Searcher.json_options import search_products
import pytest

# Initialize data
all_cryptos = select_cryptocurrencies()
all_etfs = select_etfs()
all_equities = select_equities()
all_funds = select_funds()
all_currencies = select_currencies()
all_indices = select_indices()
all_moneymarkets = select_moneymarkets()


def test_product_search():
    cryptos = search_products(all_cryptos, 'Bitcoin')
    assert type(cryptos) is dict and len(cryptos) > 0, 'cryptos is invalid'

    etfs = search_products(all_etfs, 'technology')
    assert type(etfs) is dict and len(etfs) > 0, 'etfs is invalid'

    equities = search_products(all_equities, 'technology')
    assert type(equities) is dict and len(equities) > 0, 'equities is invalid'

    equities = search_products(all_equities, 'APPLE', search='long_name')
    assert type(equities) is dict and len(
        equities) > 0, 'equities (APPLE) is invalid'