Skip to content

Commit

Permalink
Move test_cached_descriptors to test_device.py
Browse files Browse the repository at this point in the history
  • Loading branch information
starkillerOG committed Jan 30, 2023
1 parent 9fe8ca9 commit 2ad5f53
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 14 additions & 0 deletions miio/tests/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,17 @@ def test_supports_miot(mocker):

send.side_effect = None
assert d.supports_miot() is True


@pytest.mark.parametrize("getter_name", ["actions", "settings", "sensors"])
def test_cached_descriptors(getter_name, mocker):
d = Device("127.0.0.1", "68ffffffffffffffffffffffffffffff")
getter = getattr(d, getter_name)
initialize_descriptors = mocker.spy(d, "_initialize_descriptors")
mocker.patch("miio.Device.status")
mocker.patch("miio.Device._sensor_descriptors_from_status", return_value={})
mocker.patch("miio.Device._setting_descriptors_from_status", return_value={})
mocker.patch("miio.Device._action_descriptors", return_value={})
for _i in range(5):
getter()
initialize_descriptors.assert_called_once()
14 changes: 0 additions & 14 deletions miio/tests/test_devicestatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,20 +250,6 @@ def level(self) -> TestEnum:
setter.assert_called_with(TestEnum.Second)


@pytest.mark.parametrize("getter_name", ["actions", "settings", "sensors"])
def test_cached_descriptors(getter_name, mocker):
d = Device("127.0.0.1", "68ffffffffffffffffffffffffffffff")
getter = getattr(d, getter_name)
initialize_descriptors = mocker.spy(d, "_initialize_descriptors")
mocker.patch("miio.Device.status")
mocker.patch("miio.Device._sensor_descriptors_from_status", return_value={})
mocker.patch("miio.Device._setting_descriptors_from_status", return_value={})
mocker.patch("miio.Device._action_descriptors", return_value={})
for _i in range(5):
getter()
initialize_descriptors.assert_called_once()


def test_embed():
class MainStatus(DeviceStatus):
@property
Expand Down

0 comments on commit 2ad5f53

Please sign in to comment.