Rename variable, add more tests
This commit is contained in:
parent
ff6967de9e
commit
e75cdd4c27
@ -20,7 +20,7 @@ logger = logging.getLogger(__name__)
|
||||
logger.debug('Included module rpc.telegram ...')
|
||||
|
||||
|
||||
MAX_TELEGRAM_MESSAGE = 4096
|
||||
MAX_TELEGRAM_MESSAGE_LENGTH = 4096
|
||||
|
||||
|
||||
def authorized_only(command_handler: Callable[..., None]) -> Callable[..., Any]:
|
||||
@ -339,7 +339,7 @@ class Telegram(RPC):
|
||||
curr_output = "*{currency}:* not showing <1$ amount \n".format(**currency)
|
||||
|
||||
# Handle overflowing messsage length
|
||||
if len(output + curr_output) >= MAX_TELEGRAM_MESSAGE:
|
||||
if len(output + curr_output) >= MAX_TELEGRAM_MESSAGE_LENGTH:
|
||||
self._send_msg(output, bot=bot)
|
||||
output = curr_output
|
||||
else:
|
||||
|
@ -621,6 +621,11 @@ def test_balance_handle_too_large_response(default_conf, update, mocker) -> None
|
||||
|
||||
telegram._balance(bot=MagicMock(), update=update)
|
||||
assert msg_mock.call_count > 1
|
||||
# Test if wrap happens around 4000 -
|
||||
# and each single currency-output is around 120 characters long so we need
|
||||
# an offset to avoid random test failures
|
||||
assert len(msg_mock.call_args_list[0][0][0]) < 4096
|
||||
assert len(msg_mock.call_args_list[0][0][0]) > (4096 - 120)
|
||||
|
||||
|
||||
def test_start_handle(default_conf, update, mocker) -> None:
|
||||
|
Loading…
Reference in New Issue
Block a user