Stop clock to avoid random failures on slow CI runs

This commit is contained in:
Matthias 2022-12-08 14:15:29 +01:00
parent 39e19bd0c9
commit bbedc4b63e

View File

@ -12,6 +12,7 @@ from unittest.mock import ANY, MagicMock
import arrow import arrow
import pytest import pytest
import time_machine
from pandas import DataFrame 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
@ -2065,41 +2066,42 @@ def test_send_msg_sell_fill_notification(default_conf, mocker, direction,
default_conf['telegram']['notification_settings']['exit_fill'] = 'on' default_conf['telegram']['notification_settings']['exit_fill'] = 'on'
telegram, _, msg_mock = get_telegram_testobject(mocker, default_conf) telegram, _, msg_mock = get_telegram_testobject(mocker, default_conf)
telegram.send_msg({ with time_machine.travel("2022-09-01 05:00:00 +00:00", tick=False) as t:
'type': RPCMessageType.EXIT_FILL, telegram.send_msg({
'trade_id': 1, 'type': RPCMessageType.EXIT_FILL,
'exchange': 'Binance', 'trade_id': 1,
'pair': 'KEY/ETH', 'exchange': 'Binance',
'leverage': leverage, 'pair': 'KEY/ETH',
'direction': direction, 'leverage': leverage,
'gain': 'loss', 'direction': direction,
'limit': 3.201e-05, 'gain': 'loss',
'amount': 1333.3333333333335, 'limit': 3.201e-05,
'order_type': 'market', 'amount': 1333.3333333333335,
'open_rate': 7.5e-05, 'order_type': 'market',
'close_rate': 3.201e-05, 'open_rate': 7.5e-05,
'profit_amount': -0.05746268, 'close_rate': 3.201e-05,
'profit_ratio': -0.57405275, 'profit_amount': -0.05746268,
'stake_currency': 'ETH', 'profit_ratio': -0.57405275,
'enter_tag': enter_signal, 'stake_currency': 'ETH',
'exit_reason': ExitType.STOP_LOSS.value, 'enter_tag': enter_signal,
'open_date': arrow.utcnow().shift(days=-1, hours=-2, minutes=-30), 'exit_reason': ExitType.STOP_LOSS.value,
'close_date': arrow.utcnow(), 'open_date': arrow.utcnow().shift(days=-1, hours=-2, minutes=-30),
}) 'close_date': arrow.utcnow(),
})
leverage_text = f'*Leverage:* `{leverage}`\n' if leverage and leverage != 1.0 else '' leverage_text = f'*Leverage:* `{leverage}`\n' if leverage and leverage != 1.0 else ''
assert msg_mock.call_args[0][0] == ( assert msg_mock.call_args[0][0] == (
'\N{WARNING SIGN} *Binance (dry):* Exited KEY/ETH (#1)\n' '\N{WARNING SIGN} *Binance (dry):* Exited KEY/ETH (#1)\n'
'*Profit:* `-57.41% (loss: -0.05746268 ETH)`\n' '*Profit:* `-57.41% (loss: -0.05746268 ETH)`\n'
f'*Enter Tag:* `{enter_signal}`\n' f'*Enter Tag:* `{enter_signal}`\n'
'*Exit Reason:* `stop_loss`\n' '*Exit Reason:* `stop_loss`\n'
f"*Direction:* `{direction}`\n" f"*Direction:* `{direction}`\n"
f"{leverage_text}" f"{leverage_text}"
'*Amount:* `1333.33333333`\n' '*Amount:* `1333.33333333`\n'
'*Open Rate:* `0.00007500`\n' '*Open Rate:* `0.00007500`\n'
'*Exit Rate:* `0.00003201`\n' '*Exit Rate:* `0.00003201`\n'
'*Duration:* `1 day, 2:30:00 (1590.0 min)`' '*Duration:* `1 day, 2:30:00 (1590.0 min)`'
) )
def test_send_msg_status_notification(default_conf, mocker) -> None: def test_send_msg_status_notification(default_conf, mocker) -> None: