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

Feature Request: Trigger tests using "events" #69

Open
CalamarBicefalo opened this issue Oct 29, 2022 · 1 comment
Open

Feature Request: Trigger tests using "events" #69

CalamarBicefalo opened this issue Oct 29, 2022 · 1 comment

Comments

@CalamarBicefalo
Copy link

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.

@HelloThisIsFlo
Copy link
Owner

Hey 👋

For now, you can consider this project unmaintained, unfortunately.

I haven't had time to maintain this repo in the last few years, in good parts because I moved home and I haven't had a HomeAssistant setup for a very long time. So I'm a bit disconnected with the latest updates, and it's a huge overhead to start everything again, get context and understand how to fix issues on this project

However, I've finally taken the task to set up my server at home again, so I'll probably use this project for my own use again soon.

This means I may bring this project up-to-date in the next few months. No guarantees, obviously, but I may.

Best,
Flo

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

No branches or pull requests

2 participants