From c68d3d87228c4445f29f7b3f87aa7b5670292eb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Kr=C4=8Dek?= Date: Sun, 13 Oct 2024 19:13:12 +0200 Subject: [PATCH] Fix datetime in unittests --- telegram_downloader_bot/security.py | 3 ++- tests/test_utils.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/telegram_downloader_bot/security.py b/telegram_downloader_bot/security.py index 1ff11b0..06f5371 100644 --- a/telegram_downloader_bot/security.py +++ b/telegram_downloader_bot/security.py @@ -14,7 +14,8 @@ def protected(func): async def wrapper(client, message): if int(message.from_user.id) not in allowed_ids: log.warning( - f"User with ID {message.from_user.id} attempted to text this bot!") + f"User with ID {message.from_user.id} attempted" + "to text this bot!") log.info( f"Only users allowed are: {' '.join(allowed_ids)}") return await message.reply_text("You are not on the list!") diff --git a/tests/test_utils.py b/tests/test_utils.py index 6327daa..e2278d7 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -293,7 +293,7 @@ class TestDownloadTTVideo(unittest.TestCase): def test_download_tt_video_with_valid_video(self, mock_datetime, mock_snaptik): # Mock datetime mock_now = datetime(2023, 1, 1, 12, 0, 0) - mock_datetime.datetime.now.return_value = mock_now + mock_datetime.now.return_value = mock_now # Read the content of valid.mp4 with open(self.valid_video_path, 'rb') as f: @@ -322,7 +322,7 @@ class TestDownloadTTVideo(unittest.TestCase): def test_download_tt_video_with_invalid_video(self, mock_datetime, mock_snaptik): # Mock datetime mock_now = datetime(2023, 1, 1, 12, 0, 0) - mock_datetime.datetime.now.return_value = mock_now + mock_datetime.now.return_value = mock_now # Read the content of invalid.mp4 with open(self.invalid_video_path, 'rb') as f: