mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-12-15 20:31:43 +00:00
Improve ccxt_ws test setup
This commit is contained in:
@@ -11,6 +11,8 @@ from tests.conftest import EXMS, get_default_conf_usdt
|
||||
|
||||
|
||||
EXCHANGE_FIXTURE_TYPE = Tuple[Exchange, str]
|
||||
EXCHANGE_WS_FIXTURE_TYPE = Tuple[Exchange, str, str]
|
||||
|
||||
|
||||
# Exchanges that should be tested online
|
||||
EXCHANGES = {
|
||||
@@ -412,11 +414,24 @@ def exchange_futures(request, exchange_conf, class_mocker):
|
||||
return get_futures_exchange(request.param, exchange_conf, class_mocker)
|
||||
|
||||
|
||||
@pytest.fixture(params=["spot", "futures"], scope="class")
|
||||
def exchange_mode(request):
|
||||
return request.param
|
||||
|
||||
|
||||
@pytest.fixture(params=EXCHANGES, scope="class")
|
||||
def exchange_ws(request, exchange_conf):
|
||||
def exchange_ws(request, exchange_conf, exchange_mode, class_mocker):
|
||||
exchange_conf["exchange"]["enable_ws"] = True
|
||||
exchange, name = get_exchange(request.param, exchange_conf)
|
||||
if exchange_mode == "spot":
|
||||
exchange, name = get_exchange(request.param, exchange_conf)
|
||||
pair = EXCHANGES[request.param]["pair"]
|
||||
else:
|
||||
exchange, name = get_futures_exchange(
|
||||
request.param, exchange_conf, class_mocker=class_mocker
|
||||
)
|
||||
pair = EXCHANGES[request.param]["futures_pair"]
|
||||
|
||||
if not exchange._has_watch_ohlcv:
|
||||
pytest.skip("Exchange does not support watch_ohlcv.")
|
||||
yield exchange, name
|
||||
yield exchange, name, pair
|
||||
exchange.close()
|
||||
|
||||
@@ -11,22 +11,20 @@ from time import sleep
|
||||
import pytest
|
||||
|
||||
from freqtrade.enums import CandleType
|
||||
from freqtrade.exchange.exchange_utils import (timeframe_to_minutes, timeframe_to_next_date,
|
||||
timeframe_to_prev_date)
|
||||
from freqtrade.exchange.exchange_utils import timeframe_to_prev_date
|
||||
from freqtrade.loggers.set_log_levels import set_loggers
|
||||
from freqtrade.util.datetime_helpers import dt_now
|
||||
from tests.conftest import log_has_re
|
||||
from tests.exchange_online.conftest import EXCHANGE_FIXTURE_TYPE, EXCHANGES
|
||||
from tests.exchange_online.conftest import EXCHANGE_WS_FIXTURE_TYPE
|
||||
|
||||
|
||||
@pytest.mark.longrun
|
||||
class TestCCXTExchangeWs:
|
||||
|
||||
def test_ccxt_ohlcv(self, exchange_ws: EXCHANGE_FIXTURE_TYPE, caplog, mocker):
|
||||
exch, exchangename = exchange_ws
|
||||
def test_ccxt_ohlcv(self, exchange_ws: EXCHANGE_WS_FIXTURE_TYPE, caplog, mocker):
|
||||
exch, exchangename, pair = exchange_ws
|
||||
|
||||
assert exch._ws_async is not None
|
||||
pair = EXCHANGES[exchangename]['pair']
|
||||
timeframe = '1m'
|
||||
pair_tf = (pair, timeframe, CandleType.SPOT)
|
||||
m_hist = mocker.spy(exch, '_async_get_historic_ohlcv')
|
||||
|
||||
Reference in New Issue
Block a user