Files
zvk2_public/tests/zvk/plugins/vk/test_testing_api.py
2019-03-15 15:02:19 +04:00

28 lines
675 B
Python

import pytest
from zvk.event.consumer import on_startup
@on_startup
async def inc(api, bot):
bot.counter += await api.get_magic.inc(type='test')
bot.counter += await api.get_magic.inc(type='test')
bot.counter += await api.get_magic.inc(type='test')
with pytest.raises(ValueError):
await api.get_magic.inc(type='test')
@pytest.mark.asyncio
async def test_api(bot):
bot.api.expect('get_magic.inc', type='test').set_result(1)
bot.api.expect('get_magic.inc', type='test').set_result(2)
bot.api.expect('get_magic.inc', type='*').set_result(3)
bot.counter = 0
bot.event_queue.register_consumer(inc)
assert await bot.run()
assert bot.counter == 6