Remove direct call to pytest fixture to elliminate pytest warning
This commit is contained in:
parent
2d4d1d7306
commit
4d5e368c2e
@ -2,38 +2,39 @@
|
|||||||
|
|
||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
import freqtrade.tests.conftest as tt # test tools
|
from freqtrade.tests.conftest import get_patched_freqtradebot
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
# whitelist, blacklist, filtering, all of that will
|
# whitelist, blacklist, filtering, all of that will
|
||||||
# eventually become some rules to run on a generic ACL engine
|
# eventually become some rules to run on a generic ACL engine
|
||||||
# perhaps try to anticipate that by using some python package
|
# perhaps try to anticipate that by using some python package
|
||||||
|
|
||||||
|
|
||||||
def whitelist_conf():
|
@pytest.fixture(scope="function")
|
||||||
config = tt.default_conf()
|
def whitelist_conf(default_conf):
|
||||||
config['stake_currency'] = 'BTC'
|
default_conf['stake_currency'] = 'BTC'
|
||||||
config['exchange']['pair_whitelist'] = [
|
default_conf['exchange']['pair_whitelist'] = [
|
||||||
'ETH/BTC',
|
'ETH/BTC',
|
||||||
'TKN/BTC',
|
'TKN/BTC',
|
||||||
'TRST/BTC',
|
'TRST/BTC',
|
||||||
'SWT/BTC',
|
'SWT/BTC',
|
||||||
'BCC/BTC'
|
'BCC/BTC'
|
||||||
]
|
]
|
||||||
config['exchange']['pair_blacklist'] = [
|
default_conf['exchange']['pair_blacklist'] = [
|
||||||
'BLK/BTC'
|
'BLK/BTC'
|
||||||
]
|
]
|
||||||
|
|
||||||
return config
|
return default_conf
|
||||||
|
|
||||||
|
|
||||||
def test_refresh_market_pair_not_in_whitelist(mocker, markets):
|
def test_refresh_market_pair_not_in_whitelist(mocker, markets, whitelist_conf):
|
||||||
conf = whitelist_conf()
|
|
||||||
|
|
||||||
freqtradebot = tt.get_patched_freqtradebot(mocker, conf)
|
freqtradebot = get_patched_freqtradebot(mocker, whitelist_conf)
|
||||||
|
|
||||||
mocker.patch('freqtrade.exchange.Exchange.get_markets', markets)
|
mocker.patch('freqtrade.exchange.Exchange.get_markets', markets)
|
||||||
refreshedwhitelist = freqtradebot._refresh_whitelist(
|
refreshedwhitelist = freqtradebot._refresh_whitelist(
|
||||||
conf['exchange']['pair_whitelist'] + ['XXX/BTC']
|
whitelist_conf['exchange']['pair_whitelist'] + ['XXX/BTC']
|
||||||
)
|
)
|
||||||
# List ordered by BaseVolume
|
# List ordered by BaseVolume
|
||||||
whitelist = ['ETH/BTC', 'TKN/BTC']
|
whitelist = ['ETH/BTC', 'TKN/BTC']
|
||||||
@ -41,12 +42,12 @@ def test_refresh_market_pair_not_in_whitelist(mocker, markets):
|
|||||||
assert whitelist == refreshedwhitelist
|
assert whitelist == refreshedwhitelist
|
||||||
|
|
||||||
|
|
||||||
def test_refresh_whitelist(mocker, markets):
|
def test_refresh_whitelist(mocker, markets, whitelist_conf):
|
||||||
conf = whitelist_conf()
|
freqtradebot = get_patched_freqtradebot(mocker, whitelist_conf)
|
||||||
freqtradebot = tt.get_patched_freqtradebot(mocker, conf)
|
|
||||||
|
|
||||||
mocker.patch('freqtrade.exchange.Exchange.get_markets', markets)
|
mocker.patch('freqtrade.exchange.Exchange.get_markets', markets)
|
||||||
refreshedwhitelist = freqtradebot._refresh_whitelist(conf['exchange']['pair_whitelist'])
|
refreshedwhitelist = freqtradebot._refresh_whitelist(
|
||||||
|
whitelist_conf['exchange']['pair_whitelist'])
|
||||||
|
|
||||||
# List ordered by BaseVolume
|
# List ordered by BaseVolume
|
||||||
whitelist = ['ETH/BTC', 'TKN/BTC']
|
whitelist = ['ETH/BTC', 'TKN/BTC']
|
||||||
@ -54,9 +55,8 @@ def test_refresh_whitelist(mocker, markets):
|
|||||||
assert whitelist == refreshedwhitelist
|
assert whitelist == refreshedwhitelist
|
||||||
|
|
||||||
|
|
||||||
def test_refresh_whitelist_dynamic(mocker, markets, tickers):
|
def test_refresh_whitelist_dynamic(mocker, markets, tickers, whitelist_conf):
|
||||||
conf = whitelist_conf()
|
freqtradebot = get_patched_freqtradebot(mocker, whitelist_conf)
|
||||||
freqtradebot = tt.get_patched_freqtradebot(mocker, conf)
|
|
||||||
mocker.patch.multiple(
|
mocker.patch.multiple(
|
||||||
'freqtrade.exchange.Exchange',
|
'freqtrade.exchange.Exchange',
|
||||||
get_markets=markets,
|
get_markets=markets,
|
||||||
@ -68,21 +68,20 @@ def test_refresh_whitelist_dynamic(mocker, markets, tickers):
|
|||||||
whitelist = ['ETH/BTC', 'TKN/BTC']
|
whitelist = ['ETH/BTC', 'TKN/BTC']
|
||||||
|
|
||||||
refreshedwhitelist = freqtradebot._refresh_whitelist(
|
refreshedwhitelist = freqtradebot._refresh_whitelist(
|
||||||
freqtradebot._gen_pair_whitelist(conf['stake_currency'])
|
freqtradebot._gen_pair_whitelist(whitelist_conf['stake_currency'])
|
||||||
)
|
)
|
||||||
|
|
||||||
assert whitelist == refreshedwhitelist
|
assert whitelist == refreshedwhitelist
|
||||||
|
|
||||||
|
|
||||||
def test_refresh_whitelist_dynamic_empty(mocker, markets_empty):
|
def test_refresh_whitelist_dynamic_empty(mocker, markets_empty, whitelist_conf):
|
||||||
conf = whitelist_conf()
|
freqtradebot = get_patched_freqtradebot(mocker, whitelist_conf)
|
||||||
freqtradebot = tt.get_patched_freqtradebot(mocker, conf)
|
|
||||||
mocker.patch('freqtrade.exchange.Exchange.get_markets', markets_empty)
|
mocker.patch('freqtrade.exchange.Exchange.get_markets', markets_empty)
|
||||||
|
|
||||||
# argument: use the whitelist dynamically by exchange-volume
|
# argument: use the whitelist dynamically by exchange-volume
|
||||||
whitelist = []
|
whitelist = []
|
||||||
conf['exchange']['pair_whitelist'] = []
|
whitelist_conf['exchange']['pair_whitelist'] = []
|
||||||
freqtradebot._refresh_whitelist(whitelist)
|
freqtradebot._refresh_whitelist(whitelist)
|
||||||
pairslist = conf['exchange']['pair_whitelist']
|
pairslist = whitelist_conf['exchange']['pair_whitelist']
|
||||||
|
|
||||||
assert set(whitelist) == set(pairslist)
|
assert set(whitelist) == set(pairslist)
|
||||||
|
Loading…
Reference in New Issue
Block a user