1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Add 'bitwise_xor' filter to jinja templates (#104942)

Co-authored-by: Robert Resch <robert@resch.dev>
This commit is contained in:
Lars R
2024-01-10 09:40:52 +01:00
committed by GitHub
parent 554c27a31a
commit bf6b9175a1
2 changed files with 22 additions and 0 deletions

View File

@@ -2405,6 +2405,22 @@ def test_bitwise_or(hass: HomeAssistant) -> None:
assert tpl.async_render() == 8 | 2
@pytest.mark.parametrize(
("value", "xor_value", "expected"),
[(8, 8, 0), (10, 2, 8), (0x8000, 0xFAFA, 31482), (True, False, 1), (True, True, 0)],
)
def test_bitwise_xor(
hass: HomeAssistant, value: Any, xor_value: Any, expected: int
) -> None:
"""Test bitwise_xor method."""
assert (
template.Template("{{ value | bitwise_xor(xor_value) }}", hass).async_render(
{"value": value, "xor_value": xor_value}
)
== expected
)
def test_pack(hass: HomeAssistant, caplog: pytest.LogCaptureFixture) -> None:
"""Test struct pack method."""