Use modern condition API in condition helper tests#169353
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates Home Assistant’s condition helper test suite to use the modern ConditionChecker API (async_check) while preserving coverage for legacy __call__ behavior.
Changes:
- Replace legacy
test(hass, ...)invocations withtest.async_check(...)across condition helper tests. - Add/adjust tests to confirm
__call__forwarding behavior and AND semantics forasync_conditions_from_config. - Update a comment to reflect “child checkers” terminology.
MartinHjelmare
approved these changes
Apr 28, 2026
Comment on lines
+460
to
+483
| async def test_conditions_from_config_forwards_call( | ||
| hass: HomeAssistant, | ||
| ) -> None: | ||
| """Test that async_conditions_from_config forwards call.""" | ||
| hass.states.async_set("binary_sensor.test_one", STATE_ON) | ||
| hass.states.async_set("binary_sensor.test_two", STATE_ON) | ||
| configs = await condition.async_validate_conditions_config( | ||
| hass, | ||
| [ | ||
| { | ||
| "condition": "state", | ||
| "entity_id": "binary_sensor.test_one", | ||
| "state": STATE_ON, | ||
| }, | ||
| { | ||
| "condition": "state", | ||
| "entity_id": "binary_sensor.test_two", | ||
| "state": STATE_ON, | ||
| }, | ||
| ], | ||
| ) | ||
| test = await condition.async_conditions_from_config( | ||
| hass, configs, logging.getLogger(__name__), "test" | ||
| ) |
Member
There was a problem hiding this comment.
This test looks unrelated.
Contributor
Author
There was a problem hiding this comment.
After modifying the test above, test_conditions_from_config_has_and_semantics there's no longer a direct call to the special checker returned by async_conditions_from_config, so adding this test closes that.
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Proposed change
Use modern condition API in condition helper tests
Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: