예제 #1
0
def test_is_trade_history_loading_enabled(config):
    assert util.is_trade_history_loading_enabled(config) is True
    config[commons_constants.CONFIG_TRADER][commons_constants.CONFIG_LOAD_TRADE_HISTORY] = False
    assert util.is_trade_history_loading_enabled(config) is False
    config.pop(commons_constants.CONFIG_TRADER)
    assert util.is_trade_history_loading_enabled(config) is True
    assert util.is_trade_history_loading_enabled(config, False) is False
예제 #2
0
def test_get_symbols(config):
    assert util.get_symbols(config, True) == FULL_PAIRS_LIST
    # with wildcard currency
    config[commons_constants.CONFIG_CRYPTO_CURRENCIES]["Bitcoin"][commons_constants.CONFIG_CRYPTO_PAIRS] = \
        commons_constants.CONFIG_WILDCARD
    list_without_bitcoin = _filter_by_base(FULL_PAIRS_LIST, "BTC")
    assert util.get_symbols(config, True) == list_without_bitcoin

    # with disabled currency
    config[commons_constants.CONFIG_CRYPTO_CURRENCIES]["Bitcoin"][commons_constants.CONFIG_CRYPTO_PAIRS] = [
        'BTC/USDT',
        'BTC/EUR',
        'BTC/USDC'
    ]
    config[commons_constants.CONFIG_CRYPTO_CURRENCIES]["Bitcoin"][commons_constants.CONFIG_ENABLED_OPTION] = False
    list_without_bitcoin = _filter_by_base(FULL_PAIRS_LIST, "BTC")
    assert util.get_symbols(config, True) == list_without_bitcoin
    assert util.get_symbols(config, False) == FULL_PAIRS_LIST

    # with empty pairs
    config[commons_constants.CONFIG_CRYPTO_CURRENCIES]["Ethereum"][commons_constants.CONFIG_CRYPTO_PAIRS] = []
    assert util.get_symbols(config, False) == _filter_by_base(FULL_PAIRS_LIST, "ETH")

    # with broken config
    config[commons_constants.CONFIG_CRYPTO_CURRENCIES] = []
    assert util.get_symbols(config, False) == []
    config.pop(commons_constants.CONFIG_CRYPTO_CURRENCIES, None)
    assert util.get_symbols(config, False) == []
예제 #3
0
def _test_enabled(config, func, config_key, current_val):
    assert func(config) is current_val
    config[config_key][commons_constants.CONFIG_ENABLED_OPTION] = not current_val
    assert func(config) is not current_val
    config[config_key].pop(commons_constants.CONFIG_ENABLED_OPTION, None)
    assert func(config) is False
    config.pop(config_key, None)
    assert func(config) is False