Skip to content

Commit

Permalink
Repr tests for all devices added.
Browse files Browse the repository at this point in the history
  • Loading branch information
syssi committed Mar 15, 2018
1 parent f2dadcd commit 74d9281
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 7 deletions.
8 changes: 6 additions & 2 deletions miio/tests/test_airconditioningcompanion.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import string
from unittest import TestCase
from miio import AirConditioningCompanion
from miio.airconditioningcompanion import OperationMode, FanSpeed, Power, \
SwingMode, Led, STORAGE_SLOT_ID
from miio.airconditioningcompanion import (OperationMode, FanSpeed, Power,
SwingMode, Led,
AirConditioningCompanionStatus,
STORAGE_SLOT_ID, )
import pytest

STATE_ON = ['on']
Expand Down Expand Up @@ -78,6 +80,8 @@ def test_off(self):
def test_status(self):
self.device._reset_state()

assert repr(self.state()) == repr(AirConditioningCompanionStatus(self.device.start_state))

assert self.is_on() is False
assert self.state().load_power == 2
assert self.state().air_condition_model == '010500978022222102'
Expand Down
5 changes: 4 additions & 1 deletion miio/tests/test_airhumidifier.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from unittest import TestCase
from miio import AirHumidifier
from miio.airhumidifier import OperationMode, LedBrightness, AirHumidifierException
from miio.airhumidifier import (OperationMode, LedBrightness,
AirHumidifierStatus, AirHumidifierException)
from .dummies import DummyDevice
import pytest

Expand Down Expand Up @@ -69,6 +70,8 @@ def test_off(self):
def test_status(self):
self.device._reset_state()

assert repr(self.state()) == repr(AirHumidifierStatus(self.device.start_state))

assert self.is_on() is True
assert self.state().temperature == self.device.start_state["temp_dec"] / 10.0
assert self.state().humidity == self.device.start_state["humidity"]
Expand Down
3 changes: 3 additions & 0 deletions miio/tests/test_airqualitymonitor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from unittest import TestCase
from miio import AirQualityMonitor
from miio.airqualitymonitor import AirQualityMonitorStatus
from .dummies import DummyDevice
import pytest

Expand Down Expand Up @@ -51,6 +52,8 @@ def test_off(self):
def test_status(self):
self.device._reset_state()

assert repr(self.state()) == repr(AirQualityMonitorStatus(self.device.start_state))

assert self.is_on() is True
assert self.state().aqi == self.device.start_state["aqi"]
assert self.state().battery == self.device.start_state["battery"]
Expand Down
4 changes: 3 additions & 1 deletion miio/tests/test_ceil.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from unittest import TestCase
from miio import Ceil
from miio.ceil import CeilException
from miio.ceil import CeilStatus, CeilException
from .dummies import DummyDevice
import pytest

Expand Down Expand Up @@ -66,6 +66,8 @@ def test_off(self):
def test_status(self):
self.device._reset_state()

assert repr(self.state()) == repr(CeilStatus(self.device.start_state))

assert self.is_on() is True
assert self.state().brightness == self.device.start_state["bright"]
assert self.state().color_temperature == self.device.start_state["cct"]
Expand Down
4 changes: 3 additions & 1 deletion miio/tests/test_philips_bulb.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from unittest import TestCase
from miio import PhilipsBulb
from miio.philips_bulb import PhilipsBulbException
from miio.philips_bulb import PhilipsBulbStatus, PhilipsBulbException
from .dummies import DummyDevice
import pytest

Expand Down Expand Up @@ -60,6 +60,8 @@ def test_off(self):
def test_status(self):
self.device._reset_state()

assert repr(self.state()) == repr(PhilipsBulbStatus(self.device.start_state))

assert self.is_on() is True
assert self.state().brightness == self.device.start_state["bright"]
assert self.state().color_temperature == self.device.start_state["cct"]
Expand Down
4 changes: 3 additions & 1 deletion miio/tests/test_philips_eyecare.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from unittest import TestCase
from miio import PhilipsEyecare
from miio.philips_eyecare import PhilipsEyecareException
from miio.philips_eyecare import PhilipsEyecareStatus, PhilipsEyecareException
from .dummies import DummyDevice
import pytest

Expand Down Expand Up @@ -64,6 +64,8 @@ def test_off(self):
def test_status(self):
self.device._reset_state()

assert repr(self.state()) == repr(PhilipsEyecareStatus(self.device.start_state))

assert self.is_on() is True
assert self.state().brightness == self.device.start_state["bright"]
assert self.state().reminder is (self.device.start_state["notifystatus"] == 'on')
Expand Down
3 changes: 3 additions & 0 deletions miio/tests/test_plug.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from unittest import TestCase
from miio import Plug
from miio.plug import PlugStatus
from .dummies import DummyDevice
import pytest

Expand Down Expand Up @@ -48,5 +49,7 @@ def test_off(self):
def test_status(self):
self.device._reset_state()

assert repr(self.state()) == repr(PlugStatus(self.device.start_state))

assert self.is_on() is True
assert self.state().temperature == self.device.start_state["temperature"]
3 changes: 3 additions & 0 deletions miio/tests/test_plug_v1.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from unittest import TestCase
from miio import PlugV1
from miio.plug_v1 import PlugV1Status
import pytest


Expand Down Expand Up @@ -67,6 +68,8 @@ def test_off(self):
def test_status(self):
self.device._reset_state()

assert repr(self.state()) == repr(PlugV1Status(self.device.start_state))

assert self.is_on() is True
assert self.state().usb_power is True
assert self.state().temperature == self.device.start_state[
Expand Down
3 changes: 3 additions & 0 deletions miio/tests/test_plug_v3.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from unittest import TestCase
from miio import PlugV3
from miio.plug_v3 import PlugV3Status
from .dummies import DummyDevice
import pytest

Expand Down Expand Up @@ -62,6 +63,8 @@ def test_off(self):
def test_status(self):
self.device._reset_state()

assert repr(self.state()) == repr(PlugV3Status(self.device.start_state))

assert self.is_on() is True
assert self.state().usb_power is True
assert self.state().temperature == self.device.start_state[
Expand Down
4 changes: 3 additions & 1 deletion miio/tests/test_powerstrip.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from unittest import TestCase
from miio import PowerStrip
from miio.powerstrip import PowerMode, PowerStripException
from miio.powerstrip import PowerMode, PowerStripStatus, PowerStripException
from .dummies import DummyDevice
import pytest

Expand Down Expand Up @@ -57,6 +57,8 @@ def test_off(self):
def test_status(self):
self.device._reset_state()

assert repr(self.state()) == repr(PowerStripStatus(self.device.start_state))

assert self.is_on() is True
assert self.state().mode == PowerMode(self.device.start_state["mode"])
assert self.state().temperature == self.device.start_state["temperature"]
Expand Down
3 changes: 3 additions & 0 deletions miio/tests/test_vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ def status(self):

def test_status(self):
self.device._reset_state()

assert repr(self.state()) == repr(VacuumStatus(self.device.start_state))

status = self.status()
assert status.is_on is False
assert status.dnd is True
Expand Down
3 changes: 3 additions & 0 deletions miio/tests/test_yeelight.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ def dummylight(request):
class TestYeelight(TestCase):
def test_status(self):
self.device._reset_state()

assert repr(self.state()) == repr(YeelightStatus(self.device.start_state))

status = self.device.status() # type: YeelightStatus
assert status.name == self.device.start_state["name"]
assert status.is_on is False
Expand Down

0 comments on commit 74d9281

Please sign in to comment.