From 8e648fd5b8d10c8f68b30ee0c30f02d5b60a1b77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Mon, 27 Aug 2018 11:19:55 +0200 Subject: Use market options for fetch balances --- tests/test_market.py | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'tests') diff --git a/tests/test_market.py b/tests/test_market.py index e6e6f36..9316480 100644 --- a/tests/test_market.py +++ b/tests/test_market.py @@ -1057,6 +1057,9 @@ class ProcessorTest(WebMockTestCase): method, arguments = processor.method_arguments("print_tickers") self.assertEqual(m.print_tickers, method) + method, arguments = processor.method_arguments("fetch_balances") + self.assertEqual(m.balances.fetch_balances, method) + def test_process_step(self): processor = market.Processor(self.m) @@ -1069,19 +1072,17 @@ class ProcessorTest(WebMockTestCase): mock.call("process_foo__2_sell_begin"), mock.call("process_foo__2_sell_end"), ]) - self.m.balances.fetch_balances.assert_has_calls([ - mock.call(tag="process_foo__2_sell_begin"), - mock.call(tag="process_foo__2_sell_end"), - ]) - self.assertEqual(5, run_action.call_count) + self.assertEqual(7, run_action.call_count) run_action.assert_has_calls([ + mock.call('fetch_balances', {}, {'foo': 'bar', 'tag': 'process_foo__2_sell_begin'}), mock.call('prepare_trades', {}, {'foo': 'bar'}), mock.call('prepare_orders', {'only': 'dispose', 'compute_value': 'average'}, {'foo': 'bar'}), mock.call('run_orders', {}, {'foo': 'bar'}), mock.call('follow_orders', {}, {'foo': 'bar'}), mock.call('close_trades', {}, {'foo': 'bar'}), + mock.call('fetch_balances', {}, {'foo': 'bar', 'tag': 'process_foo__2_sell_end'}), ]) self.m.reset_mock() @@ -1094,30 +1095,31 @@ class ProcessorTest(WebMockTestCase): mock.call("process_foo__0_print_balances_begin"), mock.call("process_foo__0_print_balances_end"), ]) - self.m.balances.fetch_balances.assert_has_calls([ - mock.call(add_portfolio=True, checkpoint='end', - log_tickers=True, - add_usdt=True, - tag='process_foo__0_print_balances_begin') - ]) - self.assertEqual(0, run_action.call_count) + self.assertEqual(1, run_action.call_count) + run_action.assert_has_calls([ + mock.call('fetch_balances', + {'checkpoint': 'end', 'log_tickers': True, 'add_usdt': True, 'add_portfolio': True}, + {'foo': 'bar', 'tag': 'process_foo__0_print_balances_begin'}), + ]) self.m.reset_mock() with mock.patch.object(processor, "run_action") as run_action: step = processor.scenarios["sell_needed"][1] processor.process_step("foo", step, {"foo":"bar"}) - self.m.balances.fetch_balances.assert_not_called() + self.assertEqual(1, run_action.call_count) self.m.reset_mock() with mock.patch.object(processor, "run_action") as run_action: step = processor.scenarios["print_balances"][0] processor.process_step("foo", step, {"foo":"bar"}) - self.m.balances.fetch_balances.assert_called_once_with( - add_portfolio=True, add_usdt=True, log_tickers=True, - tag='process_foo__1_print_balances_begin') + run_action.assert_has_calls([ + mock.call('fetch_balances', + {'log_tickers': True, 'add_usdt': True, 'add_portfolio': True}, + {'foo': 'bar', 'tag': 'process_foo__1_print_balances_begin'}), + ]) def test_parse_args(self): processor = market.Processor(self.m) -- cgit v1.2.3