-
-
Notifications
You must be signed in to change notification settings - Fork 561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unit tests for philips lights #133
Conversation
miio/tests/test_philips_eyecare.py
Outdated
self.device.ambient_on() | ||
assert ambient() == True | ||
self.device.ambient_off() | ||
assert ambient() == False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comparison to False should be 'if cond is False:' or 'if not cond:'
miio/tests/test_philips_eyecare.py
Outdated
return self.device.status().ambient | ||
|
||
self.device.ambient_on() | ||
assert ambient() == True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comparison to True should be 'if cond is True:' or 'if cond:'
miio/tests/test_philips_eyecare.py
Outdated
self.device.reminder_on() | ||
assert reminder() == True | ||
self.device.reminder_off() | ||
assert reminder() == False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comparison to False should be 'if cond is False:' or 'if not cond:'
miio/tests/test_philips_eyecare.py
Outdated
return self.device.status().reminder | ||
|
||
self.device.reminder_on() | ||
assert reminder() == True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comparison to True should be 'if cond is True:' or 'if cond:'
miio/tests/test_philips_eyecare.py
Outdated
self.device.smart_night_light_on() | ||
assert smart_night_light() == True | ||
self.device.smart_night_light_off() | ||
assert smart_night_light() == False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comparison to False should be 'if cond is False:' or 'if not cond:'
miio/tests/test_philips_eyecare.py
Outdated
assert self.state().brightness == self.device.start_state["bright"] | ||
assert self.state().reminder == (self.device.start_state["notifystatus"] == 'on') | ||
assert self.state().ambient == (self.device.start_state["ambstatus"] == 'on') | ||
assert self.state().ambient_brightness == self.device.start_state["ambvalue"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (85 > 79 characters)
miio/tests/test_philips_eyecare.py
Outdated
assert self.is_on() is True | ||
assert self.state().brightness == self.device.start_state["bright"] | ||
assert self.state().reminder == (self.device.start_state["notifystatus"] == 'on') | ||
assert self.state().ambient == (self.device.start_state["ambstatus"] == 'on') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (85 > 79 characters)
miio/tests/test_philips_eyecare.py
Outdated
|
||
assert self.is_on() is True | ||
assert self.state().brightness == self.device.start_state["bright"] | ||
assert self.state().reminder == (self.device.start_state["notifystatus"] == 'on') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (89 > 79 characters)
miio/tests/test_philips_bulb.py
Outdated
self.device._reset_state() | ||
|
||
assert self.is_on() is True | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blank line at end of file
miio/tests/test_ceil.py
Outdated
self.device._reset_state() | ||
|
||
assert self.is_on() is True | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blank line at end of file
miio/tests/test_philips_eyecare.py
Outdated
self.device.ambient_on() | ||
assert ambient() == True | ||
self.device.ambient_off() | ||
assert ambient() == False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comparison to False should be 'if cond is False:' or 'if not cond:'
miio/tests/test_philips_eyecare.py
Outdated
return self.device.status().ambient | ||
|
||
self.device.ambient_on() | ||
assert ambient() == True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comparison to True should be 'if cond is True:' or 'if cond:'
miio/tests/test_philips_eyecare.py
Outdated
self.device.reminder_on() | ||
assert reminder() == True | ||
self.device.reminder_off() | ||
assert reminder() == False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comparison to False should be 'if cond is False:' or 'if not cond:'
miio/tests/test_philips_eyecare.py
Outdated
return self.device.status().reminder | ||
|
||
self.device.reminder_on() | ||
assert reminder() == True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comparison to True should be 'if cond is True:' or 'if cond:'
miio/tests/test_philips_eyecare.py
Outdated
self.device.smart_night_light_on() | ||
assert smart_night_light() == True | ||
self.device.smart_night_light_off() | ||
assert smart_night_light() == False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comparison to False should be 'if cond is False:' or 'if not cond:'
miio/tests/test_philips_eyecare.py
Outdated
assert self.state().brightness == self.device.start_state["bright"] | ||
assert self.state().reminder == (self.device.start_state["notifystatus"] == 'on') | ||
assert self.state().ambient == (self.device.start_state["ambstatus"] == 'on') | ||
assert self.state().ambient_brightness == self.device.start_state["ambvalue"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (85 > 79 characters)
miio/tests/test_philips_eyecare.py
Outdated
assert self.is_on() is True | ||
assert self.state().brightness == self.device.start_state["bright"] | ||
assert self.state().reminder == (self.device.start_state["notifystatus"] == 'on') | ||
assert self.state().ambient == (self.device.start_state["ambstatus"] == 'on') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (85 > 79 characters)
miio/tests/test_philips_eyecare.py
Outdated
|
||
assert self.is_on() is True | ||
assert self.state().brightness == self.device.start_state["bright"] | ||
assert self.state().reminder == (self.device.start_state["notifystatus"] == 'on') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (89 > 79 characters)
miio/tests/test_philips_bulb.py
Outdated
self.device._reset_state() | ||
|
||
assert self.is_on() is True | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blank line at end of file
miio/tests/test_ceil.py
Outdated
self.device._reset_state() | ||
|
||
assert self.is_on() is True | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blank line at end of file
miio/tests/test_ceil.py
Outdated
self.device.automatic_color_temperature_on() | ||
assert automatic_color_temperature() == True | ||
self.device.automatic_color_temperature_off() | ||
assert automatic_color_temperature() == False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comparison to False should be 'if cond is False:' or 'if not cond:'
no newline at end of file
miio/tests/test_philips_bulb.py
Outdated
assert scene() == 2 | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blank line at end of file
assert self.state().brightness == self.device.start_state["bright"] | ||
assert self.state().color_temperature == self.device.start_state["cct"] | ||
assert self.state().scene == self.device.start_state["snm"] | ||
assert self.state().delay_off_countdown == self.device.start_state["dv"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (80 > 79 characters)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good in general. I added a couple of notes, in general we should be testing also for unexpected/invalid values from user.
|
||
assert self.is_on() is True | ||
self.device.off() | ||
assert self.is_on() is False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering quite a few devices has the ability for turning on and off, maybe it makes sense to have a single set of tests for all of those devices. For now this is fine though.
self.device.set_brightness(10) | ||
assert brightness() == 10 | ||
self.device.set_brightness(20) | ||
assert brightness() == 20 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test against incorrect values (brightness <0, >100), the bulbs should raise an exception if an incorrect value is thrown at them I think.
self.device.set_color_temperature(30) | ||
assert color_temperature() == 30 | ||
self.device.set_color_temperature(20) | ||
assert color_temperature() == 20 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above for incorrect values.
self.device.delay_off(100) | ||
assert delay_off_countdown() == 100 | ||
self.device.delay_off(200) | ||
assert delay_off_countdown() == 200 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
self.device.set_scene(1) | ||
assert scene() == 1 | ||
self.device.set_scene(2) | ||
assert scene() == 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
miio/tests/test_philips_bulb.py
Outdated
self.device.set_brightness(10) | ||
assert brightness() == 10 | ||
self.device.set_brightness(20) | ||
assert brightness() == 20 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Above comment on incorrect values. Merging with "brightness adjustable" could be done at some point?
miio/tests/test_philips_bulb.py
Outdated
self.device.set_color_temperature(30) | ||
assert color_temperature() == 30 | ||
self.device.set_color_temperature(20) | ||
assert color_temperature() == 20 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test for incorrect inputs.
assert self.state().eyecare is (self.device.start_state["eyecare"] == 'on') | ||
assert self.state().scene == self.device.start_state["scene_num"] | ||
assert self.state().smart_night_light is (self.device.start_state["bls"] == 'on') | ||
assert self.state().delay_off_countdown == self.device.start_state["dvalue"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (84 > 79 characters)
assert self.state().ambient_brightness == self.device.start_state["ambvalue"] | ||
assert self.state().eyecare is (self.device.start_state["eyecare"] == 'on') | ||
assert self.state().scene == self.device.start_state["scene_num"] | ||
assert self.state().smart_night_light is (self.device.start_state["bls"] == 'on') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (89 > 79 characters)
assert self.state().reminder is (self.device.start_state["notifystatus"] == 'on') | ||
assert self.state().ambient is (self.device.start_state["ambstatus"] == 'on') | ||
assert self.state().ambient_brightness == self.device.start_state["ambvalue"] | ||
assert self.state().eyecare is (self.device.start_state["eyecare"] == 'on') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (83 > 79 characters)
assert self.state().brightness == self.device.start_state["bright"] | ||
assert self.state().reminder is (self.device.start_state["notifystatus"] == 'on') | ||
assert self.state().ambient is (self.device.start_state["ambstatus"] == 'on') | ||
assert self.state().ambient_brightness == self.device.start_state["ambvalue"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (85 > 79 characters)
|
||
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') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (89 > 79 characters)
assert self.state().scene == self.device.start_state["snm"] | ||
assert self.state().delay_off_countdown == self.device.start_state["dv"] | ||
assert self.state().smart_night_light is (self.device.start_state["bl"] == 1) | ||
assert self.state().automatic_color_temperature is (self.device.start_state["ac"] == 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (95 > 79 characters)
assert self.state().color_temperature == self.device.start_state["cct"] | ||
assert self.state().scene == self.device.start_state["snm"] | ||
assert self.state().delay_off_countdown == self.device.start_state["dv"] | ||
assert self.state().smart_night_light is (self.device.start_state["bl"] == 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (85 > 79 characters)
assert self.state().brightness == self.device.start_state["bright"] | ||
assert self.state().color_temperature == self.device.start_state["cct"] | ||
assert self.state().scene == self.device.start_state["snm"] | ||
assert self.state().delay_off_countdown == self.device.start_state["dv"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (80 > 79 characters)
"""Set eyecare user scene.""" | ||
return self.send("set_user_scene", [num]) | ||
if number < 1 or number > 4: | ||
raise PhilipsEyecareException("Invalid fixed scene number: %s" % number) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (84 > 79 characters)
def set_scene(self, number: int): | ||
"""Set scene number.""" | ||
if number < 1 or number > 4: | ||
raise PhilipsBulbException("Invalid fixed scene number: %s" % number) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (81 > 79 characters)
No description provided.