Skip to content
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

Merged
merged 7 commits into from Nov 26, 2017

Conversation

syssi
Copy link
Collaborator

@syssi syssi commented Nov 26, 2017

No description provided.

self.device.ambient_on()
assert ambient() == True
self.device.ambient_off()
assert ambient() == False

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:'

return self.device.status().ambient

self.device.ambient_on()
assert ambient() == True

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:'

self.device.reminder_on()
assert reminder() == True
self.device.reminder_off()
assert reminder() == False

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:'

return self.device.status().reminder

self.device.reminder_on()
assert reminder() == True

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:'

self.device.smart_night_light_on()
assert smart_night_light() == True
self.device.smart_night_light_off()
assert smart_night_light() == False

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:'

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"]

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 == (self.device.start_state["notifystatus"] == 'on')
assert self.state().ambient == (self.device.start_state["ambstatus"] == 'on')

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 == (self.device.start_state["notifystatus"] == 'on')

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)

self.device._reset_state()

assert self.is_on() is True

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

self.device._reset_state()

assert self.is_on() is True

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

self.device.ambient_on()
assert ambient() == True
self.device.ambient_off()
assert ambient() == False

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:'

return self.device.status().ambient

self.device.ambient_on()
assert ambient() == True

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:'

self.device.reminder_on()
assert reminder() == True
self.device.reminder_off()
assert reminder() == False

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:'

return self.device.status().reminder

self.device.reminder_on()
assert reminder() == True

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:'

self.device.smart_night_light_on()
assert smart_night_light() == True
self.device.smart_night_light_off()
assert smart_night_light() == False

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:'

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"]

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 == (self.device.start_state["notifystatus"] == 'on')
assert self.state().ambient == (self.device.start_state["ambstatus"] == 'on')

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 == (self.device.start_state["notifystatus"] == 'on')

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)

self.device._reset_state()

assert self.is_on() is True

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

self.device._reset_state()

assert self.is_on() is True

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

@coveralls
Copy link

coveralls commented Nov 26, 2017

Coverage Status

Coverage increased (+5.1%) to 51.175% when pulling 73ec545 on syssi:feature/pytests-philipslights into fc9c4c6 on rytilahti:master.

self.device.automatic_color_temperature_on()
assert automatic_color_temperature() == True
self.device.automatic_color_temperature_off()
assert automatic_color_temperature() == False

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

@coveralls
Copy link

coveralls commented Nov 26, 2017

Coverage Status

Coverage increased (+6.5%) to 52.547% when pulling 49184f1 on syssi:feature/pytests-philipslights into fc9c4c6 on rytilahti:master.

assert scene() == 2



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"]

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)

@syssi syssi changed the title Unit tests for philip lights Unit tests for philips lights Nov 26, 2017
@coveralls
Copy link

coveralls commented Nov 26, 2017

Coverage Status

Coverage increased (+6.3%) to 52.372% when pulling 2199a43 on syssi:feature/pytests-philipslights into fc9c4c6 on rytilahti:master.

Copy link
Owner

@rytilahti rytilahti left a 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
Copy link
Owner

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
Copy link
Owner

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
Copy link
Owner

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
Copy link
Owner

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
Copy link
Owner

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_brightness(10)
assert brightness() == 10
self.device.set_brightness(20)
assert brightness() == 20
Copy link
Owner

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?

self.device.set_color_temperature(30)
assert color_temperature() == 30
self.device.set_color_temperature(20)
assert color_temperature() == 20
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test for incorrect inputs.

@coveralls
Copy link

coveralls commented Nov 26, 2017

Coverage Status

Coverage increased (+6.3%) to 52.372% when pulling dd0fed8 on syssi:feature/pytests-philipslights into fc9c4c6 on rytilahti:master.

@coveralls
Copy link

coveralls commented Nov 26, 2017

Coverage Status

Coverage increased (+7.3%) to 53.386% when pulling 8fd6e18 on syssi:feature/pytests-philipslights into fc9c4c6 on rytilahti:master.

@coveralls
Copy link

coveralls commented Nov 26, 2017

Coverage Status

Coverage increased (+8.5%) to 54.558% when pulling 7987a87 on syssi:feature/pytests-philipslights into fc9c4c6 on rytilahti:master.

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"]

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')

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')

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"]

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')

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)

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)

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"]

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)

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)

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)

@coveralls
Copy link

coveralls commented Nov 26, 2017

Coverage Status

Coverage increased (+8.5%) to 54.558% when pulling 0bf3dca on syssi:feature/pytests-philipslights into fc9c4c6 on rytilahti:master.

@syssi syssi merged commit 3df66fd into rytilahti:master Nov 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants