From 4ae84fb7861938f7d98802a5621b1bbd6745c914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Sun, 6 May 2018 23:04:40 +0200 Subject: Fix infinite recursion during fetch --- tests/test_market.py | 2 +- tests/test_portfolio.py | 26 ++++++++++++++------------ 2 files changed, 15 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/test_market.py b/tests/test_market.py index 37c009b..0211638 100644 --- a/tests/test_market.py +++ b/tests/test_market.py @@ -890,7 +890,7 @@ class MarketTest(WebMockTestCase): process.side_effect = Exception("bouh") m.process(["some_action"], before=True) - log_error.assert_called_with("market_process", exception=mock.ANY) + log_error.assert_called_with("market_process", exception=mock.ANY, message=mock.ANY) store_report.assert_called_once() diff --git a/tests/test_portfolio.py b/tests/test_portfolio.py index 969f5d4..6ca3327 100644 --- a/tests/test_portfolio.py +++ b/tests/test_portfolio.py @@ -142,9 +142,9 @@ class TradeTest(WebMockTestCase): self.assertTrue(trade.is_fullfiled) - order1.filled_amount.assert_called_with(in_base_currency=True) - order2.filled_amount.assert_called_with(in_base_currency=True) - order3.filled_amount.assert_called_with(in_base_currency=True) + order1.filled_amount.assert_called_with(in_base_currency=True, refetch=True) + order2.filled_amount.assert_called_with(in_base_currency=True, refetch=True) + order3.filled_amount.assert_called_with(in_base_currency=True, refetch=True) with self.subTest(inverted=True): value_from = portfolio.Amount("BTC", "0.5") @@ -169,9 +169,9 @@ class TradeTest(WebMockTestCase): self.assertTrue(trade.is_fullfiled) - order1.filled_amount.assert_called_with(in_base_currency=False) - order2.filled_amount.assert_called_with(in_base_currency=False) - order3.filled_amount.assert_called_with(in_base_currency=False) + order1.filled_amount.assert_called_with(in_base_currency=False, refetch=True) + order2.filled_amount.assert_called_with(in_base_currency=False, refetch=True) + order3.filled_amount.assert_called_with(in_base_currency=False, refetch=True) def test_filled_amount(self): @@ -189,16 +189,16 @@ class TradeTest(WebMockTestCase): trade.orders.append(order2) self.assertEqual(portfolio.Amount("ETH", "0.31"), trade.filled_amount()) - order1.filled_amount.assert_called_with(in_base_currency=False) - order2.filled_amount.assert_called_with(in_base_currency=False) + order1.filled_amount.assert_called_with(in_base_currency=False, refetch=False) + order2.filled_amount.assert_called_with(in_base_currency=False, refetch=False) self.assertEqual(portfolio.Amount("ETH", "0.31"), trade.filled_amount(in_base_currency=False)) - order1.filled_amount.assert_called_with(in_base_currency=False) - order2.filled_amount.assert_called_with(in_base_currency=False) + order1.filled_amount.assert_called_with(in_base_currency=False, refetch=False) + order2.filled_amount.assert_called_with(in_base_currency=False, refetch=False) self.assertEqual(portfolio.Amount("ETH", "0.31"), trade.filled_amount(in_base_currency=True)) - order1.filled_amount.assert_called_with(in_base_currency=True) - order2.filled_amount.assert_called_with(in_base_currency=True) + order1.filled_amount.assert_called_with(in_base_currency=True, refetch=False) + order2.filled_amount.assert_called_with(in_base_currency=True, refetch=False) @mock.patch.object(portfolio.Computation, "compute_value") @mock.patch.object(portfolio.Trade, "filled_amount") @@ -863,6 +863,8 @@ class OrderTest(WebMockTestCase): fetch.assert_not_called() order.status = "open" self.assertEqual(portfolio.Amount("ETH", 5), order.filled_amount(in_base_currency=False)) + fetch.assert_not_called() + self.assertEqual(portfolio.Amount("ETH", 5), order.filled_amount(in_base_currency=False, refetch=True)) fetch.assert_called_once() self.assertEqual(portfolio.Amount("BTC", "0.7"), order.filled_amount(in_base_currency=True)) -- cgit v1.2.3