git reimport
This commit is contained in:
27
tests/zvk/plugins/vk/test_echo.py
Normal file
27
tests/zvk/plugins/vk/test_echo.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import pytest
|
||||
|
||||
from zvk.bot.bot import Bot
|
||||
from zvk.event.consumer import event_consumer, on_startup
|
||||
from zvk.plugins.vk.api import VKApi
|
||||
from zvk.plugins.vk.command_parser import CommandEventType
|
||||
from zvk.util import emoji
|
||||
|
||||
|
||||
@on_startup
|
||||
async def vk_event_emitter(bot):
|
||||
yield bot.dummy_message_event('.command1')
|
||||
|
||||
|
||||
@event_consumer(consumes=[CommandEventType(command_name='command1')])
|
||||
async def command_consumer(echo):
|
||||
assert (await echo('hi')) == 1
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_echo(bot: Bot, api: VKApi):
|
||||
api.expect('messages.send', peer_id=123, message=f'{emoji.ROBOT}: hi').set_result(1)
|
||||
|
||||
bot.event_queue.register_consumer(vk_event_emitter)
|
||||
bot.event_queue.register_consumer(command_consumer)
|
||||
|
||||
assert await bot.run()
|
Reference in New Issue
Block a user