chore: update patch_exchange to not override builtins

This commit is contained in:
Matthias
2024-07-05 09:10:55 +02:00
parent 1e287de589
commit 36a44575c7
5 changed files with 18 additions and 17 deletions

View File

@@ -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),