updating unit test to remove assert_list_equal
This commit is contained in:
commit
21a7a117fa
188
freqtrade/tests/exchange/test_exchange.py
Normal file
188
freqtrade/tests/exchange/test_exchange.py
Normal file
@ -0,0 +1,188 @@
|
|||||||
|
# pragma pylint: disable=missing-docstring,C0103
|
||||||
|
from unittest.mock import MagicMock
|
||||||
|
from requests.exceptions import RequestException
|
||||||
|
from random import randint
|
||||||
|
import logging
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from freqtrade import OperationalException
|
||||||
|
from freqtrade.exchange import init, validate_pairs, buy, sell, get_balance, get_balances, \
|
||||||
|
get_ticker, cancel_order, get_name, get_fee
|
||||||
|
|
||||||
|
|
||||||
|
def test_init(default_conf, mocker, caplog):
|
||||||
|
mocker.patch('freqtrade.exchange.validate_pairs', side_effect=lambda s: True)
|
||||||
|
init(config=default_conf)
|
||||||
|
assert ('freqtrade.exchange',
|
||||||
|
logging.INFO,
|
||||||
|
'Instance is running with dry_run enabled'
|
||||||
|
) in caplog.record_tuples
|
||||||
|
|
||||||
|
|
||||||
|
def test_init_exception(default_conf, mocker):
|
||||||
|
default_conf['exchange']['name'] = 'wrong_exchange_name'
|
||||||
|
|
||||||
|
with pytest.raises(
|
||||||
|
OperationalException,
|
||||||
|
match='Exchange {} is not supported'.format(default_conf['exchange']['name'])):
|
||||||
|
init(config=default_conf)
|
||||||
|
|
||||||
|
|
||||||
|
def test_validate_pairs(default_conf, mocker):
|
||||||
|
api_mock = MagicMock()
|
||||||
|
api_mock.get_markets = MagicMock(return_value=[
|
||||||
|
'BTC_ETH', 'BTC_TKN', 'BTC_TRST', 'BTC_SWT', 'BTC_BCC',
|
||||||
|
])
|
||||||
|
mocker.patch('freqtrade.exchange._API', api_mock)
|
||||||
|
mocker.patch.dict('freqtrade.exchange._CONF', default_conf)
|
||||||
|
validate_pairs(default_conf['exchange']['pair_whitelist'])
|
||||||
|
|
||||||
|
|
||||||
|
def test_validate_pairs_not_available(default_conf, mocker):
|
||||||
|
api_mock = MagicMock()
|
||||||
|
api_mock.get_markets = MagicMock(return_value=[])
|
||||||
|
mocker.patch('freqtrade.exchange._API', api_mock)
|
||||||
|
mocker.patch.dict('freqtrade.exchange._CONF', default_conf)
|
||||||
|
with pytest.raises(OperationalException, match=r'not available'):
|
||||||
|
validate_pairs(default_conf['exchange']['pair_whitelist'])
|
||||||
|
|
||||||
|
|
||||||
|
def test_validate_pairs_not_compatible(default_conf, mocker):
|
||||||
|
api_mock = MagicMock()
|
||||||
|
api_mock.get_markets = MagicMock(return_value=['BTC_ETH', 'BTC_TKN', 'BTC_TRST', 'BTC_SWT'])
|
||||||
|
default_conf['stake_currency'] = 'ETH'
|
||||||
|
mocker.patch('freqtrade.exchange._API', api_mock)
|
||||||
|
mocker.patch.dict('freqtrade.exchange._CONF', default_conf)
|
||||||
|
with pytest.raises(OperationalException, match=r'not compatible'):
|
||||||
|
validate_pairs(default_conf['exchange']['pair_whitelist'])
|
||||||
|
|
||||||
|
|
||||||
|
def test_validate_pairs_exception(default_conf, mocker, caplog):
|
||||||
|
api_mock = MagicMock()
|
||||||
|
api_mock.get_markets = MagicMock(side_effect=RequestException())
|
||||||
|
mocker.patch('freqtrade.exchange._API', api_mock)
|
||||||
|
|
||||||
|
# with pytest.raises(RequestException, match=r'Unable to validate pairs'):
|
||||||
|
validate_pairs(default_conf['exchange']['pair_whitelist'])
|
||||||
|
assert ('freqtrade.exchange',
|
||||||
|
logging.WARNING,
|
||||||
|
'Unable to validate pairs (assuming they are correct). Reason: '
|
||||||
|
) in caplog.record_tuples
|
||||||
|
|
||||||
|
|
||||||
|
def test_buy_dry_run(default_conf, mocker):
|
||||||
|
default_conf['dry_run'] = True
|
||||||
|
mocker.patch.dict('freqtrade.exchange._CONF', default_conf)
|
||||||
|
|
||||||
|
assert 'dry_run_buy_' in buy(pair='BTC_ETH', rate=200, amount=1)
|
||||||
|
|
||||||
|
|
||||||
|
def test_buy_prod(default_conf, mocker):
|
||||||
|
api_mock = MagicMock()
|
||||||
|
api_mock.buy = MagicMock(return_value='dry_run_buy_{}'.format(randint(0, 10**6)))
|
||||||
|
mocker.patch('freqtrade.exchange._API', api_mock)
|
||||||
|
|
||||||
|
default_conf['dry_run'] = False
|
||||||
|
mocker.patch.dict('freqtrade.exchange._CONF', default_conf)
|
||||||
|
|
||||||
|
assert 'dry_run_buy_' in buy(pair='BTC_ETH', rate=200, amount=1)
|
||||||
|
|
||||||
|
|
||||||
|
def test_sell_dry_run(default_conf, mocker):
|
||||||
|
default_conf['dry_run'] = True
|
||||||
|
mocker.patch.dict('freqtrade.exchange._CONF', default_conf)
|
||||||
|
|
||||||
|
assert 'dry_run_sell_' in sell(pair='BTC_ETH', rate=200, amount=1)
|
||||||
|
|
||||||
|
|
||||||
|
def test_sell_prod(default_conf, mocker):
|
||||||
|
api_mock = MagicMock()
|
||||||
|
api_mock.sell = MagicMock(return_value='dry_run_sell_{}'.format(randint(0, 10**6)))
|
||||||
|
mocker.patch('freqtrade.exchange._API', api_mock)
|
||||||
|
|
||||||
|
default_conf['dry_run'] = False
|
||||||
|
mocker.patch.dict('freqtrade.exchange._CONF', default_conf)
|
||||||
|
|
||||||
|
assert 'dry_run_sell_' in sell(pair='BTC_ETH', rate=200, amount=1)
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_balance_dry_run(default_conf, mocker):
|
||||||
|
default_conf['dry_run'] = True
|
||||||
|
mocker.patch.dict('freqtrade.exchange._CONF', default_conf)
|
||||||
|
|
||||||
|
assert get_balance(currency='BTC') == 999.9
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_balance_prod(default_conf, mocker):
|
||||||
|
api_mock = MagicMock()
|
||||||
|
api_mock.get_balance = MagicMock(return_value=123.4)
|
||||||
|
mocker.patch('freqtrade.exchange._API', api_mock)
|
||||||
|
|
||||||
|
default_conf['dry_run'] = False
|
||||||
|
mocker.patch.dict('freqtrade.exchange._CONF', default_conf)
|
||||||
|
|
||||||
|
assert get_balance(currency='BTC') == 123.4
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_balances_dry_run(default_conf, mocker):
|
||||||
|
default_conf['dry_run'] = True
|
||||||
|
mocker.patch.dict('freqtrade.exchange._CONF', default_conf)
|
||||||
|
|
||||||
|
assert get_balances() == []
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_balances_prod(default_conf, mocker):
|
||||||
|
balance_item = {
|
||||||
|
'Currency': '1ST',
|
||||||
|
'Balance': 10.0,
|
||||||
|
'Available': 10.0,
|
||||||
|
'Pending': 0.0,
|
||||||
|
'CryptoAddress': None
|
||||||
|
}
|
||||||
|
|
||||||
|
api_mock = MagicMock()
|
||||||
|
api_mock.get_balances = MagicMock(return_value=[balance_item, balance_item, balance_item])
|
||||||
|
mocker.patch('freqtrade.exchange._API', api_mock)
|
||||||
|
|
||||||
|
default_conf['dry_run'] = False
|
||||||
|
mocker.patch.dict('freqtrade.exchange._CONF', default_conf)
|
||||||
|
|
||||||
|
assert len(get_balances()) == 3
|
||||||
|
assert get_balances()[0]['Currency'] == '1ST'
|
||||||
|
assert get_balances()[0]['Balance'] == 10.0
|
||||||
|
assert get_balances()[0]['Available'] == 10.0
|
||||||
|
assert get_balances()[0]['Pending'] == 0.0
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_ticker(mocker, ticker):
|
||||||
|
|
||||||
|
api_mock = MagicMock()
|
||||||
|
api_mock.get_ticker = MagicMock(return_value=ticker())
|
||||||
|
mocker.patch('freqtrade.exchange._API', api_mock)
|
||||||
|
|
||||||
|
ticker = get_ticker(pair='BTC_ETH')
|
||||||
|
assert ticker['bid'] == 0.00001098
|
||||||
|
assert ticker['ask'] == 0.00001099
|
||||||
|
assert ticker['bid'] == 0.00001098
|
||||||
|
|
||||||
|
|
||||||
|
def test_cancel_order_dry_run(default_conf, mocker):
|
||||||
|
default_conf['dry_run'] = True
|
||||||
|
mocker.patch.dict('freqtrade.exchange._CONF', default_conf)
|
||||||
|
|
||||||
|
assert cancel_order(order_id='123') is None
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_name(default_conf, mocker):
|
||||||
|
mocker.patch('freqtrade.exchange.validate_pairs', side_effect=lambda s: True)
|
||||||
|
default_conf['exchange']['name'] = 'bittrex'
|
||||||
|
init(default_conf)
|
||||||
|
|
||||||
|
assert get_name() == 'Bittrex'
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_fee(default_conf, mocker):
|
||||||
|
mocker.patch('freqtrade.exchange.validate_pairs', side_effect=lambda s: True)
|
||||||
|
init(default_conf)
|
||||||
|
|
||||||
|
assert get_fee() == 0.0025
|
@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
import math
|
import math
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
# from unittest.mock import MagicMock
|
||||||
from freqtrade import exchange, optimize
|
from freqtrade import exchange, optimize
|
||||||
from freqtrade.exchange import Bittrex
|
from freqtrade.exchange import Bittrex
|
||||||
from freqtrade.optimize.backtesting import backtest, generate_text_table, get_timeframe
|
from freqtrade.optimize.backtesting import backtest, generate_text_table, get_timeframe
|
||||||
|
# import freqtrade.optimize.backtesting as backtesting
|
||||||
|
|
||||||
|
|
||||||
def test_generate_text_table():
|
def test_generate_text_table():
|
||||||
@ -49,77 +51,53 @@ def test_backtest_1min_ticker_interval(default_conf, mocker):
|
|||||||
assert not results.empty
|
assert not results.empty
|
||||||
|
|
||||||
|
|
||||||
def trim_dataframe(df, num):
|
def trim_dictlist(dl, num):
|
||||||
new = dict()
|
new = {}
|
||||||
for pair, pair_data in df.items():
|
for pair, pair_data in dl.items():
|
||||||
new[pair] = pair_data[-num:] # last 50 rows
|
# Can't figure out why -num wont work
|
||||||
|
new[pair] = pair_data[num:]
|
||||||
return new
|
return new
|
||||||
|
|
||||||
|
|
||||||
def load_data_test(what):
|
def load_data_test(what):
|
||||||
data = optimize.load_data(ticker_interval=1, pairs=['BTC_UNITEST'])
|
data = optimize.load_data(ticker_interval=1, pairs=['BTC_UNITEST'])
|
||||||
data = trim_dataframe(data, -40)
|
data = trim_dictlist(data, -100)
|
||||||
pair = data['BTC_UNITEST']
|
pair = data['BTC_UNITEST']
|
||||||
|
datalen = len(pair)
|
||||||
# Depending on the what parameter we now adjust the
|
# Depending on the what parameter we now adjust the
|
||||||
# loaded data:
|
# loaded data looks:
|
||||||
# pair :: [{'O': 0.123, 'H': 0.123, 'L': 0.123,
|
# pair :: [{'O': 0.123, 'H': 0.123, 'L': 0.123,
|
||||||
# 'C': 0.123, 'V': 123.123,
|
# 'C': 0.123, 'V': 123.123,
|
||||||
# 'T': '2017-11-04T23:02:00', 'BV': 0.123}]
|
# 'T': '2017-11-04T23:02:00', 'BV': 0.123}]
|
||||||
|
base = 0.001
|
||||||
if what == 'raise':
|
if what == 'raise':
|
||||||
o = 0.001
|
return {'BTC_UNITEST':
|
||||||
h = 0.001
|
[{'T': pair[x]['T'], # Keep old dates
|
||||||
ll = 0.001
|
'V': pair[x]['V'], # Keep old volume
|
||||||
c = 0.001
|
'BV': pair[x]['BV'], # keep too
|
||||||
ll -= 0.0001
|
'O': x * base, # But replace O,H,L,C
|
||||||
h += 0.0001
|
'H': x * base + 0.0001,
|
||||||
for frame in pair:
|
'L': x * base - 0.0001,
|
||||||
o += 0.0001
|
'C': x * base} for x in range(0, datalen)]}
|
||||||
h += 0.0001
|
|
||||||
ll += 0.0001
|
|
||||||
c += 0.0001
|
|
||||||
# save prices rounded to satoshis
|
|
||||||
frame['O'] = round(o, 9)
|
|
||||||
frame['H'] = round(h, 9)
|
|
||||||
frame['L'] = round(ll, 9)
|
|
||||||
frame['C'] = round(c, 9)
|
|
||||||
if what == 'lower':
|
if what == 'lower':
|
||||||
o = 0.001
|
return {'BTC_UNITEST':
|
||||||
h = 0.001
|
[{'T': pair[x]['T'], # Keep old dates
|
||||||
ll = 0.001
|
'V': pair[x]['V'], # Keep old volume
|
||||||
c = 0.001
|
'BV': pair[x]['BV'], # keep too
|
||||||
ll -= 0.0001
|
'O': 1 - x * base, # But replace O,H,L,C
|
||||||
h += 0.0001
|
'H': 1 - x * base + 0.0001,
|
||||||
for frame in pair:
|
'L': 1 - x * base - 0.0001,
|
||||||
o -= 0.0001
|
'C': 1 - x * base} for x in range(0, datalen)]}
|
||||||
h -= 0.0001
|
|
||||||
ll -= 0.0001
|
|
||||||
c -= 0.0001
|
|
||||||
# save prices rounded to satoshis
|
|
||||||
frame['O'] = round(o, 9)
|
|
||||||
frame['H'] = round(h, 9)
|
|
||||||
frame['L'] = round(ll, 9)
|
|
||||||
frame['C'] = round(c, 9)
|
|
||||||
if what == 'sine':
|
if what == 'sine':
|
||||||
i = 0
|
hz = 0.1 # frequency
|
||||||
o = (2 + math.sin(i/10)) / 1000
|
return {'BTC_UNITEST':
|
||||||
h = o
|
[{'T': pair[x]['T'], # Keep old dates
|
||||||
ll = o
|
'V': pair[x]['V'], # Keep old volume
|
||||||
c = o
|
'BV': pair[x]['BV'], # keep too
|
||||||
h += 0.0001
|
'O': math.sin(x*hz) / 1000 + base, # But replace O,H,L,C
|
||||||
ll -= 0.0001
|
'H': math.sin(x*hz) / 1000 + base + 0.0001,
|
||||||
for frame in pair:
|
'L': math.sin(x*hz) / 1000 + base - 0.0001,
|
||||||
o = (2 + math.sin(i/10)) / 1000
|
'C': math.sin(x*hz) / 1000 + base} for x in range(0, datalen)]}
|
||||||
h = (2 + math.sin(i/10)) / 1000 + 0.0001
|
|
||||||
ll = (2 + math.sin(i/10)) / 1000 - 0.0001
|
|
||||||
c = (2 + math.sin(i/10)) / 1000 - 0.000001
|
|
||||||
|
|
||||||
# save prices rounded to satoshis
|
|
||||||
frame['O'] = round(o, 9)
|
|
||||||
frame['H'] = round(h, 9)
|
|
||||||
frame['L'] = round(ll, 9)
|
|
||||||
frame['C'] = round(c, 9)
|
|
||||||
i += 1
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
@ -131,6 +109,7 @@ def simple_backtest(config, contour, num_results):
|
|||||||
# results :: <class 'pandas.core.frame.DataFrame'>
|
# results :: <class 'pandas.core.frame.DataFrame'>
|
||||||
assert len(results) == num_results
|
assert len(results) == num_results
|
||||||
|
|
||||||
|
|
||||||
# Test backtest on offline data
|
# Test backtest on offline data
|
||||||
# loaded by freqdata/optimize/__init__.py::load_data()
|
# loaded by freqdata/optimize/__init__.py::load_data()
|
||||||
|
|
||||||
@ -139,18 +118,42 @@ def test_backtest2(default_conf, mocker):
|
|||||||
mocker.patch.dict('freqtrade.main._CONF', default_conf)
|
mocker.patch.dict('freqtrade.main._CONF', default_conf)
|
||||||
data = optimize.load_data(ticker_interval=5, pairs=['BTC_ETH'])
|
data = optimize.load_data(ticker_interval=5, pairs=['BTC_ETH'])
|
||||||
results = backtest(default_conf['stake_amount'], optimize.preprocess(data), 10, True)
|
results = backtest(default_conf['stake_amount'], optimize.preprocess(data), 10, True)
|
||||||
num_resutls = len(results)
|
assert not results.empty
|
||||||
assert num_resutls > 0
|
|
||||||
|
|
||||||
|
|
||||||
def test_processed(default_conf, mocker):
|
def test_processed(default_conf, mocker):
|
||||||
mocker.patch.dict('freqtrade.main._CONF', default_conf)
|
mocker.patch.dict('freqtrade.main._CONF', default_conf)
|
||||||
data = load_data_test('raise')
|
dict_of_tickerrows = load_data_test('raise')
|
||||||
assert optimize.preprocess(data)
|
dataframes = optimize.preprocess(dict_of_tickerrows)
|
||||||
|
dataframe = dataframes['BTC_UNITEST']
|
||||||
|
cols = dataframe.columns
|
||||||
|
# assert the dataframe got some of the indicator columns
|
||||||
|
for col in ['close', 'high', 'low', 'open', 'date',
|
||||||
|
'ema50', 'ao', 'macd', 'plus_dm']:
|
||||||
|
assert col in cols
|
||||||
|
|
||||||
|
|
||||||
def test_raise(default_conf, mocker):
|
def test_backtest_pricecontours(default_conf, mocker):
|
||||||
mocker.patch.dict('freqtrade.main._CONF', default_conf)
|
mocker.patch.dict('freqtrade.main._CONF', default_conf)
|
||||||
tests = [['raise', 359], ['lower', 0], ['sine', 1734]]
|
tests = [['raise', 17], ['lower', 0], ['sine', 17]]
|
||||||
for [contour, numres] in tests:
|
for [contour, numres] in tests:
|
||||||
simple_backtest(default_conf, contour, numres)
|
simple_backtest(default_conf, contour, numres)
|
||||||
|
|
||||||
|
# Please make this work, the load_config needs to be mocked
|
||||||
|
# and cleanups.
|
||||||
|
# def test_backtest_start(default_conf, mocker):
|
||||||
|
# default_conf['exchange']['pair_whitelist'] = ['BTC_UNITEST']
|
||||||
|
# mocker.patch.dict('freqtrade.main._CONF', default_conf)
|
||||||
|
# # see https://pypi.python.org/pypi/pytest-mock/
|
||||||
|
# # and http://www.voidspace.org.uk/python/mock/patch.html
|
||||||
|
# # No usage example of simple function mocking,
|
||||||
|
# # and no documentation of side_effect
|
||||||
|
# mocker.patch('freqtrade.misc.load_config', new=lambda s, t: {})
|
||||||
|
# args = MagicMock()
|
||||||
|
# args.level = 10
|
||||||
|
# #load_config('foo')
|
||||||
|
# backtesting.start(args)
|
||||||
|
#
|
||||||
|
# Check what sideeffect backtstesting has done.
|
||||||
|
# Probably need to capture standard-output and
|
||||||
|
# check for the generated report table.
|
||||||
|
@ -5,13 +5,6 @@ from freqtrade.main import refresh_whitelist
|
|||||||
# perhaps try to anticipate that by using some python package
|
# perhaps try to anticipate that by using some python package
|
||||||
|
|
||||||
|
|
||||||
def assert_list_equal(l1, l2):
|
|
||||||
for pair in l1:
|
|
||||||
assert pair in l2
|
|
||||||
for pair in l2:
|
|
||||||
assert pair in l1
|
|
||||||
|
|
||||||
|
|
||||||
def whitelist_conf():
|
def whitelist_conf():
|
||||||
return {
|
return {
|
||||||
"stake_currency": "BTC",
|
"stake_currency": "BTC",
|
||||||
@ -51,7 +44,7 @@ def test_refresh_whitelist(mocker):
|
|||||||
refreshedwhitelist = refresh_whitelist(conf['exchange']['pair_whitelist'])
|
refreshedwhitelist = refresh_whitelist(conf['exchange']['pair_whitelist'])
|
||||||
whitelist = ['BTC_ETH', 'BTC_TKN']
|
whitelist = ['BTC_ETH', 'BTC_TKN']
|
||||||
# Ensure all except those in whitelist are removed
|
# Ensure all except those in whitelist are removed
|
||||||
assert_list_equal(whitelist, refreshedwhitelist)
|
assert set(whitelist) == set(refreshedwhitelist)
|
||||||
|
|
||||||
|
|
||||||
def test_refresh_whitelist_dynamic(mocker):
|
def test_refresh_whitelist_dynamic(mocker):
|
||||||
@ -62,7 +55,7 @@ def test_refresh_whitelist_dynamic(mocker):
|
|||||||
# argument: use the whitelist dynamically by exchange-volume
|
# argument: use the whitelist dynamically by exchange-volume
|
||||||
whitelist = ['BTC_ETH', 'BTC_TKN']
|
whitelist = ['BTC_ETH', 'BTC_TKN']
|
||||||
refreshedwhitelist = refresh_whitelist(whitelist)
|
refreshedwhitelist = refresh_whitelist(whitelist)
|
||||||
assert_list_equal(whitelist, refreshedwhitelist)
|
assert set(whitelist) == set(refreshedwhitelist)
|
||||||
|
|
||||||
|
|
||||||
def test_refresh_whitelist_dynamic_empty(mocker):
|
def test_refresh_whitelist_dynamic_empty(mocker):
|
||||||
@ -75,4 +68,4 @@ def test_refresh_whitelist_dynamic_empty(mocker):
|
|||||||
conf['exchange']['pair_whitelist'] = []
|
conf['exchange']['pair_whitelist'] = []
|
||||||
refresh_whitelist(whitelist)
|
refresh_whitelist(whitelist)
|
||||||
pairslist = conf['exchange']['pair_whitelist']
|
pairslist = conf['exchange']['pair_whitelist']
|
||||||
assert_list_equal(whitelist, pairslist)
|
assert set(whitelist) == set(pairslist)
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
# pragma pylint: disable=missing-docstring,C0103
|
|
||||||
from unittest.mock import MagicMock
|
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
from freqtrade import OperationalException
|
|
||||||
from freqtrade.exchange import validate_pairs
|
|
||||||
|
|
||||||
|
|
||||||
def test_validate_pairs(default_conf, mocker):
|
|
||||||
api_mock = MagicMock()
|
|
||||||
api_mock.get_markets = MagicMock(return_value=[
|
|
||||||
'BTC_ETH', 'BTC_TKN', 'BTC_TRST', 'BTC_SWT', 'BTC_BCC',
|
|
||||||
])
|
|
||||||
mocker.patch('freqtrade.exchange._API', api_mock)
|
|
||||||
mocker.patch.dict('freqtrade.exchange._CONF', default_conf)
|
|
||||||
validate_pairs(default_conf['exchange']['pair_whitelist'])
|
|
||||||
|
|
||||||
|
|
||||||
def test_validate_pairs_not_available(default_conf, mocker):
|
|
||||||
api_mock = MagicMock()
|
|
||||||
api_mock.get_markets = MagicMock(return_value=[])
|
|
||||||
mocker.patch('freqtrade.exchange._API', api_mock)
|
|
||||||
mocker.patch.dict('freqtrade.exchange._CONF', default_conf)
|
|
||||||
with pytest.raises(OperationalException, match=r'not available'):
|
|
||||||
validate_pairs(default_conf['exchange']['pair_whitelist'])
|
|
||||||
|
|
||||||
|
|
||||||
def test_validate_pairs_not_compatible(default_conf, mocker):
|
|
||||||
api_mock = MagicMock()
|
|
||||||
api_mock.get_markets = MagicMock(return_value=['BTC_ETH', 'BTC_TKN', 'BTC_TRST', 'BTC_SWT'])
|
|
||||||
default_conf['stake_currency'] = 'ETH'
|
|
||||||
mocker.patch('freqtrade.exchange._API', api_mock)
|
|
||||||
mocker.patch.dict('freqtrade.exchange._CONF', default_conf)
|
|
||||||
with pytest.raises(OperationalException, match=r'not compatible'):
|
|
||||||
validate_pairs(default_conf['exchange']['pair_whitelist'])
|
|
Loading…
Reference in New Issue
Block a user