2022-03-21 10:02:48 +00:00
|
|
|
"""Test the update significant change platform."""
|
2024-03-08 13:44:56 +00:00
|
|
|
|
2022-03-21 10:02:48 +00:00
|
|
|
from homeassistant.components.update.const import (
|
|
|
|
ATTR_IN_PROGRESS,
|
2022-04-01 18:11:17 +00:00
|
|
|
ATTR_INSTALLED_VERSION,
|
2022-03-21 10:02:48 +00:00
|
|
|
ATTR_LATEST_VERSION,
|
|
|
|
ATTR_RELEASE_SUMMARY,
|
|
|
|
ATTR_RELEASE_URL,
|
|
|
|
ATTR_SKIPPED_VERSION,
|
|
|
|
ATTR_TITLE,
|
|
|
|
)
|
|
|
|
from homeassistant.components.update.significant_change import (
|
|
|
|
async_check_significant_change,
|
|
|
|
)
|
|
|
|
from homeassistant.const import STATE_OFF, STATE_ON
|
|
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
|
|
|
|
|
|
|
|
async def test_significant_change(hass: HomeAssistant) -> None:
|
|
|
|
"""Detect update significant changes."""
|
|
|
|
assert async_check_significant_change(hass, STATE_ON, {}, STATE_OFF, {})
|
|
|
|
assert async_check_significant_change(hass, STATE_OFF, {}, STATE_ON, {})
|
|
|
|
assert not async_check_significant_change(hass, STATE_OFF, {}, STATE_OFF, {})
|
|
|
|
assert not async_check_significant_change(hass, STATE_ON, {}, STATE_ON, {})
|
|
|
|
|
|
|
|
attrs = {
|
2022-04-01 18:11:17 +00:00
|
|
|
ATTR_INSTALLED_VERSION: "1.0.0",
|
2022-03-21 10:02:48 +00:00
|
|
|
ATTR_IN_PROGRESS: False,
|
|
|
|
ATTR_LATEST_VERSION: "1.0.1",
|
|
|
|
ATTR_RELEASE_SUMMARY: "Fixes!",
|
|
|
|
ATTR_RELEASE_URL: "https://www.example.com",
|
|
|
|
ATTR_SKIPPED_VERSION: None,
|
|
|
|
ATTR_TITLE: "Piece of Software",
|
|
|
|
}
|
|
|
|
assert not async_check_significant_change(hass, STATE_ON, attrs, STATE_ON, attrs)
|
|
|
|
|
|
|
|
assert async_check_significant_change(
|
|
|
|
hass,
|
|
|
|
STATE_ON,
|
|
|
|
attrs,
|
|
|
|
STATE_ON,
|
2022-04-01 18:11:17 +00:00
|
|
|
attrs.copy() | {ATTR_INSTALLED_VERSION: "1.0.1"},
|
2022-03-21 10:02:48 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert async_check_significant_change(
|
|
|
|
hass,
|
|
|
|
STATE_ON,
|
|
|
|
attrs,
|
|
|
|
STATE_ON,
|
|
|
|
attrs.copy() | {ATTR_LATEST_VERSION: "1.0.2"},
|
|
|
|
)
|
|
|
|
|
|
|
|
assert not async_check_significant_change(
|
|
|
|
hass,
|
|
|
|
STATE_ON,
|
|
|
|
attrs,
|
|
|
|
STATE_ON,
|
|
|
|
attrs.copy() | {ATTR_IN_PROGRESS: True},
|
|
|
|
)
|
|
|
|
|
|
|
|
assert not async_check_significant_change(
|
|
|
|
hass,
|
|
|
|
STATE_ON,
|
|
|
|
attrs,
|
|
|
|
STATE_ON,
|
|
|
|
attrs.copy() | {ATTR_RELEASE_SUMMARY: "More fixes!"},
|
|
|
|
)
|
|
|
|
|
|
|
|
assert not async_check_significant_change(
|
|
|
|
hass,
|
|
|
|
STATE_ON,
|
|
|
|
attrs,
|
|
|
|
STATE_ON,
|
|
|
|
attrs.copy() | {ATTR_RELEASE_URL: "https://www.example.com/changed_url"},
|
|
|
|
)
|
|
|
|
|
|
|
|
assert not async_check_significant_change(
|
|
|
|
hass,
|
|
|
|
STATE_ON,
|
|
|
|
attrs,
|
|
|
|
STATE_ON,
|
|
|
|
attrs.copy() | {ATTR_SKIPPED_VERSION: "1.0.0"},
|
|
|
|
)
|
|
|
|
|
|
|
|
assert not async_check_significant_change(
|
|
|
|
hass,
|
|
|
|
STATE_ON,
|
|
|
|
attrs,
|
|
|
|
STATE_ON,
|
|
|
|
attrs.copy() | {ATTR_TITLE: "Renamed the software..."},
|
|
|
|
)
|