Introduce markets_static fixture serving an immutable list of markets. Adapt pairlist/markets tests to use this new fixture.

This allows freely modifying markets in get_markets() without a need of updating pairlist/markets tests.
This commit is contained in:
Rokas Kupstys
2021-09-29 10:15:05 +03:00
parent 5726886b06
commit e025576d8c
4 changed files with 26 additions and 12 deletions

View File

@@ -90,8 +90,10 @@ def patch_exchange(mocker, api_mock=None, id='binance', mock_markets=True) -> No
mocker.patch('freqtrade.exchange.Exchange.name', PropertyMock(return_value=id.title()))
mocker.patch('freqtrade.exchange.Exchange.precisionMode', PropertyMock(return_value=2))
if mock_markets:
if isinstance(mock_markets, bool):
mock_markets = get_markets()
mocker.patch('freqtrade.exchange.Exchange.markets',
PropertyMock(return_value=get_markets()))
PropertyMock(return_value=mock_markets))
if api_mock:
mocker.patch('freqtrade.exchange.Exchange._init_ccxt', MagicMock(return_value=api_mock))
@@ -376,6 +378,8 @@ def markets():
def get_markets():
# See get_markets_static() for immutable markets and do not modify them unless absolutely
# necessary!
return {
'ETH/BTC': {
'id': 'ethbtc',
@@ -675,11 +679,22 @@ def get_markets():
@pytest.fixture
def shitcoinmarkets(markets):
def markets_static():
# These markets are used in some tests that would need adaptation should anything change in
# market list. Do not modify this list without a good reason! Do not modify market parameters
# of listed pairs in get_markets() without a good reason either!
static_markets = ['BLK/BTC', 'BTT/BTC', 'ETH/BTC', 'ETH/USDT', 'LTC/BTC', 'LTC/ETH', 'LTC/USD',
'LTC/USDT', 'NEO/BTC', 'TKN/BTC', 'XLTCUSDT', 'XRP/BTC']
all_markets = get_markets()
return {m: all_markets[m] for m in static_markets}
@pytest.fixture
def shitcoinmarkets(markets_static):
"""
Fixture with shitcoin markets - used to test filters in pairlists
"""
shitmarkets = deepcopy(markets)
shitmarkets = deepcopy(markets_static)
shitmarkets.update({
'HOT/BTC': {
'id': 'HOTBTC',