Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions tests/helpers/test_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from contextlib import AbstractContextManager, nullcontext as does_not_raise
from datetime import timedelta
import io
import logging
from typing import Any
from unittest.mock import AsyncMock, Mock, patch

Expand Down Expand Up @@ -424,6 +425,38 @@ async def test_and_condition_list_shorthand(hass: HomeAssistant) -> None:
assert test(hass)


async def test_conditions_from_config_has_and_semantics(
hass: HomeAssistant,
) -> None:
"""Test that async_conditions_from_config returns a callable with AND semantics."""
hass.states.async_set("binary_sensor.test_one", STATE_ON)
hass.states.async_set("binary_sensor.test_two", STATE_ON)
configs = [
Comment thread
arturpragacz marked this conversation as resolved.
Outdated
await condition.async_validate_condition_config(
hass,
{
"condition": "state",
"entity_id": "binary_sensor.test_one",
"state": STATE_ON,
},
),
await condition.async_validate_condition_config(
hass,
{
"condition": "state",
"entity_id": "binary_sensor.test_two",
"state": STATE_ON,
},
),
]
test = await condition.async_conditions_from_config(
hass, configs, logging.getLogger(__name__), "test"
)
assert test(hass) is True
hass.states.async_set("binary_sensor.test_two", STATE_OFF)
assert test(hass) is False
Comment thread
emontnemery marked this conversation as resolved.
Outdated


async def test_malformed_and_condition_list_shorthand(hass: HomeAssistant) -> None:
"""Test the 'and' condition list shorthand syntax check."""
config = {
Expand Down
Loading