Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
titilambert committed Dec 24, 2020
1 parent d295fe7 commit 60a3468
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion miio/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def send(
:param int retry_count: How many times to retry on error
:param dict extra_parameters: Extra top-level parameters
"""
retry_count = retry_count if retry_count is not None else self._retry_count
retry_count = retry_count if retry_count is not None else self.retry_count
return self._protocol.send(
command, parameters, retry_count, extra_parameters=extra_parameters
)
Expand Down
11 changes: 11 additions & 0 deletions miio/tests/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ def test_get_properties_splitting(mocker, max_properties):
if max_properties is None:
max_properties = len(properties)
assert send.call_count == math.ceil(len(properties) / max_properties)
assert 5 == d._protocol._timeout


def test_timeout_retry(mocker):
send = mocker.patch("miio.miioprotocol.MiIOProtocol.send")
d = Device("127.0.0.1", "68ffffffffffffffffffffffffffffff", timeout=4)
assert 4 == d._protocol._timeout
d.send("fake_command", [], 1)
send.assert_called_with("fake_command", [], 1, extra_parameters=None)
d.send("fake_command", [])
send.assert_called_with("fake_command", [], 3, extra_parameters=None)


def test_unavailable_device_info_raises(mocker):
Expand Down

0 comments on commit 60a3468

Please sign in to comment.