Skip to content

Commit

Permalink
Raise DeviceError on unsupported methods for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rytilahti committed Feb 3, 2023
1 parent 94cae65 commit df9de6c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion miio/tests/dummies.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from miio import DeviceError


class DummyMiIOProtocol:
"""DummyProtocol allows you mock MiIOProtocol."""

Expand All @@ -8,7 +11,10 @@ def __init__(self, dummy_device):

def send(self, command: str, parameters=None, retry_count=3, extra_parameters=None):
"""Overridden send() to return values from `self.return_values`."""
return self.dummy_device.return_values[command](parameters)
try:
return self.dummy_device.return_values[command](parameters)
except KeyError:
raise DeviceError({"code": -32601, "message": "Method not found."})


class DummyDevice:
Expand Down

0 comments on commit df9de6c

Please sign in to comment.