diff --git a/tests/commands/test_commands.py b/tests/commands/test_commands.py index c98c6302e..02b234b6c 100644 --- a/tests/commands/test_commands.py +++ b/tests/commands/test_commands.py @@ -167,7 +167,7 @@ def test_list_timeframes(mocker, capsys): "1h": "hour", "1d": "day", } - patch_exchange(mocker, api_mock=api_mock, id="bybit") + patch_exchange(mocker, api_mock=api_mock, exchange="bybit") args = [ "list-timeframes", ] @@ -213,7 +213,7 @@ def test_list_timeframes(mocker, capsys): "1d": "1d", "3d": "3d", } - patch_exchange(mocker, api_mock=api_mock, id="binance") + patch_exchange(mocker, api_mock=api_mock, exchange="binance") # Test with --exchange binance args = [ "list-timeframes", @@ -258,7 +258,7 @@ def test_list_timeframes(mocker, capsys): def test_list_markets(mocker, markets_static, capsys): api_mock = MagicMock() - patch_exchange(mocker, api_mock=api_mock, id="binance", mock_markets=markets_static) + patch_exchange(mocker, api_mock=api_mock, exchange="binance", mock_markets=markets_static) # Test with no --config args = [ @@ -286,7 +286,7 @@ def test_list_markets(mocker, markets_static, capsys): "LTC/ETH, LTC/USD, NEO/BTC, TKN/BTC, XLTCUSDT, XRP/BTC.\n" in captured.out ) - patch_exchange(mocker, api_mock=api_mock, id="binance", mock_markets=markets_static) + patch_exchange(mocker, api_mock=api_mock, exchange="binance", mock_markets=markets_static) # Test with --exchange args = ["list-markets", "--exchange", "binance"] pargs = get_args(args) @@ -295,7 +295,7 @@ def test_list_markets(mocker, markets_static, capsys): captured = capsys.readouterr() assert re.match("\nExchange Binance has 12 active markets:\n", captured.out) - patch_exchange(mocker, api_mock=api_mock, id="binance", mock_markets=markets_static) + patch_exchange(mocker, api_mock=api_mock, exchange="binance", mock_markets=markets_static) # Test with --all: all markets args = [ "list-markets", @@ -823,7 +823,7 @@ def test_download_data_no_markets(mocker, caplog): "freqtrade.data.history.history_utils.refresh_backtest_ohlcv_data", MagicMock(return_value=["ETH/BTC", "XRP/BTC"]), ) - patch_exchange(mocker, id="binance") + patch_exchange(mocker, exchange="binance") mocker.patch(f"{EXMS}.get_markets", return_value={}) args = [ "download-data", @@ -952,7 +952,7 @@ def test_download_data_trades(mocker): def test_download_data_data_invalid(mocker): - patch_exchange(mocker, id="kraken") + patch_exchange(mocker, exchange="kraken") mocker.patch(f"{EXMS}.get_markets", return_value={}) args = [ "download-data", diff --git a/tests/conftest.py b/tests/conftest.py index c4964c414..71eca24c4 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -137,7 +137,7 @@ def generate_trades_history(n_rows, start_date: Optional[datetime] = None, days= random_timestamps_in_seconds = np.random.uniform(_start_timestamp, _end_timestamp, n_rows) timestamp = pd.to_datetime(random_timestamps_in_seconds, unit="s") - id = [ + trade_id = [ f"a{np.random.randint(1e6, 1e7 - 1)}cd{np.random.randint(100, 999)}" for _ in range(n_rows) ] @@ -155,7 +155,7 @@ def generate_trades_history(n_rows, start_date: Optional[datetime] = None, days= df = pd.DataFrame( { "timestamp": timestamp, - "id": id, + "id": trade_id, "type": None, "side": side, "price": price, @@ -236,12 +236,12 @@ def patched_configuration_load_config_file(mocker, config) -> None: def patch_exchange( - mocker, api_mock=None, id="binance", mock_markets=True, mock_supported_modes=True + mocker, api_mock=None, exchange="binance", mock_markets=True, mock_supported_modes=True ) -> None: mocker.patch(f"{EXMS}.validate_config", MagicMock()) mocker.patch(f"{EXMS}.validate_timeframes", MagicMock()) - mocker.patch(f"{EXMS}.id", PropertyMock(return_value=id)) - mocker.patch(f"{EXMS}.name", PropertyMock(return_value=id.title())) + mocker.patch(f"{EXMS}.id", PropertyMock(return_value=exchange)) + mocker.patch(f"{EXMS}.name", PropertyMock(return_value=exchange.title())) mocker.patch(f"{EXMS}.precisionMode", PropertyMock(return_value=2)) # Temporary patch ... mocker.patch("freqtrade.exchange.bybit.Bybit.cache_leverage_tiers") @@ -254,7 +254,8 @@ def patch_exchange( if mock_supported_modes: mocker.patch( - f"freqtrade.exchange.{id}.{id.capitalize()}._supported_trading_mode_margin_pairs", + f"freqtrade.exchange.{exchange}.{exchange.capitalize()}" + "._supported_trading_mode_margin_pairs", PropertyMock( return_value=[ (TradingMode.MARGIN, MarginMode.CROSS), diff --git a/tests/data/test_download_data.py b/tests/data/test_download_data.py index 08d56458f..f2c8a51d4 100644 --- a/tests/data/test_download_data.py +++ b/tests/data/test_download_data.py @@ -14,7 +14,7 @@ def test_download_data_main_no_markets(mocker, caplog): "freqtrade.data.history.history_utils.refresh_backtest_ohlcv_data", MagicMock(return_value=["ETH/BTC", "XRP/BTC"]), ) - patch_exchange(mocker, id="binance") + patch_exchange(mocker, exchange="binance") mocker.patch(f"{EXMS}.get_markets", return_value={}) config = setup_utils_configuration({"exchange": "binance"}, RunMode.UTIL_EXCHANGE) config.update({"days": 20, "pairs": ["ETH/BTC", "XRP/BTC"], "timeframes": ["5m", "1h"]}) @@ -91,7 +91,7 @@ def test_download_data_main_trades(mocker): def test_download_data_main_data_invalid(mocker): - patch_exchange(mocker, id="kraken") + patch_exchange(mocker, exchange="kraken") mocker.patch(f"{EXMS}.get_markets", return_value={}) config = setup_utils_configuration({"exchange": "kraken"}, RunMode.UTIL_EXCHANGE) config.update( diff --git a/tests/data/test_trade_converter_kraken.py b/tests/data/test_trade_converter_kraken.py index 480ea93ca..d8d20fd88 100644 --- a/tests/data/test_trade_converter_kraken.py +++ b/tests/data/test_trade_converter_kraken.py @@ -17,7 +17,7 @@ def test_import_kraken_trades_from_csv(testdatadir, tmp_path, caplog, default_co default_conf_usdt["exchange"]["name"] = "kraken" - patch_exchange(mocker, id="kraken") + patch_exchange(mocker, exchange="kraken") mocker.patch( f"{EXMS}.markets", PropertyMock( diff --git a/tests/freqtradebot/test_freqtradebot.py b/tests/freqtradebot/test_freqtradebot.py index 79224ddec..23dfbb785 100644 --- a/tests/freqtradebot/test_freqtradebot.py +++ b/tests/freqtradebot/test_freqtradebot.py @@ -915,7 +915,7 @@ def test_execute_entry( default_conf_usdt["margin_mode"] = margin_mode mocker.patch("freqtrade.exchange.gate.Gate.validate_ordertypes") patch_RPCManager(mocker) - patch_exchange(mocker, id=exchange_name) + patch_exchange(mocker, exchange=exchange_name) freqtrade = FreqtradeBot(default_conf_usdt) freqtrade.strategy.confirm_trade_entry = MagicMock(return_value=False) freqtrade.strategy.leverage = MagicMock(return_value=leverage)