diff --git a/src/telegram_notifier.py b/src/telegram_notifier.py index ea252c9..00d9548 100644 --- a/src/telegram_notifier.py +++ b/src/telegram_notifier.py @@ -1,7 +1,7 @@ from __future__ import annotations -import os import asyncio +import os from io import BytesIO import numpy as np @@ -26,9 +26,16 @@ async def send_notification( buffer = BytesIO() image_pil.save(buffer, format='PNG') buffer.seek(0) - await self.bot.send_photo(chat_id=chat_id, photo=buffer, caption=message) + await self.bot.send_photo( + chat_id=chat_id, + photo=buffer, + caption=message, + ) else: - await self.bot.send_message(chat_id=chat_id, text=message) + await self.bot.send_message( + chat_id=chat_id, + text=message, + ) return 200 diff --git a/tests/telegram_notifier_test.py b/tests/telegram_notifier_test.py index b73f5c0..38510a3 100644 --- a/tests/telegram_notifier_test.py +++ b/tests/telegram_notifier_test.py @@ -2,7 +2,8 @@ import unittest from io import BytesIO -from unittest.mock import patch, AsyncMock +from unittest.mock import AsyncMock +from unittest.mock import patch import numpy as np @@ -25,7 +26,10 @@ async def test_send_notification_no_image(self, mock_send_message): mock_send_message.return_value = 'Message sent' chat_id = 'test_chat_id' message = 'Hello, Telegram!' - response = await self.telegram_notifier.send_notification(chat_id, message) + response = await self.telegram_notifier.send_notification( + chat_id, + message, + ) self.assertEqual(response, 'Message sent') mock_send_message.assert_called_once_with( chat_id=chat_id, text=message,