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()