Skip to content

Commit

Permalink
Fail early if trying to re-initialize descriptors
Browse files Browse the repository at this point in the history
  • Loading branch information
rytilahti committed Mar 18, 2024
1 parent 4ffaf8e commit 8edabc1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 6 additions & 4 deletions miio/integrations/roborock/vacuum/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -1066,10 +1066,12 @@ def _initialize_descriptors(self) -> None:
Overridden to collect descriptors also from the update helper.
"""
if not self._initialized:
super()._initialize_descriptors()
res = self.status()
self._descriptors.descriptors_from_object(res)
if self._initialized:
return

Check warning on line 1070 in miio/integrations/roborock/vacuum/vacuum.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/roborock/vacuum/vacuum.py#L1070

Added line #L1070 was not covered by tests

super()._initialize_descriptors()
res = self.status()
self._descriptors.descriptors_from_object(res)

Check warning on line 1074 in miio/integrations/roborock/vacuum/vacuum.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/roborock/vacuum/vacuum.py#L1072-L1074

Added lines #L1072 - L1074 were not covered by tests

@classmethod
def get_device_group(cls):
Expand Down
4 changes: 3 additions & 1 deletion miio/tests/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ def test_supports_miot(mocker):
assert d.supports_miot() is True


@pytest.mark.parametrize("getter_name", ["actions", "settings", "sensors"])
@pytest.mark.parametrize(
"getter_name", ["actions", "settings", "sensors", "descriptors"]
)
def test_cached_descriptors(getter_name, mocker, caplog):
d = Device("127.0.0.1", "68ffffffffffffffffffffffffffffff")
getter = getattr(d, getter_name)
Expand Down

0 comments on commit 8edabc1

Please sign in to comment.