mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Remove deprecated Updater integration (#68981)
* Remove deprecated Updater integration * Remove updater mock
This commit is contained in:
parent
4e2b6db397
commit
2c66ac6203
@ -1076,8 +1076,6 @@ build.json @home-assistant/supervisor
|
|||||||
/tests/components/upcloud/ @scop
|
/tests/components/upcloud/ @scop
|
||||||
/homeassistant/components/update/ @home-assistant/core
|
/homeassistant/components/update/ @home-assistant/core
|
||||||
/tests/components/update/ @home-assistant/core
|
/tests/components/update/ @home-assistant/core
|
||||||
/homeassistant/components/updater/ @home-assistant/core
|
|
||||||
/tests/components/updater/ @home-assistant/core
|
|
||||||
/homeassistant/components/upnp/ @StevenLooman @ehendrix23
|
/homeassistant/components/upnp/ @StevenLooman @ehendrix23
|
||||||
/tests/components/upnp/ @StevenLooman @ehendrix23
|
/tests/components/upnp/ @StevenLooman @ehendrix23
|
||||||
/homeassistant/components/uptime/ @frenck
|
/homeassistant/components/uptime/ @frenck
|
||||||
|
@ -1,141 +0,0 @@
|
|||||||
"""Support to check for available updates."""
|
|
||||||
import asyncio
|
|
||||||
from datetime import timedelta
|
|
||||||
import logging
|
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from awesomeversion import AwesomeVersion
|
|
||||||
import voluptuous as vol
|
|
||||||
|
|
||||||
from homeassistant.components import hassio
|
|
||||||
from homeassistant.const import Platform, __version__ as current_version
|
|
||||||
from homeassistant.core import HomeAssistant
|
|
||||||
from homeassistant.helpers import discovery, update_coordinator
|
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
|
||||||
import homeassistant.helpers.config_validation as cv
|
|
||||||
from homeassistant.helpers.typing import ConfigType
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
ATTR_RELEASE_NOTES = "release_notes"
|
|
||||||
ATTR_NEWEST_VERSION = "newest_version"
|
|
||||||
|
|
||||||
CONF_REPORTING = "reporting"
|
|
||||||
CONF_COMPONENT_REPORTING = "include_used_components"
|
|
||||||
|
|
||||||
DOMAIN = "updater"
|
|
||||||
|
|
||||||
UPDATER_URL = "https://www.home-assistant.io/version.json"
|
|
||||||
|
|
||||||
|
|
||||||
CONFIG_SCHEMA = vol.Schema(
|
|
||||||
{
|
|
||||||
DOMAIN: {
|
|
||||||
vol.Optional(CONF_REPORTING): cv.boolean,
|
|
||||||
vol.Optional(CONF_COMPONENT_REPORTING): cv.boolean,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
extra=vol.ALLOW_EXTRA,
|
|
||||||
)
|
|
||||||
|
|
||||||
RESPONSE_SCHEMA = vol.Schema(
|
|
||||||
{vol.Required("current_version"): cv.string, vol.Required("release_notes"): cv.url},
|
|
||||||
extra=vol.REMOVE_EXTRA,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class Updater:
|
|
||||||
"""Updater class for data exchange."""
|
|
||||||
|
|
||||||
def __init__(
|
|
||||||
self, update_available: bool, newest_version: str, release_notes: str
|
|
||||||
) -> None:
|
|
||||||
"""Initialize attributes."""
|
|
||||||
self.update_available = update_available
|
|
||||||
self.release_notes = release_notes
|
|
||||||
self.newest_version = newest_version
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|
||||||
"""Set up the updater component."""
|
|
||||||
_LOGGER.warning(
|
|
||||||
"The updater integration has been deprecated and will be removed in 2022.5, "
|
|
||||||
"please remove it from your configuration"
|
|
||||||
)
|
|
||||||
|
|
||||||
async def check_new_version() -> Updater:
|
|
||||||
"""Check if a new version is available and report if one is."""
|
|
||||||
# Skip on dev
|
|
||||||
if "dev" in current_version:
|
|
||||||
return Updater(False, "", "")
|
|
||||||
|
|
||||||
newest, release_notes = await get_newest_version(hass)
|
|
||||||
|
|
||||||
_LOGGER.debug("Fetched version %s: %s", newest, release_notes)
|
|
||||||
|
|
||||||
# Load data from Supervisor
|
|
||||||
if hassio.is_hassio(hass):
|
|
||||||
core_info = hassio.get_core_info(hass)
|
|
||||||
newest = core_info["version_latest"]
|
|
||||||
|
|
||||||
# Validate version
|
|
||||||
update_available = False
|
|
||||||
if AwesomeVersion(newest) > AwesomeVersion(current_version):
|
|
||||||
_LOGGER.debug(
|
|
||||||
"The latest available version of Home Assistant is %s", newest
|
|
||||||
)
|
|
||||||
update_available = True
|
|
||||||
elif AwesomeVersion(newest) == AwesomeVersion(current_version):
|
|
||||||
_LOGGER.debug(
|
|
||||||
"You are on the latest version (%s) of Home Assistant", newest
|
|
||||||
)
|
|
||||||
elif AwesomeVersion(newest) < AwesomeVersion(current_version):
|
|
||||||
_LOGGER.debug(
|
|
||||||
"Local version (%s) is newer than the latest available version (%s)",
|
|
||||||
current_version,
|
|
||||||
newest,
|
|
||||||
)
|
|
||||||
|
|
||||||
_LOGGER.debug("Update available: %s", update_available)
|
|
||||||
|
|
||||||
return Updater(update_available, newest, release_notes)
|
|
||||||
|
|
||||||
coordinator = hass.data[DOMAIN] = update_coordinator.DataUpdateCoordinator[Updater](
|
|
||||||
hass,
|
|
||||||
_LOGGER,
|
|
||||||
name="Home Assistant update",
|
|
||||||
update_method=check_new_version,
|
|
||||||
update_interval=timedelta(days=1),
|
|
||||||
)
|
|
||||||
|
|
||||||
# This can take up to 15s which can delay startup
|
|
||||||
asyncio.create_task(coordinator.async_refresh())
|
|
||||||
|
|
||||||
hass.async_create_task(
|
|
||||||
discovery.async_load_platform(hass, Platform.BINARY_SENSOR, DOMAIN, {}, config)
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
async def get_newest_version(hass):
|
|
||||||
"""Get the newest Home Assistant version."""
|
|
||||||
session = async_get_clientsession(hass)
|
|
||||||
|
|
||||||
async with async_timeout.timeout(30):
|
|
||||||
req = await session.get(UPDATER_URL)
|
|
||||||
|
|
||||||
try:
|
|
||||||
res = await req.json()
|
|
||||||
except ValueError as err:
|
|
||||||
raise update_coordinator.UpdateFailed(
|
|
||||||
"Received invalid JSON from Home Assistant Update"
|
|
||||||
) from err
|
|
||||||
|
|
||||||
try:
|
|
||||||
res = RESPONSE_SCHEMA(res)
|
|
||||||
return res["current_version"], res["release_notes"]
|
|
||||||
except vol.Invalid as err:
|
|
||||||
raise update_coordinator.UpdateFailed(
|
|
||||||
f"Got unexpected response: {err}"
|
|
||||||
) from err
|
|
@ -1,56 +0,0 @@
|
|||||||
"""Support for Home Assistant Updater binary sensors."""
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import (
|
|
||||||
BinarySensorDeviceClass,
|
|
||||||
BinarySensorEntity,
|
|
||||||
)
|
|
||||||
from homeassistant.core import HomeAssistant
|
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
|
||||||
|
|
||||||
from . import ATTR_NEWEST_VERSION, ATTR_RELEASE_NOTES, DOMAIN as UPDATER_DOMAIN
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(
|
|
||||||
hass: HomeAssistant,
|
|
||||||
config: ConfigType,
|
|
||||||
async_add_entities: AddEntitiesCallback,
|
|
||||||
discovery_info: DiscoveryInfoType | None = None,
|
|
||||||
) -> None:
|
|
||||||
"""Set up the updater binary sensors."""
|
|
||||||
if discovery_info is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
async_add_entities([UpdaterBinary(hass.data[UPDATER_DOMAIN])])
|
|
||||||
|
|
||||||
|
|
||||||
class UpdaterBinary(CoordinatorEntity, BinarySensorEntity):
|
|
||||||
"""Representation of an updater binary sensor."""
|
|
||||||
|
|
||||||
_attr_device_class = BinarySensorDeviceClass.UPDATE
|
|
||||||
_attr_name = "Updater"
|
|
||||||
_attr_unique_id = "updater"
|
|
||||||
|
|
||||||
@property
|
|
||||||
def available(self) -> bool:
|
|
||||||
"""Return if entity is available."""
|
|
||||||
return True
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_on(self) -> bool:
|
|
||||||
"""Return true if there is an update available."""
|
|
||||||
return self.coordinator.data and self.coordinator.data.update_available
|
|
||||||
|
|
||||||
@property
|
|
||||||
def extra_state_attributes(self) -> dict | None:
|
|
||||||
"""Return the optional state attributes."""
|
|
||||||
if not self.coordinator.data:
|
|
||||||
return None
|
|
||||||
data = {}
|
|
||||||
if self.coordinator.data.release_notes:
|
|
||||||
data[ATTR_RELEASE_NOTES] = self.coordinator.data.release_notes
|
|
||||||
if self.coordinator.data.newest_version:
|
|
||||||
data[ATTR_NEWEST_VERSION] = self.coordinator.data.newest_version
|
|
||||||
return data
|
|
@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"domain": "updater",
|
|
||||||
"name": "Updater",
|
|
||||||
"documentation": "https://www.home-assistant.io/integrations/updater",
|
|
||||||
"codeowners": ["@home-assistant/core"],
|
|
||||||
"quality_scale": "internal",
|
|
||||||
"iot_class": "cloud_polling"
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
{ "title": "Updater" }
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Opdateerder"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "\u062a\u062d\u062f\u064a\u062b"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "\u041e\u0431\u043d\u043e\u0432\u044f\u0432\u0430\u043d\u0435"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Updater"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Actualitzador"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Aktualiz\u00e1tor"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Diweddarwr"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Opdater"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Updater"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "\u0395\u03bd\u03b7\u03bc\u03b5\u03c1\u03c9\u03c4\u03ae\u03c2"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Updater"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Actualizador"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Actualizador"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Uuendaja"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Eguneratzailea"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "\u0628\u0647 \u0631\u0648\u0632 \u0631\u0633\u0627\u0646"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "P\u00e4ivitys"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Mise \u00e0 jour"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Updater"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "\u05de\u05e2\u05d3\u05db\u05df"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "A\u017euriranje"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Friss\u00edt\u0151"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "\u0539\u0561\u0580\u0574\u0561\u0581\u0576\u0578\u0572"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Pembaru"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Uppf\u00e6rslu\u00e1lfur"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Aggiornamento"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "\u30a2\u30c3\u30d7\u30c7\u30fc\u30bf\u30fc"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "\uc5c5\ub370\uc774\ud130"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Aktualis\u00e9ierung"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Atjaunin\u0101t\u0101js"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Oppdater"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Updater"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Oppdateringar"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Oppdaterer"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Aktualizator"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Gerenciador de atualiza\u00e7\u00f5es"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Atualizador"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Updater"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Aktualiz\u00e1tor"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Posodabljalnik"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Uppdaterare"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "\u0b85\u0baa\u0bcd\u0b9f\u0bc7\u0b9f\u0bcd\u0b9f\u0bb0\u0bcd"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Updater"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "\u0e2d\u0e31\u0e1e\u0e40\u0e14\u0e15"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "G\u00fcncelleyici"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "\u041e\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044f"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "Tr\u00ecnh c\u1eadp nh\u1eadt"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "\u66f4\u65b0\u63d0\u793a"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"title": "\u66f4\u65b0\u5668"
|
|
||||||
}
|
|
@ -15,13 +15,6 @@ def mock_ssdp():
|
|||||||
yield
|
yield
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
|
||||||
def mock_updater():
|
|
||||||
"""Mock updater."""
|
|
||||||
with patch("homeassistant.components.updater.get_newest_version"):
|
|
||||||
yield
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def recorder_url_mock():
|
def recorder_url_mock():
|
||||||
"""Mock recorder url."""
|
"""Mock recorder url."""
|
||||||
|
@ -1 +0,0 @@
|
|||||||
"""Tests for the updater component."""
|
|
@ -1,130 +0,0 @@
|
|||||||
"""The tests for the Updater integration."""
|
|
||||||
from unittest.mock import patch
|
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
from homeassistant.components import updater
|
|
||||||
from homeassistant.helpers.update_coordinator import UpdateFailed
|
|
||||||
from homeassistant.setup import async_setup_component
|
|
||||||
|
|
||||||
from tests.common import mock_component
|
|
||||||
|
|
||||||
NEW_VERSION = "10000.0"
|
|
||||||
MOCK_VERSION = "10.0"
|
|
||||||
MOCK_DEV_VERSION = "10.0.dev0"
|
|
||||||
MOCK_RESPONSE = {
|
|
||||||
"current_version": "0.15",
|
|
||||||
"release_notes": "https://home-assistant.io",
|
|
||||||
}
|
|
||||||
MOCK_CONFIG = {updater.DOMAIN: {"reporting": True}}
|
|
||||||
RELEASE_NOTES = "test release notes"
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
|
||||||
def mock_version():
|
|
||||||
"""Mock current version."""
|
|
||||||
with patch("homeassistant.components.updater.current_version", MOCK_VERSION):
|
|
||||||
yield
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="mock_get_newest_version")
|
|
||||||
def mock_get_newest_version_fixture():
|
|
||||||
"""Fixture to mock get_newest_version."""
|
|
||||||
with patch(
|
|
||||||
"homeassistant.components.updater.get_newest_version",
|
|
||||||
return_value=(NEW_VERSION, RELEASE_NOTES),
|
|
||||||
) as mock:
|
|
||||||
yield mock
|
|
||||||
|
|
||||||
|
|
||||||
async def test_new_version_shows_entity_true(hass, mock_get_newest_version):
|
|
||||||
"""Test if sensor is true if new version is available."""
|
|
||||||
assert await async_setup_component(hass, updater.DOMAIN, {updater.DOMAIN: {}})
|
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
|
||||||
assert hass.states.is_state("binary_sensor.updater", "on")
|
|
||||||
assert (
|
|
||||||
hass.states.get("binary_sensor.updater").attributes["newest_version"]
|
|
||||||
== NEW_VERSION
|
|
||||||
)
|
|
||||||
assert (
|
|
||||||
hass.states.get("binary_sensor.updater").attributes["release_notes"]
|
|
||||||
== RELEASE_NOTES
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def test_same_version_shows_entity_false(hass, mock_get_newest_version):
|
|
||||||
"""Test if sensor is false if no new version is available."""
|
|
||||||
mock_get_newest_version.return_value = (MOCK_VERSION, "")
|
|
||||||
|
|
||||||
assert await async_setup_component(hass, updater.DOMAIN, {updater.DOMAIN: {}})
|
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
|
||||||
|
|
||||||
assert hass.states.is_state("binary_sensor.updater", "off")
|
|
||||||
assert (
|
|
||||||
hass.states.get("binary_sensor.updater").attributes["newest_version"]
|
|
||||||
== MOCK_VERSION
|
|
||||||
)
|
|
||||||
assert "release_notes" not in hass.states.get("binary_sensor.updater").attributes
|
|
||||||
|
|
||||||
|
|
||||||
async def test_deprecated_reporting(hass, mock_get_newest_version, caplog):
|
|
||||||
"""Test we do not gather analytics when disable reporting is active."""
|
|
||||||
mock_get_newest_version.return_value = (MOCK_VERSION, "")
|
|
||||||
|
|
||||||
assert await async_setup_component(
|
|
||||||
hass, updater.DOMAIN, {updater.DOMAIN: {"reporting": True}}
|
|
||||||
)
|
|
||||||
await hass.async_block_till_done()
|
|
||||||
|
|
||||||
assert "deprecated" in caplog.text
|
|
||||||
|
|
||||||
|
|
||||||
async def test_error_fetching_new_version_bad_json(hass, aioclient_mock):
|
|
||||||
"""Test we handle json error while fetching new version."""
|
|
||||||
aioclient_mock.get(updater.UPDATER_URL, text="not json")
|
|
||||||
|
|
||||||
with patch(
|
|
||||||
"homeassistant.helpers.system_info.async_get_system_info",
|
|
||||||
return_value={"fake": "bla"},
|
|
||||||
), pytest.raises(UpdateFailed):
|
|
||||||
await updater.get_newest_version(hass)
|
|
||||||
|
|
||||||
|
|
||||||
async def test_error_fetching_new_version_invalid_response(hass, aioclient_mock):
|
|
||||||
"""Test we handle response error while fetching new version."""
|
|
||||||
aioclient_mock.get(
|
|
||||||
updater.UPDATER_URL,
|
|
||||||
json={
|
|
||||||
"version": "0.15"
|
|
||||||
# 'release-notes' is missing
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
with patch(
|
|
||||||
"homeassistant.helpers.system_info.async_get_system_info",
|
|
||||||
return_value={"fake": "bla"},
|
|
||||||
), pytest.raises(UpdateFailed):
|
|
||||||
await updater.get_newest_version(hass)
|
|
||||||
|
|
||||||
|
|
||||||
async def test_new_version_shows_entity_after_hour_hassio(
|
|
||||||
hass, mock_get_newest_version
|
|
||||||
):
|
|
||||||
"""Test if binary sensor gets updated if new version is available / Hass.io."""
|
|
||||||
mock_component(hass, "hassio")
|
|
||||||
hass.data["hassio_core_info"] = {"version_latest": "999.0"}
|
|
||||||
|
|
||||||
assert await async_setup_component(hass, updater.DOMAIN, {updater.DOMAIN: {}})
|
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
|
||||||
|
|
||||||
assert hass.states.is_state("binary_sensor.updater", "on")
|
|
||||||
assert (
|
|
||||||
hass.states.get("binary_sensor.updater").attributes["newest_version"] == "999.0"
|
|
||||||
)
|
|
||||||
assert (
|
|
||||||
hass.states.get("binary_sensor.updater").attributes["release_notes"]
|
|
||||||
== RELEASE_NOTES
|
|
||||||
)
|
|
Loading…
x
Reference in New Issue
Block a user