Update test_rpc.py
This commit is contained in:
		| @@ -771,7 +771,7 @@ def test_rpc_stopbuy(mocker, default_conf) -> None: | ||||
|     assert freqtradebot.config['max_open_trades'] == 0 | ||||
|  | ||||
|  | ||||
| def test_rpc_forceexit(default_conf, ticker, fee, mocker) -> None: | ||||
| def test_rpc_force_exit(default_conf, ticker, fee, mocker) -> None: | ||||
|     mocker.patch('freqtrade.rpc.telegram.Telegram', MagicMock()) | ||||
|  | ||||
|     cancel_order_mock = MagicMock() | ||||
| @@ -798,29 +798,29 @@ def test_rpc_forceexit(default_conf, ticker, fee, mocker) -> None: | ||||
|  | ||||
|     freqtradebot.state = State.STOPPED | ||||
|     with pytest.raises(RPCException, match=r'.*trader is not running*'): | ||||
|         rpc._rpc_forceexit(None) | ||||
|         rpc._rpc_force_exit(None) | ||||
|  | ||||
|     freqtradebot.state = State.RUNNING | ||||
|     with pytest.raises(RPCException, match=r'.*invalid argument*'): | ||||
|         rpc._rpc_forceexit(None) | ||||
|         rpc._rpc_force_exit(None) | ||||
|  | ||||
|     msg = rpc._rpc_forceexit('all') | ||||
|     msg = rpc._rpc_force_exit('all') | ||||
|     assert msg == {'result': 'Created sell orders for all open trades.'} | ||||
|  | ||||
|     freqtradebot.enter_positions() | ||||
|     msg = rpc._rpc_forceexit('all') | ||||
|     msg = rpc._rpc_force_exit('all') | ||||
|     assert msg == {'result': 'Created sell orders for all open trades.'} | ||||
|  | ||||
|     freqtradebot.enter_positions() | ||||
|     msg = rpc._rpc_forceexit('2') | ||||
|     msg = rpc._rpc_force_exit('2') | ||||
|     assert msg == {'result': 'Created sell order for trade 2.'} | ||||
|  | ||||
|     freqtradebot.state = State.STOPPED | ||||
|     with pytest.raises(RPCException, match=r'.*trader is not running*'): | ||||
|         rpc._rpc_forceexit(None) | ||||
|         rpc._rpc_force_exit(None) | ||||
|  | ||||
|     with pytest.raises(RPCException, match=r'.*trader is not running*'): | ||||
|         rpc._rpc_forceexit('all') | ||||
|         rpc._rpc_force_exit('all') | ||||
|  | ||||
|     freqtradebot.state = State.RUNNING | ||||
|     assert cancel_order_mock.call_count == 0 | ||||
| @@ -849,7 +849,7 @@ def test_rpc_forceexit(default_conf, ticker, fee, mocker) -> None: | ||||
|     ) | ||||
|     # check that the trade is called, which is done by ensuring exchange.cancel_order is called | ||||
|     # and trade amount is updated | ||||
|     rpc._rpc_forceexit('3') | ||||
|     rpc._rpc_force_exit('3') | ||||
|     assert cancel_order_mock.call_count == 1 | ||||
|     assert trade.amount == filled_amount | ||||
|  | ||||
| @@ -877,7 +877,7 @@ def test_rpc_forceexit(default_conf, ticker, fee, mocker) -> None: | ||||
|         } | ||||
|     ) | ||||
|     # check that the trade is called, which is done by ensuring exchange.cancel_order is called | ||||
|     msg = rpc._rpc_forceexit('4') | ||||
|     msg = rpc._rpc_force_exit('4') | ||||
|     assert msg == {'result': 'Created sell order for trade 4.'} | ||||
|     assert cancel_order_mock.call_count == 2 | ||||
|     assert trade.amount == amount | ||||
| @@ -894,7 +894,7 @@ def test_rpc_forceexit(default_conf, ticker, fee, mocker) -> None: | ||||
|             'filled': 0.0 | ||||
|         } | ||||
|     ) | ||||
|     msg = rpc._rpc_forceexit('3') | ||||
|     msg = rpc._rpc_force_exit('3') | ||||
|     assert msg == {'result': 'Created sell order for trade 3.'} | ||||
|     # status quo, no exchange calls | ||||
|     assert cancel_order_mock.call_count == 3 | ||||
| @@ -1182,7 +1182,7 @@ def test_rpc_count(mocker, default_conf, ticker, fee) -> None: | ||||
|     assert counts["current"] == 1 | ||||
|  | ||||
|  | ||||
| def test_rpc_forceentry(mocker, default_conf, ticker, fee, limit_buy_order_open) -> None: | ||||
| def test_rpc_force_entry(mocker, default_conf, ticker, fee, limit_buy_order_open) -> None: | ||||
|     default_conf['forcebuy_enable'] = True | ||||
|     mocker.patch('freqtrade.rpc.telegram.Telegram', MagicMock()) | ||||
|     buy_mm = MagicMock(return_value=limit_buy_order_open) | ||||
| @@ -1221,7 +1221,7 @@ def test_rpc_forceentry(mocker, default_conf, ticker, fee, limit_buy_order_open) | ||||
|     pair = 'LTC/BTC' | ||||
|     trade = rpc._rpc_force_entry(pair, 0.0001, order_type='limit', stake_amount=0.05) | ||||
|     assert trade.stake_amount == 0.05 | ||||
|     assert trade.buy_tag == 'forceentry' | ||||
|     assert trade.buy_tag == 'force_entry' | ||||
|  | ||||
|     # Test not buying | ||||
|     pair = 'XRP/BTC' | ||||
| @@ -1234,7 +1234,7 @@ def test_rpc_forceentry(mocker, default_conf, ticker, fee, limit_buy_order_open) | ||||
|     assert trade is None | ||||
|  | ||||
|  | ||||
| def test_rpc_forceentry_stopped(mocker, default_conf) -> None: | ||||
| def test_rpc_force_entry_stopped(mocker, default_conf) -> None: | ||||
|     default_conf['forcebuy_enable'] = True | ||||
|     default_conf['initial_state'] = 'stopped' | ||||
|     mocker.patch('freqtrade.rpc.telegram.Telegram', MagicMock()) | ||||
| @@ -1247,18 +1247,18 @@ def test_rpc_forceentry_stopped(mocker, default_conf) -> None: | ||||
|         rpc._rpc_force_entry(pair, None) | ||||
|  | ||||
|  | ||||
| def test_rpc_forceentry_disabled(mocker, default_conf) -> None: | ||||
| def test_rpc_force_entry_disabled(mocker, default_conf) -> None: | ||||
|     mocker.patch('freqtrade.rpc.telegram.Telegram', MagicMock()) | ||||
|  | ||||
|     freqtradebot = get_patched_freqtradebot(mocker, default_conf) | ||||
|     patch_get_signal(freqtradebot) | ||||
|     rpc = RPC(freqtradebot) | ||||
|     pair = 'ETH/BTC' | ||||
|     with pytest.raises(RPCException, match=r'Forceentry not enabled.'): | ||||
|     with pytest.raises(RPCException, match=r'Force_entry not enabled.'): | ||||
|         rpc._rpc_force_entry(pair, None) | ||||
|  | ||||
|  | ||||
| def test_rpc_forceentry_wrong_mode(mocker, default_conf) -> None: | ||||
| def test_rpc_force_entry_wrong_mode(mocker, default_conf) -> None: | ||||
|     default_conf['forcebuy_enable'] = True | ||||
|     mocker.patch('freqtrade.rpc.telegram.Telegram', MagicMock()) | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user