Skip to content

Commit af9fe69

Browse files
committed
test: add docstring to DummyBot for pylint 10/10
1 parent eedf981 commit af9fe69

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

services/reminders.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import asyncio
22
import logging
3-
from aiogram import Bot
3+
from typing import Any
4+
from aiogram.exceptions import TelegramAPIError
45

56
logger = logging.getLogger(__name__)
67

78

8-
async def schedule_reminders(user_id: int, plan: list, bot: Bot):
9+
async def schedule_reminders(user_id: int, plan: list, bot: Any):
910
"""Schedule reminders for study plan steps and send messages to the user"""
1011
logger.info("Scheduling reminders for user %s", user_id)
1112

@@ -16,7 +17,7 @@ async def schedule_reminders(user_id: int, plan: list, bot: Bot):
1617
reminder_text = f"⏰ Reminder {i}: {task}"
1718
try:
1819
await bot.send_message(user_id, reminder_text)
19-
except Exception as e:
20+
except TelegramAPIError as e:
2021
logger.error("Failed to send reminder to %s: %s", user_id, e)
2122
logger.info("Reminder for %s: day %s — %s", user_id, i, task)
2223
count += 1

tests/test_reminders.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
import pytest
22
from services.reminders import schedule_reminders
33

4+
class DummyBot:
5+
"""A dummy bot for testing schedule_reminders without real Telegram API calls."""
6+
async def send_message(self, user_id, text):
7+
pass
8+
49
@pytest.mark.asyncio
510
async def test_schedule_reminders():
611
user_id = 1
712
plan = ["Task 1", "Task 2", "Task 3", ""] # The last empty one should not be counted
8-
count = await schedule_reminders(user_id, plan)
13+
bot = DummyBot()
14+
count = await schedule_reminders(user_id, plan, bot)
915
assert count == 3

0 commit comments

Comments
 (0)