From a64252492804cb6c254a4d4f09f03a7e1ed02d48 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 29 Mar 2023 06:47:34 +0200 Subject: [PATCH] Improve integration test correctness --- tests/test_integration.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/test_integration.py b/tests/test_integration.py index 66aa7b4ee..9fb9fd8b3 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -49,8 +49,9 @@ def test_may_execute_exit_stoploss_on_exchange_multi(default_conf, ticker, fee, stoploss_order_closed['filled'] = stoploss_order_closed['amount'] # Sell first trade based on stoploss, keep 2nd and 3rd trade open + stop_orders = [stoploss_order_closed, stoploss_order_open, stoploss_order_open] stoploss_order_mock = MagicMock( - side_effect=[stoploss_order_closed, stoploss_order_open, stoploss_order_open]) + side_effect=stop_orders) # Sell 3rd trade (not called for the first trade) should_sell_mock = MagicMock(side_effect=[ [], @@ -94,12 +95,13 @@ def test_may_execute_exit_stoploss_on_exchange_multi(default_conf, ticker, fee, trades = Trade.session.scalars(select(Trade)).all() # Make sure stoploss-order is open and trade is bought - for trade in trades: - stoploss_order_closed['id'] = '3' - oobj = Order.parse_from_ccxt_object(stoploss_order_closed, trade.pair, 'stoploss') + for idx, trade in enumerate(trades): + stop_order = stop_orders[idx] + stop_order['id'] = f"stop{idx}" + oobj = Order.parse_from_ccxt_object(stop_order, trade.pair, 'stoploss') trade.orders.append(oobj) - trade.stoploss_order_id = '3' + trade.stoploss_order_id = f"stop{idx}" trade.open_order_id = None n = freqtrade.exit_positions(trades)