From 17e8e698a559fb308764db97153d1f45d0752176 Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Fri, 16 Mar 2018 13:15:23 +0100 Subject: [PATCH] Tests for reprs of the status classes (#266) * Test the __repr__ of the status class. * Import fixed. * Access the correct object. * Repr tests for all devices added. * Yeelight tests refactored. * Repr test of the vacuum fixed. * Missing __repr__ method added. * __str__ methods renamed to __repr__. * Yeelight refactoring reverted. * Start state extended by get power output. * Dict extended properly. * Reformatted. * Format updated. --- miio/airconditioningcompanion.py | 20 ++++++++++++++++++++ miio/airhumidifier.py | 2 +- miio/plug.py | 2 +- miio/plug_v1.py | 2 +- miio/plug_v3.py | 2 +- miio/tests/test_airconditioningcompanion.py | 6 ++++-- miio/tests/test_airhumidifier.py | 5 ++++- miio/tests/test_airpurifier.py | 7 ++++--- miio/tests/test_airqualitymonitor.py | 3 +++ miio/tests/test_ceil.py | 4 +++- miio/tests/test_philips_bulb.py | 4 +++- miio/tests/test_philips_eyecare.py | 4 +++- miio/tests/test_plug.py | 3 +++ miio/tests/test_plug_v1.py | 3 +++ miio/tests/test_plug_v3.py | 12 +++++++++--- miio/tests/test_powerstrip.py | 4 +++- miio/tests/test_vacuum.py | 3 +++ miio/tests/test_yeelight.py | 3 +++ 18 files changed, 72 insertions(+), 17 deletions(-) diff --git a/miio/airconditioningcompanion.py b/miio/airconditioningcompanion.py index 0a956f7fa..69c499ab4 100644 --- a/miio/airconditioningcompanion.py +++ b/miio/airconditioningcompanion.py @@ -141,6 +141,26 @@ def mode(self) -> Optional[OperationMode]: except TypeError: return None + def __repr__(self) -> str: + s = "" % \ + (self.power, + self.load_power, + self.air_condition_model, + self.led, + self.temperature, + self.swing_mode, + self.fan_speed, + self.mode) + return s + class AirConditioningCompanion(Device): """Main class representing Xiaomi Air Conditioning Companion.""" diff --git a/miio/airhumidifier.py b/miio/airhumidifier.py index d9a73cae7..dff93a432 100644 --- a/miio/airhumidifier.py +++ b/miio/airhumidifier.py @@ -126,7 +126,7 @@ def button_pressed(self) -> Optional[str]: """Last pressed button.""" return self.data["button_pressed"] - def __str__(self) -> str: + def __repr__(self) -> str: s = " float: """Return temperature.""" return self.data["temperature"] - def __str__(self) -> str: + def __repr__(self) -> str: s = "" % \ (self.power, self.temperature) diff --git a/miio/plug_v1.py b/miio/plug_v1.py index c14de09ba..19b06546a 100644 --- a/miio/plug_v1.py +++ b/miio/plug_v1.py @@ -31,7 +31,7 @@ def usb_power(self) -> bool: def temperature(self) -> float: return self.data["temperature"] - def __str__(self) -> str: + def __repr__(self) -> str: s = "" % \ (self.power, self.usb_power, diff --git a/miio/plug_v3.py b/miio/plug_v3.py index f220ce64b..247604cd5 100644 --- a/miio/plug_v3.py +++ b/miio/plug_v3.py @@ -49,7 +49,7 @@ def wifi_led(self) -> bool: """True if the wifi led is turned on.""" return self.data["wifi_led"] == "on" - def __str__(self) -> str: + def __repr__(self) -> str: s = "