diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-02-12 14:11:02 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-02-12 14:11:02 +0100 |
commit | 97922ff1826cc6b9c0329cc30e8d4621bb2644ee (patch) | |
tree | 1437590a98b10f64683e226d03fda130840f0ba6 /test.py | |
parent | 9f54fd9acf98692ff7601fd3236c46745eb26e15 (diff) | |
download | Trader-97922ff1826cc6b9c0329cc30e8d4621bb2644ee.tar.gz Trader-97922ff1826cc6b9c0329cc30e8d4621bb2644ee.tar.zst Trader-97922ff1826cc6b9c0329cc30e8d4621bb2644ee.zip |
Add print_balances helper
Diffstat (limited to 'test.py')
-rw-r--r-- | test.py | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -820,6 +820,32 @@ class HelperTest(WebMockTestCase): | |||
820 | print_all_with_order.assert_called() | 820 | print_all_with_order.assert_called() |
821 | self.assertRegex(stdout_mock.getvalue(), "Balance") | 821 | self.assertRegex(stdout_mock.getvalue(), "Balance") |
822 | 822 | ||
823 | @mock.patch.object(portfolio.BalanceStore, "fetch_balances") | ||
824 | @mock.patch.object(portfolio.BalanceStore, "in_currency") | ||
825 | @mock.patch('sys.stdout', new_callable=StringIO) | ||
826 | def test_print_balances(self, stdout_mock, in_currency, fetch_balances): | ||
827 | market = mock.Mock() | ||
828 | portfolio.BalanceStore.all = { | ||
829 | "BTC": portfolio.Balance("BTC", { | ||
830 | "total": "0.65", | ||
831 | "exchange_total":"0.65", | ||
832 | "exchange_free": "0.35", | ||
833 | "exchange_used": "0.30"}), | ||
834 | "ETH": portfolio.Balance("ETH", { | ||
835 | "total": 3, | ||
836 | "exchange_total": 3, | ||
837 | "exchange_free": 3, | ||
838 | "exchange_used": 0}), | ||
839 | } | ||
840 | in_currency.return_value = { | ||
841 | "BTC": portfolio.Amount("BTC", "0.65"), | ||
842 | "ETH": portfolio.Amount("BTC", "0.3"), | ||
843 | } | ||
844 | helper.print_balances(market) | ||
845 | fetch_balances.assert_called_with(market) | ||
846 | self.assertRegex(stdout_mock.getvalue(), "Balance") | ||
847 | self.assertRegex(stdout_mock.getvalue(), "0.95000000 BTC") | ||
848 | |||
823 | @mock.patch.object(helper, "prepare_trades") | 849 | @mock.patch.object(helper, "prepare_trades") |
824 | @mock.patch.object(helper, "follow_orders") | 850 | @mock.patch.object(helper, "follow_orders") |
825 | @mock.patch.object(portfolio.TradeStore, "prepare_orders") | 851 | @mock.patch.object(portfolio.TradeStore, "prepare_orders") |