diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-08-27 11:19:55 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-08-27 11:19:55 +0200 |
commit | 8e648fd5b8d10c8f68b30ee0c30f02d5b60a1b77 (patch) | |
tree | d63560104b41c11c12591ceaf3fa7000fc99856c /tests | |
parent | 8f98e46aa52f4e229ae4f44cd9cc49f9fad9c866 (diff) | |
download | Trader-8e648fd5b8d10c8f68b30ee0c30f02d5b60a1b77.tar.gz Trader-8e648fd5b8d10c8f68b30ee0c30f02d5b60a1b77.tar.zst Trader-8e648fd5b8d10c8f68b30ee0c30f02d5b60a1b77.zip |
Use market options for fetch balances
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_market.py | 34 |
1 files changed, 18 insertions, 16 deletions
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): | |||
1057 | method, arguments = processor.method_arguments("print_tickers") | 1057 | method, arguments = processor.method_arguments("print_tickers") |
1058 | self.assertEqual(m.print_tickers, method) | 1058 | self.assertEqual(m.print_tickers, method) |
1059 | 1059 | ||
1060 | method, arguments = processor.method_arguments("fetch_balances") | ||
1061 | self.assertEqual(m.balances.fetch_balances, method) | ||
1062 | |||
1060 | def test_process_step(self): | 1063 | def test_process_step(self): |
1061 | processor = market.Processor(self.m) | 1064 | processor = market.Processor(self.m) |
1062 | 1065 | ||
@@ -1069,19 +1072,17 @@ class ProcessorTest(WebMockTestCase): | |||
1069 | mock.call("process_foo__2_sell_begin"), | 1072 | mock.call("process_foo__2_sell_begin"), |
1070 | mock.call("process_foo__2_sell_end"), | 1073 | mock.call("process_foo__2_sell_end"), |
1071 | ]) | 1074 | ]) |
1072 | self.m.balances.fetch_balances.assert_has_calls([ | ||
1073 | mock.call(tag="process_foo__2_sell_begin"), | ||
1074 | mock.call(tag="process_foo__2_sell_end"), | ||
1075 | ]) | ||
1076 | 1075 | ||
1077 | self.assertEqual(5, run_action.call_count) | 1076 | self.assertEqual(7, run_action.call_count) |
1078 | 1077 | ||
1079 | run_action.assert_has_calls([ | 1078 | run_action.assert_has_calls([ |
1079 | mock.call('fetch_balances', {}, {'foo': 'bar', 'tag': 'process_foo__2_sell_begin'}), | ||
1080 | mock.call('prepare_trades', {}, {'foo': 'bar'}), | 1080 | mock.call('prepare_trades', {}, {'foo': 'bar'}), |
1081 | mock.call('prepare_orders', {'only': 'dispose', 'compute_value': 'average'}, {'foo': 'bar'}), | 1081 | mock.call('prepare_orders', {'only': 'dispose', 'compute_value': 'average'}, {'foo': 'bar'}), |
1082 | mock.call('run_orders', {}, {'foo': 'bar'}), | 1082 | mock.call('run_orders', {}, {'foo': 'bar'}), |
1083 | mock.call('follow_orders', {}, {'foo': 'bar'}), | 1083 | mock.call('follow_orders', {}, {'foo': 'bar'}), |
1084 | mock.call('close_trades', {}, {'foo': 'bar'}), | 1084 | mock.call('close_trades', {}, {'foo': 'bar'}), |
1085 | mock.call('fetch_balances', {}, {'foo': 'bar', 'tag': 'process_foo__2_sell_end'}), | ||
1085 | ]) | 1086 | ]) |
1086 | 1087 | ||
1087 | self.m.reset_mock() | 1088 | self.m.reset_mock() |
@@ -1094,30 +1095,31 @@ class ProcessorTest(WebMockTestCase): | |||
1094 | mock.call("process_foo__0_print_balances_begin"), | 1095 | mock.call("process_foo__0_print_balances_begin"), |
1095 | mock.call("process_foo__0_print_balances_end"), | 1096 | mock.call("process_foo__0_print_balances_end"), |
1096 | ]) | 1097 | ]) |
1097 | self.m.balances.fetch_balances.assert_has_calls([ | ||
1098 | mock.call(add_portfolio=True, checkpoint='end', | ||
1099 | log_tickers=True, | ||
1100 | add_usdt=True, | ||
1101 | tag='process_foo__0_print_balances_begin') | ||
1102 | ]) | ||
1103 | 1098 | ||
1104 | self.assertEqual(0, run_action.call_count) | 1099 | self.assertEqual(1, run_action.call_count) |
1100 | run_action.assert_has_calls([ | ||
1101 | mock.call('fetch_balances', | ||
1102 | {'checkpoint': 'end', 'log_tickers': True, 'add_usdt': True, 'add_portfolio': True}, | ||
1103 | {'foo': 'bar', 'tag': 'process_foo__0_print_balances_begin'}), | ||
1104 | ]) | ||
1105 | 1105 | ||
1106 | self.m.reset_mock() | 1106 | self.m.reset_mock() |
1107 | with mock.patch.object(processor, "run_action") as run_action: | 1107 | with mock.patch.object(processor, "run_action") as run_action: |
1108 | step = processor.scenarios["sell_needed"][1] | 1108 | step = processor.scenarios["sell_needed"][1] |
1109 | 1109 | ||
1110 | processor.process_step("foo", step, {"foo":"bar"}) | 1110 | processor.process_step("foo", step, {"foo":"bar"}) |
1111 | self.m.balances.fetch_balances.assert_not_called() | 1111 | self.assertEqual(1, run_action.call_count) |
1112 | 1112 | ||
1113 | self.m.reset_mock() | 1113 | self.m.reset_mock() |
1114 | with mock.patch.object(processor, "run_action") as run_action: | 1114 | with mock.patch.object(processor, "run_action") as run_action: |
1115 | step = processor.scenarios["print_balances"][0] | 1115 | step = processor.scenarios["print_balances"][0] |
1116 | 1116 | ||
1117 | processor.process_step("foo", step, {"foo":"bar"}) | 1117 | processor.process_step("foo", step, {"foo":"bar"}) |
1118 | self.m.balances.fetch_balances.assert_called_once_with( | 1118 | run_action.assert_has_calls([ |
1119 | add_portfolio=True, add_usdt=True, log_tickers=True, | 1119 | mock.call('fetch_balances', |
1120 | tag='process_foo__1_print_balances_begin') | 1120 | {'log_tickers': True, 'add_usdt': True, 'add_portfolio': True}, |
1121 | {'foo': 'bar', 'tag': 'process_foo__1_print_balances_begin'}), | ||
1122 | ]) | ||
1121 | 1123 | ||
1122 | def test_parse_args(self): | 1124 | def test_parse_args(self): |
1123 | processor = market.Processor(self.m) | 1125 | processor = market.Processor(self.m) |