From 84c9fe338676667b15f1c2601ae23ef945b36db7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Mon, 30 Jul 2018 23:18:00 +0200 Subject: Fix orders disappearing but finally not --- tests/test_market.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'tests') diff --git a/tests/test_market.py b/tests/test_market.py index 07188ac..c029686 100644 --- a/tests/test_market.py +++ b/tests/test_market.py @@ -402,6 +402,40 @@ class MarketTest(WebMockTestCase): m.report.log_order.assert_called_with(order_mock2, 2, new_order=new_order_mock) new_order_mock.run.assert_called_once_with() + with self.subTest("disappearing order no action to do"), \ + mock.patch("market.ReportStore"): + all_orders.reset_mock() + m = market.Market(self.ccxt, self.market_args()) + + order_mock1 = mock.Mock() + order_mock2 = mock.Mock() + all_orders.side_effect = [ + [order_mock1, order_mock2], + [order_mock1, order_mock2], + + [order_mock1, order_mock2], + [order_mock1, order_mock2], + + [] + ] + + order_mock1.get_status.side_effect = ["open", "closed"] + order_mock2.get_status.side_effect = ["open", "error_disappeared"] + + order_mock1.trade = mock.Mock() + trade_mock = mock.Mock() + order_mock2.trade = trade_mock + + trade_mock.tick_actions_recreate.return_value = "tick1" + trade_mock.prepare_order.return_value = None + + m.follow_orders() + + trade_mock.tick_actions_recreate.assert_called_once_with(2) + trade_mock.prepare_order.assert_called_once_with(compute_value="tick1") + m.report.log_error.assert_called_once_with("follow_orders", message=mock.ANY) + m.report.log_order.assert_called_with(order_mock2, 2, finished=True) + @mock.patch.object(market.BalanceStore, "fetch_balances") def test_move_balance(self, fetch_balances): for debug in [True, False]: -- cgit v1.2.3