Fix get balance functionality

This commit is contained in:
Anton
2018-05-15 00:31:56 +03:00
parent 6cc8017943
commit f175f48418
3 changed files with 55 additions and 67 deletions

View File

@@ -288,22 +288,18 @@ def test_rpc_balance_handle(default_conf, mocker):
"""
Test rpc_balance() method
"""
mock_balance = [
{
'Currency': 'BTC',
'Balance': 10.0,
'Available': 12.0,
'Pending': 0.0,
'CryptoAddress': 'XXXX',
mock_balance = {
'BTC': {
'free': 10.0,
'total': 12.0,
'used': 2.0,
},
{
'Currency': 'ETH',
'Balance': 0.0,
'Available': 0.0,
'Pending': 0.0,
'CryptoAddress': 'XXXX',
'ETH': {
'free': 0.0,
'total': 0.0,
'used': 0.0,
}
]
}
patch_get_signal(mocker, (True, False))
mocker.patch.multiple(
@@ -324,15 +320,15 @@ def test_rpc_balance_handle(default_conf, mocker):
(error, res) = rpc.rpc_balance(default_conf['fiat_display_currency'])
assert not error
(trade, x, y, z) = res
assert prec_satoshi(x, 10)
assert prec_satoshi(z, 150000)
assert prec_satoshi(x, 12)
assert prec_satoshi(z, 180000)
assert 'USD' in y
assert len(trade) == 1
assert 'BTC' in trade[0]['currency']
assert prec_satoshi(trade[0]['available'], 12)
assert prec_satoshi(trade[0]['balance'], 10)
assert prec_satoshi(trade[0]['pending'], 0)
assert prec_satoshi(trade[0]['est_btc'], 10)
assert prec_satoshi(trade[0]['available'], 10)
assert prec_satoshi(trade[0]['balance'], 12)
assert prec_satoshi(trade[0]['pending'], 2)
assert prec_satoshi(trade[0]['est_btc'], 12)
def test_rpc_start(mocker, default_conf) -> None:

View File

@@ -554,36 +554,29 @@ def test_telegram_balance_handle(default_conf, update, mocker) -> None:
"""
Test _balance() method
"""
mock_balance = [
{
'Currency': 'BTC',
'Balance': 10.0,
'Available': 12.0,
'Pending': 0.0,
'CryptoAddress': 'XXXX',
mock_balance = {
'BTC': {
'total': 12.0,
'free': 12.0,
'used': 0.0
},
{
'Currency': 'ETH',
'Balance': 0.0,
'Available': 0.0,
'Pending': 0.0,
'CryptoAddress': 'XXXX',
'ETH': {
'total': 0.0,
'free': 0.0,
'used': 0.0
},
{
'Currency': 'USDT',
'Balance': 10000.0,
'Available': 0.0,
'Pending': 0.0,
'CryptoAddress': 'XXXX',
'USDT': {
'total': 10000.0,
'free': 10000.0,
'used': 0.0
},
{
'Currency': 'LTC',
'Balance': 10.0,
'Available': 10.0,
'Pending': 0.0,
'CryptoAddress': 'XXXX',
'LTC': {
'total': 10.0,
'free': 10.0,
'used': 0.0
}
]
}
def mock_ticker(symbol, refresh):
"""
@@ -626,7 +619,7 @@ def test_telegram_balance_handle(default_conf, update, mocker) -> None:
assert '*Currency*: USDT' in result
assert 'Balance' in result
assert 'Est. BTC' in result
assert '*BTC*: 12.00000000' in result
assert '*BTC*: 14.00000000' in result
def test_zero_balance_handle(default_conf, update, mocker) -> None:
@@ -636,7 +629,7 @@ def test_zero_balance_handle(default_conf, update, mocker) -> None:
patch_get_signal(mocker, (True, False))
patch_coinmarketcap(mocker, value={'price_usd': 15000.0})
mocker.patch('freqtrade.freqtradebot.exchange.init', MagicMock())
mocker.patch('freqtrade.freqtradebot.exchange.get_balances', return_value=[])
mocker.patch('freqtrade.freqtradebot.exchange.get_balances', return_value={})
msg_mock = MagicMock()
mocker.patch.multiple(