Update tests
This commit is contained in:
@@ -49,8 +49,10 @@ class Balance(BaseModel):
|
|||||||
class Balances(BaseModel):
|
class Balances(BaseModel):
|
||||||
currencies: List[Balance]
|
currencies: List[Balance]
|
||||||
total: float
|
total: float
|
||||||
|
total_bot: float
|
||||||
symbol: str
|
symbol: str
|
||||||
value: float
|
value: float
|
||||||
|
value_bot: float
|
||||||
stake: str
|
stake: str
|
||||||
note: str
|
note: str
|
||||||
starting_capital: float
|
starting_capital: float
|
||||||
|
|||||||
@@ -552,6 +552,7 @@ def test_rpc_balance_handle(default_conf, mocker, tickers):
|
|||||||
'leverage': 1.0,
|
'leverage': 1.0,
|
||||||
'position': 0.0,
|
'position': 0.0,
|
||||||
'side': 'long',
|
'side': 'long',
|
||||||
|
'is_bot_managed': True,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'free': 1.0,
|
'free': 1.0,
|
||||||
@@ -564,7 +565,7 @@ def test_rpc_balance_handle(default_conf, mocker, tickers):
|
|||||||
'leverage': 1.0,
|
'leverage': 1.0,
|
||||||
'position': 0.0,
|
'position': 0.0,
|
||||||
'side': 'long',
|
'side': 'long',
|
||||||
|
'is_bot_managed': False,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'free': 5.0,
|
'free': 5.0,
|
||||||
@@ -577,6 +578,7 @@ def test_rpc_balance_handle(default_conf, mocker, tickers):
|
|||||||
'leverage': 1.0,
|
'leverage': 1.0,
|
||||||
'position': 0.0,
|
'position': 0.0,
|
||||||
'side': 'long',
|
'side': 'long',
|
||||||
|
'is_bot_managed': False,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'free': 0.0,
|
'free': 0.0,
|
||||||
@@ -589,8 +591,11 @@ def test_rpc_balance_handle(default_conf, mocker, tickers):
|
|||||||
'leverage': 5.0,
|
'leverage': 5.0,
|
||||||
'position': 1000.0,
|
'position': 1000.0,
|
||||||
'side': 'short',
|
'side': 'short',
|
||||||
|
'is_bot_managed': True,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
assert pytest.approx(result['total_bot']) == 10
|
||||||
|
assert pytest.approx(result['total']) == 30.309096
|
||||||
assert result['starting_capital'] == 10
|
assert result['starting_capital'] == 10
|
||||||
assert result['starting_capital_ratio'] == 0.0
|
assert result['starting_capital_ratio'] == 0.0
|
||||||
|
|
||||||
|
|||||||
@@ -486,7 +486,10 @@ def test_api_balance(botclient, mocker, rpc_balance, tickers):
|
|||||||
'leverage': 1.0,
|
'leverage': 1.0,
|
||||||
'position': 0.0,
|
'position': 0.0,
|
||||||
'side': 'long',
|
'side': 'long',
|
||||||
|
'is_bot_managed': True,
|
||||||
}
|
}
|
||||||
|
assert response['total'] == 12.159513094
|
||||||
|
assert response['total_bot'] == 12.0
|
||||||
assert 'starting_capital' in response
|
assert 'starting_capital' in response
|
||||||
assert 'starting_capital_fiat' in response
|
assert 'starting_capital_fiat' in response
|
||||||
assert 'starting_capital_pct' in response
|
assert 'starting_capital_pct' in response
|
||||||
|
|||||||
@@ -783,19 +783,27 @@ def test_telegram_balance_handle(default_conf, update, mocker, rpc_balance, tick
|
|||||||
patch_get_signal(freqtradebot)
|
patch_get_signal(freqtradebot)
|
||||||
|
|
||||||
telegram._balance(update=update, context=MagicMock())
|
telegram._balance(update=update, context=MagicMock())
|
||||||
|
context = MagicMock()
|
||||||
|
context.args = ["full"]
|
||||||
|
telegram._balance(update=update, context=context)
|
||||||
result = msg_mock.call_args_list[0][0][0]
|
result = msg_mock.call_args_list[0][0][0]
|
||||||
assert msg_mock.call_count == 1
|
result_full = msg_mock.call_args_list[1][0][0]
|
||||||
|
assert msg_mock.call_count == 2
|
||||||
assert '*BTC:*' in result
|
assert '*BTC:*' in result
|
||||||
assert '*ETH:*' not in result
|
assert '*ETH:*' not in result
|
||||||
assert '*USDT:*' not in result
|
assert '*USDT:*' not in result
|
||||||
assert '*EUR:*' not in result
|
assert '*EUR:*' not in result
|
||||||
assert '*LTC:*' in result
|
assert '*LTC:*' not in result
|
||||||
|
|
||||||
|
assert '*LTC:*' in result_full
|
||||||
assert '*XRP:*' not in result
|
assert '*XRP:*' not in result
|
||||||
assert 'Balance:' in result
|
assert 'Balance:' in result
|
||||||
assert 'Est. BTC:' in result
|
assert 'Est. BTC:' in result
|
||||||
assert 'BTC: 12' in result
|
assert 'BTC: 12' in result
|
||||||
assert "*3 Other Currencies (< 0.0001 BTC):*" in result
|
assert "*3 Other Currencies (< 0.0001 BTC):*" in result
|
||||||
assert 'BTC: 0.00000309' in result
|
assert 'BTC: 0.00000309' in result
|
||||||
|
assert '*Estimated Value*:' in result_full
|
||||||
|
assert '*Estimated Value (Bot managed assets only)*:' in result
|
||||||
|
|
||||||
|
|
||||||
def test_balance_handle_empty_response(default_conf, update, mocker) -> None:
|
def test_balance_handle_empty_response(default_conf, update, mocker) -> None:
|
||||||
@@ -840,12 +848,15 @@ def test_balance_handle_too_large_response(default_conf, update, mocker) -> None
|
|||||||
'leverage': 1.0,
|
'leverage': 1.0,
|
||||||
'position': 0.0,
|
'position': 0.0,
|
||||||
'side': 'long',
|
'side': 'long',
|
||||||
|
'is_bot_managed': True,
|
||||||
})
|
})
|
||||||
mocker.patch('freqtrade.rpc.rpc.RPC._rpc_balance', return_value={
|
mocker.patch('freqtrade.rpc.rpc.RPC._rpc_balance', return_value={
|
||||||
'currencies': balances,
|
'currencies': balances,
|
||||||
'total': 100.0,
|
'total': 100.0,
|
||||||
|
'total_bot': 100.0,
|
||||||
'symbol': 100.0,
|
'symbol': 100.0,
|
||||||
'value': 1000.0,
|
'value': 1000.0,
|
||||||
|
'value_bot': 1000.0,
|
||||||
'starting_capital': 1000,
|
'starting_capital': 1000,
|
||||||
'starting_capital_fiat': 1000,
|
'starting_capital_fiat': 1000,
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user