test rcp cleanup
This commit is contained in:
parent
56f903c3ac
commit
82a6d0882a
@ -360,47 +360,18 @@ def test_rpc_balance_handle(default_conf, update, mocker):
|
|||||||
ticker=MagicMock(return_value={'price_usd': 15000.0}),
|
ticker=MagicMock(return_value={'price_usd': 15000.0}),
|
||||||
_cache_symbols=MagicMock(return_value={'BTC': 1}))
|
_cache_symbols=MagicMock(return_value={'BTC': 1}))
|
||||||
|
|
||||||
res = rpc.rpc_balance(default_conf['fiat_display_currency'])
|
(error, res) = rpc.rpc_balance(default_conf['fiat_display_currency'])
|
||||||
assert res
|
assert not error
|
||||||
# FIX: check returned result
|
(trade, x, y, z) = res
|
||||||
# res::
|
assert prec_satoshi(x, 10)
|
||||||
# (False, ([{'currency': 'BTC', 'available': 12.0, 'balance': 10.0,
|
assert prec_satoshi(z, 150000)
|
||||||
# 'pending': 0.0, 'est_btc': 10.0}], 10.0, 'USD', 150000.0))
|
assert y == 'USD'
|
||||||
|
assert len(trade) == 1
|
||||||
|
assert trade[0]['currency'] == 'BTC'
|
||||||
def test_exec_forcesell_open_orders(default_conf, ticker, mocker, limit_buy_order):
|
assert prec_satoshi(trade[0]['available'], 12)
|
||||||
mocker.patch.dict('freqtrade.main._CONF', default_conf)
|
assert prec_satoshi(trade[0]['balance'], 10)
|
||||||
cancel_order_mock = MagicMock()
|
assert prec_satoshi(trade[0]['pending'], 0)
|
||||||
mocker.patch.multiple('freqtrade.rpc.telegram',
|
assert prec_satoshi(trade[0]['est_btc'], 10)
|
||||||
_CONF=default_conf,
|
|
||||||
init=MagicMock(),
|
|
||||||
send_msg=MagicMock())
|
|
||||||
mocker.patch.multiple('freqtrade.main.exchange',
|
|
||||||
get_ticker=ticker,
|
|
||||||
get_order=MagicMock(return_value={
|
|
||||||
'closed': None,
|
|
||||||
'type': 'LIMIT_BUY',
|
|
||||||
}),
|
|
||||||
cancel_order=cancel_order_mock)
|
|
||||||
# Insert an open trade (which we can cancel)
|
|
||||||
# trade = Trade(
|
|
||||||
# pair='BTC_ETH',
|
|
||||||
# open_rate=1,
|
|
||||||
# exchange='BITTREX',
|
|
||||||
# open_order_id='123456789',
|
|
||||||
# amount=1,
|
|
||||||
# fee=0.0,
|
|
||||||
# open_date=datetime.utcnow(),
|
|
||||||
# is_open=False,
|
|
||||||
# )
|
|
||||||
# FIX: Cant make an open trade.....
|
|
||||||
# trade = Trade.query.first()
|
|
||||||
# print('###############', trade)
|
|
||||||
res = rpc.rpc_forcesell('123456789')
|
|
||||||
assert(res)
|
|
||||||
# print(res)
|
|
||||||
# assert cancel_order_mock.call_count == 1
|
|
||||||
# assert trade.is_open is False
|
|
||||||
|
|
||||||
|
|
||||||
def test_performance_handle(
|
def test_performance_handle(
|
||||||
@ -431,7 +402,9 @@ def test_performance_handle(
|
|||||||
|
|
||||||
trade.close_date = datetime.utcnow()
|
trade.close_date = datetime.utcnow()
|
||||||
trade.is_open = False
|
trade.is_open = False
|
||||||
res = rpc.rpc_performance()
|
(error, res) = rpc.rpc_performance()
|
||||||
print(res)
|
assert not error
|
||||||
# assert 'Performance' in msg_mock.call_args_list[0][0][0]
|
assert len(res) == 1
|
||||||
# assert '<code>BTC_ETH\t6.20% (1)</code>' in msg_mock.call_args_list[0][0][0]
|
assert res[0]['pair'] == 'BTC_ETH'
|
||||||
|
assert res[0]['count'] == 1
|
||||||
|
assert prec_satoshi(res[0]['profit'], 6.2)
|
||||||
|
@ -798,7 +798,6 @@ def test_status(default_conf, update, mocker):
|
|||||||
rpc_trade_status=MagicMock(return_value=(False, [1, 2, 3])),
|
rpc_trade_status=MagicMock(return_value=(False, [1, 2, 3])),
|
||||||
_status_table=status_table,
|
_status_table=status_table,
|
||||||
send_msg=msg_mock)
|
send_msg=msg_mock)
|
||||||
print(update)
|
|
||||||
_status(bot=MagicMock(), update=update)
|
_status(bot=MagicMock(), update=update)
|
||||||
assert msg_mock.call_count == 3
|
assert msg_mock.call_count == 3
|
||||||
update.message.text = MagicMock()
|
update.message.text = MagicMock()
|
||||||
|
Loading…
Reference in New Issue
Block a user