-
Notifications
You must be signed in to change notification settings - Fork 23
Description
This is a great little utility I'm using very much.
However, for the sake of having more expressive tests, it would be great to have a when helper that has the ability to trigger one of the HA "events" as opposed to having to invoke the callback directly.
E.g. a test like this:
def test_entering_the_kitchen(given_that, kitchen_activity, assert_that):
given_that.state_of(devices.KITCHEN_MOTION).is_set_to(states.OFF)
when.state_of(devices.KITCHEN_MOTION).changes_to(states.ON)
assert_that(services.HELPER_SELECT_SET).was.set_to_activity(helpers.KITCHEN_ACTIVITY, activities.PRESENT)as opposed to a test like this:
def test_entering_the_kitchen(given_that, kitchen_activity, assert_that):
given_that.state_of(devices.KITCHEN_MOTION).is_set_to(states.ON)
kitchen_activity.kitchen_activity_controller(None, None, None, None, None)
assert_that(services.HELPER_SELECT_SET).was.set_to_activity(helpers.KITCHEN_ACTIVITY, activities.PRESENT)If I want to create abstractions or unit tests I wouldn't really be using this lib, and I think this lib is actually great for testing the HA boundary, at which point accessing implementation details of an app-daemon class seems like a breach of boundaries.
As an added benefits, it renders the callback tests documented in the "bonus" area redundant, and those too are a bit brittle, as they rely on the thing being called, and the exact parameters set on them.