Fix xfail and skipped tests to properly pass (#1307)

This commit is contained in:
Bas Nijholt 2025-11-27 10:52:11 -08:00 • committed by GitHub
commit d95f0d4bc6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 28 additions and 19 deletions

View file

@ -1296,13 +1296,17 @@ async def test_restore_off_state(hass, state):
assert not _switch.is_on
@pytest.mark.xfail(reason="Offset is larger than half a day")
async def test_offset_too_large(hass):
"""Test that update fails when the offset is too large."""
"""Test that update fails when the sunrise offset is too large.
A 12-hour offset causes sun events to be out of order (e.g., sunrise after sunset),
which makes the adaptive lighting algorithm fail with a ValueError.
"""
_, switch = await setup_switch(hass, {CONF_SUNRISE_OFFSET: 3600 * 12})
await switch._update_attrs_and_maybe_adapt_lights(
context=switch.create_context("test"),
)
with pytest.raises(ValueError, match="sun events.*not in the expected order"):
await switch._update_attrs_and_maybe_adapt_lights(
context=switch.create_context("test"),
)
await hass.async_block_till_done()