From dbe7cc7dfb4ecc2e8fa39a86b48ea569c690b78f Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Mon, 27 Nov 2017 13:50:55 +0100 Subject: [PATCH] Unit tests of the Chuang Mi Plug V1 completed. --- miio/tests/test_plug_v1.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/miio/tests/test_plug_v1.py b/miio/tests/test_plug_v1.py index fe0305381..9a1d8bae9 100644 --- a/miio/tests/test_plug_v1.py +++ b/miio/tests/test_plug_v1.py @@ -6,24 +6,21 @@ class DummyPlugV1(PlugV1): def __init__(self, *args, **kwargs): self.state = { - 'power': True, + 'on': True, 'usb_on': True, 'temperature': 32, } self.return_values = { 'get_prop': self._get_state, - 'set_on': lambda: self._set_state("power", True), - 'set_off': lambda: self._set_state("power", False), - 'set_usb_on': lambda: self._set_state("usb_on", True), - 'set_usb_off': lambda: self._set_state("usb_on", False), + 'set_on': lambda x: self._set_state("on", True), + 'set_off': lambda x: self._set_state("on", False), + 'set_usb_on': lambda x: self._set_state("usb_on", True), + 'set_usb_off': lambda x: self._set_state("usb_on", False), } self.start_state = self.state.copy() def send(self, command: str, parameters=None, retry_count=3): """Overridden send() to return values from `self.return_values`.""" - if parameters is None: - return self.return_values[command]() - return self.return_values[command](parameters) def _reset_state(self): @@ -31,9 +28,7 @@ def _reset_state(self): self.state = self.start_state.copy() def _set_state(self, var, value): - """Set a state of a variable, - the value is expected to be an array with length of 1.""" - # print("setting %s = %s" % (var, value)) + """Set a state of a variable""" self.state[var] = value def _get_state(self, props):