Fix: Correct asyncio.sleep call count in long message test

This commit is contained in:
cyclop-bot
2025-06-03 13:10:06 -05:00
parent c416f63f76
commit b1e71bc80e
+3 -1
View File
@@ -146,8 +146,10 @@ class TestTelegramHelper(unittest.IsolatedAsyncioTestCase):
with patch('asyncio.sleep', new_callable=AsyncMock) as mock_sleep: with patch('asyncio.sleep', new_callable=AsyncMock) as mock_sleep:
await self.telegram_helper.handle_message(self.mock_update, self.mock_context) await self.telegram_helper.handle_message(self.mock_update, self.mock_context)
# Initial call + two chunks # Initial call to reply_text + two chunks sent via reply_text
self.assertEqual(self.mock_update.message.reply_text.call_count, 1 + 2) self.assertEqual(self.mock_update.message.reply_text.call_count, 1 + 2)
# asyncio.sleep is called once for each chunk *after* the first one.
# For 2 chunks, it's called once.
self.assertEqual(mock_sleep.call_count, 1) # One sleep for the second chunk self.assertEqual(mock_sleep.call_count, 1) # One sleep for the second chunk
@patch.object(TelegramHelper, '_handle_message_logic', new_callable=AsyncMock) @patch.object(TelegramHelper, '_handle_message_logic', new_callable=AsyncMock)