forked from Python-roborock/python-roborock
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_device.py
More file actions
40 lines (29 loc) · 1.02 KB
/
test_device.py
File metadata and controls
40 lines (29 loc) · 1.02 KB
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
33
34
35
36
37
38
39
40
"""Tests for the Device class."""
from unittest.mock import AsyncMock, Mock
from roborock.containers import HomeData, UserData
from roborock.devices.device import DeviceVersion, RoborockDevice
from .. import mock_data
USER_DATA = UserData.from_dict(mock_data.USER_DATA)
HOME_DATA = HomeData.from_dict(mock_data.HOME_DATA_RAW)
async def test_device_connection() -> None:
"""Test the Device connection setup."""
unsub = Mock()
subscribe = AsyncMock()
subscribe.return_value = unsub
mqtt_channel = AsyncMock()
mqtt_channel.subscribe = subscribe
device = RoborockDevice(
USER_DATA,
device_info=HOME_DATA.devices[0],
product_info=HOME_DATA.products[0],
mqtt_channel=mqtt_channel,
)
assert device.duid == "abc123"
assert device.name == "Roborock S7 MaxV"
assert device.device_version == DeviceVersion.V1
assert not subscribe.called
await device.connect()
assert subscribe.called
assert not unsub.called
await device.close()
assert unsub.called