mirror of
https://github.com/elisspace/core.git
synced 2026-08-29 15:43:55 +00:00
fix check
This commit is contained in:
@@ -15,7 +15,7 @@ from homeassistant.const import EVENT_HOMEASSISTANT_STOP
|
||||
from homeassistant.core import CALLBACK_TYPE, Event, HomeAssistant, callback
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers.storage import Store
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
@@ -101,10 +101,9 @@ class ESPHomeDashboardManager:
|
||||
dashboard = ESPHomeDashboard(
|
||||
hass, addon_slug, url, async_get_clientsession(hass)
|
||||
)
|
||||
try:
|
||||
await dashboard.async_request_refresh()
|
||||
except UpdateFailed as err:
|
||||
_LOGGER.error("Ignoring dashboard info: %s", err)
|
||||
await dashboard.async_request_refresh()
|
||||
if not dashboard.last_update_success:
|
||||
_LOGGER.error("Ignoring dashboard info: %s", dashboard.last_exception)
|
||||
return
|
||||
|
||||
self._current_dashboard = dashboard
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"""Test ESPHome dashboard features."""
|
||||
import asyncio
|
||||
from unittest.mock import patch
|
||||
|
||||
from aioesphomeapi import DeviceInfo, InvalidAuthAPIError
|
||||
@@ -10,6 +11,8 @@ from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from . import VALID_NOISE_PSK
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_dashboard_storage(
|
||||
hass: HomeAssistant, init_integration, mock_dashboard, hass_storage
|
||||
@@ -24,6 +27,40 @@ async def test_dashboard_storage(
|
||||
}
|
||||
|
||||
|
||||
async def test_restore_dashboard_storage(
|
||||
hass: HomeAssistant, mock_config_entry: MockConfigEntry, hass_storage
|
||||
) -> MockConfigEntry:
|
||||
"""Restore dashboard url and slug from storage."""
|
||||
hass_storage[dashboard.STORAGE_KEY] = {
|
||||
"version": dashboard.STORAGE_VERSION,
|
||||
"minor_version": dashboard.STORAGE_VERSION,
|
||||
"key": dashboard.STORAGE_KEY,
|
||||
"data": {"info": {"addon_slug": "test-slug", "host": "new-host", "port": 6052}},
|
||||
}
|
||||
with patch.object(
|
||||
dashboard, "async_get_or_create_dashboard_manager"
|
||||
) as mock_get_or_create:
|
||||
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert mock_get_or_create.call_count == 1
|
||||
|
||||
|
||||
async def test_setup_dashboard_fails(
|
||||
hass: HomeAssistant, mock_config_entry: MockConfigEntry, hass_storage
|
||||
) -> MockConfigEntry:
|
||||
"""Test that nothing is stored on failed dashboard setup."""
|
||||
with patch.object(
|
||||
dashboard.ESPHomeDashboardAPI, "get_devices", side_effect=asyncio.TimeoutError
|
||||
) as mock_get_devices:
|
||||
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
await dashboard.async_set_dashboard_info(hass, "test-slug", "test-host", 6052)
|
||||
assert mock_config_entry.state == ConfigEntryState.LOADED
|
||||
assert mock_get_devices.call_count == 1
|
||||
|
||||
assert dashboard.STORAGE_KEY not in hass_storage
|
||||
|
||||
|
||||
async def test_new_info_reload_config_entries(
|
||||
hass: HomeAssistant, init_integration, mock_dashboard
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user