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