1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
import asyncio
import pytest
from roborock.exceptions import VacuumError
from roborock.roborock_future import RoborockFuture
def test_can_create():
RoborockFuture(1)
@pytest.mark.asyncio
async def test_set_result():
rq = RoborockFuture(1)
rq.set_result("test")
assert await rq.async_get(1) == "test"
@pytest.mark.asyncio
async def test_set_exception():
rq = RoborockFuture(1)
rq.set_exception(VacuumError("test"))
with pytest.raises(VacuumError):
assert await rq.async_get(1)
@pytest.mark.asyncio
async def test_get_timeout():
rq = RoborockFuture(1)
with pytest.raises(asyncio.TimeoutError):
await rq.async_get(0.01)
|