-
Notifications
You must be signed in to change notification settings - Fork 19
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
Added AppDaemon command. #49
Open
andyinno
wants to merge
5
commits into
HelloThisIsFlo:master
Choose a base branch
from
andyinno:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
|
||
LIGHT = 'light.some_light' | ||
SWITCH = 'switch.some_switch' | ||
INPUT_SELECT = 'input_select.some_input_select' | ||
TRANSITION_DURATION = 2 | ||
|
||
|
||
|
@@ -141,3 +142,10 @@ def test_with_kwargs(self, assert_that, automation): | |
assert_that(LIGHT).was_not.turned_off() | ||
automation.turn_off_light_with_transition(via_helper=True) | ||
assert_that(LIGHT).was.turned_off(transition=TRANSITION_DURATION) | ||
|
||
HelloThisIsFlo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
class TestSelectOption: | ||
class TestViaService: | ||
def test_option_is_set(self, assert_that, automation): | ||
assert_that(INPUT_SELECT).was_not.set_to_option('new_option') | ||
automation.select_option('new_option') | ||
assert_that(INPUT_SELECT).was.set_to_option('new_option') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just one thing I noticed after answering your question above. Could you please add a test for the case when the option is selected via a service call instead of via the helper? :) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@FlorianKempenich I think I need some help here. I don't understand how it works. Never used lambdas and all this part seems to obscure to me.
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.
Yes I agree that part is a bit obscure. I tried to make it as readable as possible, but even for someone familiar w/ lambda it's not the most self-explanatory code . . .
The part with the lambda is for the turned on/off assertions. For turning on/off a light, there are 2 ways to do so, from the automation we can call
self.turn_on(ENTITY)
orself.call_service('turn_on', {'entity_id': ENTITY})
. What the helper does when we callassert_that(ENTITY).was.turned_on()
: it checks both (turn_on
andcall_service
) and see if at least one was called. If none was called, it'll collect errors from both and merge them into 1._capture_assert_failure_exception
runs the lambda and capture any failure orNone
if there was no failure. Then we check inif service_not_called and turn_on_helper_not_called:
if any of the 2 calls returned an error,, and if so we raise a merged errorIn the case of
set_option
, if there is a way to callset_option
via a service call, then we should be able to replicate a similar behavior indeed. I'll now look into why your test is failing :)