X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=test.py;h=d58b2035af902c63609daf0857a2aaea2b42827f;hb=7eb9cb36c2ef01097fe8e99d40dd17308abdfe37;hp=56167f4043c94207d532557542a31459ff591eb1;hpb=9f54fd9acf98692ff7601fd3236c46745eb26e15;p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FCryptoportfolio%2FTrader.git diff --git a/test.py b/test.py index 56167f4..d58b203 100644 --- a/test.py +++ b/test.py @@ -820,6 +820,32 @@ class HelperTest(WebMockTestCase): print_all_with_order.assert_called() self.assertRegex(stdout_mock.getvalue(), "Balance") + @mock.patch.object(portfolio.BalanceStore, "fetch_balances") + @mock.patch.object(portfolio.BalanceStore, "in_currency") + @mock.patch('sys.stdout', new_callable=StringIO) + def test_print_balances(self, stdout_mock, in_currency, fetch_balances): + market = mock.Mock() + portfolio.BalanceStore.all = { + "BTC": portfolio.Balance("BTC", { + "total": "0.65", + "exchange_total":"0.65", + "exchange_free": "0.35", + "exchange_used": "0.30"}), + "ETH": portfolio.Balance("ETH", { + "total": 3, + "exchange_total": 3, + "exchange_free": 3, + "exchange_used": 0}), + } + in_currency.return_value = { + "BTC": portfolio.Amount("BTC", "0.65"), + "ETH": portfolio.Amount("BTC", "0.3"), + } + helper.print_balances(market) + fetch_balances.assert_called_with(market) + self.assertRegex(stdout_mock.getvalue(), "Balance") + self.assertRegex(stdout_mock.getvalue(), "0.95000000 BTC") + @mock.patch.object(helper, "prepare_trades") @mock.patch.object(helper, "follow_orders") @mock.patch.object(portfolio.TradeStore, "prepare_orders") @@ -1221,6 +1247,7 @@ class BalanceStoreTest(WebMockTestCase): } amounts = portfolio.BalanceStore.dispatch_assets(portfolio.Amount("BTC", "11.1")) + repartition.assert_called_with(liquidity="medium") self.assertIn("XEM", portfolio.BalanceStore.currencies()) self.assertEqual(D("2.6"), amounts["BTC"].value) self.assertEqual(D("7.5"), amounts["XEM"].value)