Skip to content

Commit 2542102

Browse files
committed
test: Test telegram init exception handling
1 parent 81a5d49 commit 2542102

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tests/rpc/test_rpc_telegram.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def test_telegram_init(default_conf, mocker, caplog) -> None:
177177
assert log_has(message_str, caplog)
178178

179179

180-
async def test_telegram_startup(default_conf, mocker) -> None:
180+
async def test_telegram_startup(default_conf, mocker, caplog) -> None:
181181
app_mock = MagicMock()
182182
app_mock.initialize = AsyncMock()
183183
app_mock.start = AsyncMock()
@@ -193,6 +193,12 @@ async def test_telegram_startup(default_conf, mocker) -> None:
193193
assert app_mock.updater.start_polling.call_count == 1
194194
assert sleep_mock.call_count == 1
195195

196+
# Test telegram Retries and Exceptions
197+
app_mock.start = AsyncMock(side_effect=Exception("Test exception"))
198+
await telegram._startup_telegram()
199+
assert app_mock.start.call_count == 3
200+
assert log_has("Telegram init failed.", caplog)
201+
196202

197203
async def test_telegram_cleanup(
198204
default_conf,

0 commit comments

Comments
 (0)