test: Test telegram init exception handling

This commit is contained in:
Matthias
2025-08-30 20:01:56 +02:00
parent 81a5d49687
commit 2542102280

View File

@@ -177,7 +177,7 @@ def test_telegram_init(default_conf, mocker, caplog) -> None:
assert log_has(message_str, caplog)
async def test_telegram_startup(default_conf, mocker) -> None:
async def test_telegram_startup(default_conf, mocker, caplog) -> None:
app_mock = MagicMock()
app_mock.initialize = AsyncMock()
app_mock.start = AsyncMock()
@@ -193,6 +193,12 @@ async def test_telegram_startup(default_conf, mocker) -> None:
assert app_mock.updater.start_polling.call_count == 1
assert sleep_mock.call_count == 1
# Test telegram Retries and Exceptions
app_mock.start = AsyncMock(side_effect=Exception("Test exception"))
await telegram._startup_telegram()
assert app_mock.start.call_count == 3
assert log_has("Telegram init failed.", caplog)
async def test_telegram_cleanup(
default_conf,