* add addon_update service, use config flow to set up config entry, create disabled sensors * move most of entity logic to common entity class, improve device info, get rid of config_flow user step * fix setup logic * additional refactor * fix refactored logic * fix config flow tests * add test for addon_update service and get_addons_info * add entry setup and unload test and fix update coordinator * handle if entry setup calls unload * return nothing for coordinator if entry is being reloaded because coordinator will get recreated anyway * remove entry when HA instance is no longer hassio and add corresponding test * handle adding and removing device registry entries * better config entry reload logic * fix comment * bugfix * fix flake error * switch pass to return * use repository attribute for model and fallback to url * use custom 'system' source since hassio source is misleading * Update homeassistant/components/hassio/entity.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * update remove addons function name * Update homeassistant/components/hassio/__init__.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * fix import * pop coordinator after unload * additional fixes * always pass in sensor name when creating entity * prefix one more function with async and fix tests * use supervisor info for addons since list is already filtered on what's installed * remove unused service * update sensor names * remove added handler function * use walrus * add OS device and sensors * fix * re-add addon_update service schema * add more test coverage and exclude entities from tests * check if instance is using hass OS in order to create OS entities Co-authored-by: Franck Nijhof <frenck@frenck.nl>
36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
"""Test the Home Assistant Supervisor config flow."""
|
|
from unittest.mock import patch
|
|
|
|
from homeassistant import setup
|
|
from homeassistant.components.hassio import DOMAIN
|
|
|
|
|
|
async def test_config_flow(hass):
|
|
"""Test we get the form."""
|
|
await setup.async_setup_component(hass, "persistent_notification", {})
|
|
with patch(
|
|
"homeassistant.components.hassio.async_setup", return_value=True
|
|
) as mock_setup, patch(
|
|
"homeassistant.components.hassio.async_setup_entry",
|
|
return_value=True,
|
|
) as mock_setup_entry:
|
|
result = await hass.config_entries.flow.async_init(
|
|
DOMAIN, context={"source": "system"}
|
|
)
|
|
assert result["type"] == "create_entry"
|
|
assert result["title"] == DOMAIN.title()
|
|
assert result["data"] == {}
|
|
await hass.async_block_till_done()
|
|
|
|
assert len(mock_setup.mock_calls) == 1
|
|
assert len(mock_setup_entry.mock_calls) == 1
|
|
|
|
|
|
async def test_multiple_entries(hass):
|
|
"""Test creating multiple hassio entries."""
|
|
await test_config_flow(hass)
|
|
result = await hass.config_entries.flow.async_init(
|
|
DOMAIN, context={"source": "system"}
|
|
)
|
|
assert result["type"] == "abort"
|
|
assert result["reason"] == "already_configured"
|