1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
from miio import DeviceStatus
def test_multiple():
class MultipleProperties(DeviceStatus):
@property
def first(self):
return "first"
@property
def second(self):
return "second"
assert (
repr(MultipleProperties()) == "<MultipleProperties first=first second=second>"
)
def test_empty():
class EmptyStatus(DeviceStatus):
pass
assert repr(EmptyStatus() == "<EmptyStatus>")
def test_exception():
class StatusWithException(DeviceStatus):
@property
def raise_exception(self):
raise Exception("test")
assert (
repr(StatusWithException()) == "<StatusWithException raise_exception=Exception>"
)
def test_inheritance():
class Parent(DeviceStatus):
@property
def from_parent(self):
return True
class Child(Parent):
@property
def from_child(self):
return True
assert repr(Child()) == "<Child from_child=True from_parent=True>"
def test_list():
class List(DeviceStatus):
@property
def return_list(self):
return [0, 1, 2]
assert repr(List()) == "<List return_list=[0, 1, 2]>"
def test_none():
class NoneStatus(DeviceStatus):
@property
def return_none(self):
return None
assert repr(NoneStatus()) == "<NoneStatus return_none=None>"
|