git reimport

This commit is contained in:
2019-03-15 15:02:19 +04:00
commit 742797309a
90 changed files with 4411 additions and 0 deletions

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