feat: show typing status during processing
This commit is contained in:
1 parent
6abea3acc8
commit
33cc2b8a15
4 files changed
+116
-52
No files matched your search
@@ -0,0 +1,27 @@
|
||||
import unittest
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
import bot
|
||||
|
||||
|
||||
class TypingStatusTests(unittest.IsolatedAsyncioTestCase):
|
||||
async def test_sends_immediately_refreshes_and_cancels(self):
|
||||
fake_bot = AsyncMock()
|
||||
with patch.object(bot, "TYPING_REFRESH_SECONDS", 0.01):
|
||||
async with bot.typing_status(fake_bot, 123):
|
||||
await bot.asyncio.sleep(0.025)
|
||||
self.assertGreaterEqual(fake_bot.send_chat_action.await_count, 2)
|
||||
fake_bot.send_chat_action.assert_any_await(123, "typing")
|
||||
|
||||
async def test_stops_refresh_after_context(self):
|
||||
fake_bot = AsyncMock()
|
||||
with patch.object(bot, "TYPING_REFRESH_SECONDS", 0.01):
|
||||
async with bot.typing_status(fake_bot, 123):
|
||||
await bot.asyncio.sleep(0.015)
|
||||
calls_after_exit = fake_bot.send_chat_action.await_count
|
||||
await bot.asyncio.sleep(0.03)
|
||||
self.assertEqual(fake_bot.send_chat_action.await_count, calls_after_exit)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user