git reimport
This commit is contained in:
0
tests/zvk/bot/__init__.py
Normal file
0
tests/zvk/bot/__init__.py
Normal file
22
tests/zvk/bot/test_bot.py
Normal file
22
tests/zvk/bot/test_bot.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import asyncio
|
||||
|
||||
import pytest
|
||||
|
||||
from zvk.event.consumer import on_startup
|
||||
|
||||
|
||||
@on_startup
|
||||
async def kamikaze(bot):
|
||||
bot.die()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_do_commit_die(bot):
|
||||
bot.event_queue.register_consumer(kamikaze)
|
||||
assert await bot.run()
|
||||
|
||||
|
||||
def test_nonasync(bot):
|
||||
asyncio.run(bot.run())
|
||||
|
||||
|
32
tests/zvk/bot/test_trunk.py
Normal file
32
tests/zvk/bot/test_trunk.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import asyncio
|
||||
|
||||
import pytest
|
||||
|
||||
from zvk.bot.trunk import Trunk
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_trunk():
|
||||
trunk = Trunk()
|
||||
trunk.initialize()
|
||||
|
||||
counter = [0]
|
||||
|
||||
async def f1():
|
||||
counter[0] += await trunk.get('thing')
|
||||
|
||||
async def f2():
|
||||
await asyncio.sleep(0.1)
|
||||
trunk.set('thing', 1)
|
||||
|
||||
async def f3():
|
||||
await asyncio.sleep(0.2)
|
||||
counter[0] += await trunk.get('thing')
|
||||
|
||||
await asyncio.gather(
|
||||
f1(),
|
||||
f2(),
|
||||
f3(),
|
||||
)
|
||||
|
||||
assert counter[0] == 2
|
Reference in New Issue
Block a user