Fix refresh_whitelist tests
This commit is contained in:
parent
e8fbe77ebc
commit
1738633efc
@ -17,7 +17,7 @@ class StaticList(object):
|
|||||||
self._config = config
|
self._config = config
|
||||||
self._whitelist = self._config['exchange']['pair_whitelist']
|
self._whitelist = self._config['exchange']['pair_whitelist']
|
||||||
self._blacklist = self._config['exchange'].get('pair_blacklist', [])
|
self._blacklist = self._config['exchange'].get('pair_blacklist', [])
|
||||||
self.refresh_whitelist()
|
# self.refresh_whitelist()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def whitelist(self) -> List[str]:
|
def whitelist(self) -> List[str]:
|
||||||
|
@ -6,9 +6,7 @@ from freqtrade.tests.conftest import get_patched_freqtradebot
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
# whitelist, blacklist, filtering, all of that will
|
# whitelist, blacklist,
|
||||||
# eventually become some rules to run on a generic ACL engine
|
|
||||||
# perhaps try to anticipate that by using some python package
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="function")
|
@pytest.fixture(scope="function")
|
||||||
@ -33,26 +31,26 @@ def test_refresh_market_pair_not_in_whitelist(mocker, markets, whitelist_conf):
|
|||||||
freqtradebot = get_patched_freqtradebot(mocker, whitelist_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(
|
freqtradebot.pairlists.validate_whitelist(
|
||||||
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']
|
||||||
# Ensure all except those in whitelist are removed
|
# Ensure all except those in whitelist are removed
|
||||||
assert whitelist == refreshedwhitelist
|
assert whitelist == freqtradebot.pairlists.whitelist
|
||||||
|
|
||||||
|
|
||||||
def test_refresh_whitelist(mocker, markets, whitelist_conf):
|
def test_refresh_whitelist(mocker, markets, whitelist_conf):
|
||||||
freqtradebot = get_patched_freqtradebot(mocker, whitelist_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(
|
freqtradebot.pairlists.validate_whitelist(
|
||||||
whitelist_conf['exchange']['pair_whitelist'])
|
whitelist_conf['exchange']['pair_whitelist'])
|
||||||
|
|
||||||
# List ordered by BaseVolume
|
# List ordered by BaseVolume
|
||||||
whitelist = ['ETH/BTC', 'TKN/BTC']
|
whitelist = ['ETH/BTC', 'TKN/BTC']
|
||||||
# Ensure all except those in whitelist are removed
|
# Ensure all except those in whitelist are removed
|
||||||
assert whitelist == refreshedwhitelist
|
assert whitelist == freqtradebot.pairlists.whitelist
|
||||||
|
|
||||||
|
|
||||||
def test_refresh_whitelist_dynamic(mocker, markets, tickers, whitelist_conf):
|
def test_refresh_whitelist_dynamic(mocker, markets, tickers, whitelist_conf):
|
||||||
@ -67,11 +65,11 @@ def test_refresh_whitelist_dynamic(mocker, markets, tickers, whitelist_conf):
|
|||||||
# argument: use the whitelist dynamically by exchange-volume
|
# argument: use the whitelist dynamically by exchange-volume
|
||||||
whitelist = ['ETH/BTC', 'TKN/BTC']
|
whitelist = ['ETH/BTC', 'TKN/BTC']
|
||||||
|
|
||||||
refreshedwhitelist = freqtradebot._refresh_whitelist(
|
freqtradebot._refresh_whitelist(
|
||||||
freqtradebot._gen_pair_whitelist(whitelist_conf['stake_currency'])
|
freqtradebot._gen_pair_whitelist(whitelist_conf['stake_currency'])
|
||||||
)
|
)
|
||||||
|
|
||||||
assert whitelist == refreshedwhitelist
|
assert whitelist == freqtradebot.pairlists.whitelist
|
||||||
|
|
||||||
|
|
||||||
def test_refresh_whitelist_dynamic_empty(mocker, markets_empty, whitelist_conf):
|
def test_refresh_whitelist_dynamic_empty(mocker, markets_empty, whitelist_conf):
|
||||||
|
Loading…
Reference in New Issue
Block a user