Add test for newly added functionality
This commit is contained in:
parent
f9d3775d4c
commit
bf992fd9df
@ -12,6 +12,7 @@ from unittest.mock import ANY, MagicMock
|
|||||||
|
|
||||||
import arrow
|
import arrow
|
||||||
import pytest
|
import pytest
|
||||||
|
from pandas import DataFrame
|
||||||
from telegram import Chat, Message, ReplyKeyboardMarkup, Update
|
from telegram import Chat, Message, ReplyKeyboardMarkup, Update
|
||||||
from telegram.error import BadRequest, NetworkError, TelegramError
|
from telegram.error import BadRequest, NetworkError, TelegramError
|
||||||
|
|
||||||
@ -1655,8 +1656,17 @@ def test_show_config_handle(default_conf, update, mocker) -> None:
|
|||||||
(RPCMessageType.ENTRY, 'Long', 'long_signal_01', 1.0),
|
(RPCMessageType.ENTRY, 'Long', 'long_signal_01', 1.0),
|
||||||
(RPCMessageType.ENTRY, 'Long', 'long_signal_01', 5.0),
|
(RPCMessageType.ENTRY, 'Long', 'long_signal_01', 5.0),
|
||||||
(RPCMessageType.ENTRY, 'Short', 'short_signal_01', 2.0)])
|
(RPCMessageType.ENTRY, 'Short', 'short_signal_01', 2.0)])
|
||||||
def test_send_msg_buy_notification(default_conf, mocker, caplog, message_type,
|
def test_send_msg_enter_notification(default_conf, mocker, caplog, message_type,
|
||||||
enter, enter_signal, leverage) -> None:
|
enter, enter_signal, leverage) -> None:
|
||||||
|
default_conf['telegram']['notification_settings']['show_candle'] = 'ohlc'
|
||||||
|
df = DataFrame({
|
||||||
|
'open': [1.1],
|
||||||
|
'high': [2.2],
|
||||||
|
'low': [1.0],
|
||||||
|
'close': [1.5],
|
||||||
|
})
|
||||||
|
mocker.patch('freqtrade.data.dataprovider.DataProvider.get_analyzed_dataframe',
|
||||||
|
return_value=(df, 1))
|
||||||
|
|
||||||
msg = {
|
msg = {
|
||||||
'type': message_type,
|
'type': message_type,
|
||||||
@ -1674,6 +1684,7 @@ def test_send_msg_buy_notification(default_conf, mocker, caplog, message_type,
|
|||||||
'fiat_currency': 'USD',
|
'fiat_currency': 'USD',
|
||||||
'current_rate': 1.099e-05,
|
'current_rate': 1.099e-05,
|
||||||
'amount': 1333.3333333333335,
|
'amount': 1333.3333333333335,
|
||||||
|
'analyzed_candle': {'open': 1.1, 'high': 2.2, 'low': 1.0, 'close': 1.5},
|
||||||
'open_date': arrow.utcnow().shift(hours=-1)
|
'open_date': arrow.utcnow().shift(hours=-1)
|
||||||
}
|
}
|
||||||
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
||||||
@ -1683,6 +1694,7 @@ def test_send_msg_buy_notification(default_conf, mocker, caplog, message_type,
|
|||||||
|
|
||||||
assert msg_mock.call_args[0][0] == (
|
assert msg_mock.call_args[0][0] == (
|
||||||
f'\N{LARGE BLUE CIRCLE} *Binance (dry):* {enter} ETH/BTC (#1)\n'
|
f'\N{LARGE BLUE CIRCLE} *Binance (dry):* {enter} ETH/BTC (#1)\n'
|
||||||
|
'*Candle OHLC*: `1.1, 2.2, 1.0, 1.5`\n'
|
||||||
f'*Enter Tag:* `{enter_signal}`\n'
|
f'*Enter Tag:* `{enter_signal}`\n'
|
||||||
'*Amount:* `1333.33333333`\n'
|
'*Amount:* `1333.33333333`\n'
|
||||||
f'{leverage_text}'
|
f'{leverage_text}'
|
||||||
@ -1710,7 +1722,8 @@ def test_send_msg_buy_notification(default_conf, mocker, caplog, message_type,
|
|||||||
@pytest.mark.parametrize('message_type,enter_signal', [
|
@pytest.mark.parametrize('message_type,enter_signal', [
|
||||||
(RPCMessageType.ENTRY_CANCEL, 'long_signal_01'),
|
(RPCMessageType.ENTRY_CANCEL, 'long_signal_01'),
|
||||||
(RPCMessageType.ENTRY_CANCEL, 'short_signal_01')])
|
(RPCMessageType.ENTRY_CANCEL, 'short_signal_01')])
|
||||||
def test_send_msg_buy_cancel_notification(default_conf, mocker, message_type, enter_signal) -> None:
|
def test_send_msg_enter_cancel_notification(
|
||||||
|
default_conf, mocker, message_type, enter_signal) -> None:
|
||||||
|
|
||||||
telegram, _, msg_mock = get_telegram_testobject(mocker, default_conf)
|
telegram, _, msg_mock = get_telegram_testobject(mocker, default_conf)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user