Clean up superfluous integration setup - part 3 (#48484)

This commit is contained in:
Franck Nijhof 2021-03-30 01:23:44 +02:00 committed by GitHub
parent 6ec3234ccc
commit bb9da22a84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 23 additions and 125 deletions

View File

@ -18,12 +18,6 @@ PLATFORMS = ["climate", "cover", "binary_sensor", "sensor", "switch"]
_LOGGER = logging.getLogger(__name__)
async def async_setup(hass, config):
"""Set up Advantage Air integration."""
hass.data[DOMAIN] = {}
return True
async def async_setup_entry(hass, entry):
"""Set up Advantage Air config."""
ip_address = entry.data[CONF_IP_ADDRESS]
@ -58,6 +52,7 @@ async def async_setup_entry(hass, entry):
await coordinator.async_config_entry_first_refresh()
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = {
"coordinator": coordinator,
"async_change": async_change,

View File

@ -14,12 +14,6 @@ from .weather_update_coordinator import WeatherUpdateCoordinator
_LOGGER = logging.getLogger(__name__)
async def async_setup(hass: HomeAssistant, config: dict) -> bool:
"""Set up the AEMET OpenData component."""
hass.data.setdefault(DOMAIN, {})
return True
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry):
"""Set up AEMET OpenData as config entry."""
name = config_entry.data[CONF_NAME]
@ -32,6 +26,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry):
await weather_coordinator.async_config_entry_first_refresh()
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][config_entry.entry_id] = {
ENTRY_NAME: name,
ENTRY_WEATHER_COORDINATOR: weather_coordinator,

View File

@ -36,13 +36,6 @@ _LOGGER = logging.getLogger(__name__)
PLATFORMS = ["binary_sensor", "sensor"]
async def async_setup(hass: HomeAssistant, config: dict):
"""Set up the Aurora component."""
hass.data.setdefault(DOMAIN, {})
return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up Aurora from a config entry."""
@ -70,6 +63,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
await coordinator.async_config_entry_first_refresh()
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = {
COORDINATOR: coordinator,
AURORA_API: api,

View File

@ -59,12 +59,6 @@ def _reauth_flow_wrapper(hass, data):
)
async def async_setup(hass, config):
"""Set up a Blink component."""
hass.data[DOMAIN] = {}
return True
async def async_migrate_entry(hass, entry):
"""Handle migration of a previous version config entry."""
_LOGGER.debug("Migrating from version %s", entry.version)
@ -81,8 +75,9 @@ async def async_migrate_entry(hass, entry):
async def async_setup_entry(hass, entry):
"""Set up Blink via config entry."""
_async_import_options_from_data_if_missing(hass, entry)
hass.data.setdefault(DOMAIN, {})
_async_import_options_from_data_if_missing(hass, entry)
hass.data[DOMAIN][entry.entry_id] = await hass.async_add_executor_job(
_blink_startup_wrapper, hass, entry
)

View File

@ -19,12 +19,6 @@ PLATFORMS = ["cover", "fan", "light", "switch"]
_API_TIMEOUT = SLOW_UPDATE_WARNING - 1
async def async_setup(hass: HomeAssistant, config: dict) -> bool:
"""Set up the Bond component."""
hass.data.setdefault(DOMAIN, {})
return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Bond from a config entry."""
host = entry.data[CONF_HOST]
@ -41,6 +35,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
bpup_subs = BPUPSubscriptions()
stop_bpup = await start_bpup(host, bpup_subs)
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = {
HUB: hub,
BPUP_SUBS: bpup_subs,

View File

@ -9,18 +9,12 @@ from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNA
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.typing import ConfigType
from .const import CONF_PASSKEY, DATA_BSBLAN_CLIENT, DOMAIN
SCAN_INTERVAL = timedelta(seconds=30)
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the BSB-Lan component."""
return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up BSB-Lan from a config entry."""

View File

@ -25,7 +25,7 @@ from homeassistant.components.weather import DOMAIN as WEATHER_DOMAIN
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.typing import ConfigType, HomeAssistantType
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.helpers.update_coordinator import (
CoordinatorEntity,
DataUpdateCoordinator,
@ -81,11 +81,6 @@ def _set_update_interval(
return interval
async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
"""Set up the ClimaCell API component."""
return True
async def async_setup_entry(hass: HomeAssistantType, config_entry: ConfigEntry) -> bool:
"""Set up ClimaCell API from a config entry."""
hass.data.setdefault(DOMAIN, {})

View File

@ -42,17 +42,9 @@ _LOGGER = logging.getLogger(__name__)
PLATFORMS = ["light"]
async def async_setup(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Stub to allow setting up this component.
Configuration through YAML is not supported at this time.
"""
hass.data.setdefault(DOMAIN, {})
return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up Control4 from a config entry."""
hass.data.setdefault(DOMAIN, {})
entry_data = hass.data[DOMAIN].setdefault(entry.entry_id, {})
account_session = aiohttp_client.async_get_clientsession(hass)

View File

@ -13,12 +13,6 @@ from .const import DATA_COORDINATOR, DATA_INFO, DOMAIN
_LOGGER = logging.getLogger(__name__)
async def async_setup(hass, config):
"""Set up Coolmaster components."""
hass.data.setdefault(DOMAIN, {})
return True
async def async_setup_entry(hass, entry):
"""Set up Coolmaster from a config entry."""
host = entry.data[CONF_HOST]
@ -31,6 +25,7 @@ async def async_setup_entry(hass, entry):
except (OSError, ConnectionRefusedError, TimeoutError) as error:
raise ConfigEntryNotReady() from error
coordinator = CoolmasterDataUpdateCoordinator(hass, coolmaster)
hass.data.setdefault(DOMAIN, {})
await coordinator.async_config_entry_first_refresh()
hass.data[DOMAIN][entry.entry_id] = {
DATA_INFO: info,

View File

@ -26,12 +26,6 @@ _LOGGER = logging.getLogger(__name__)
SCAN_INTERVAL = timedelta(seconds=180)
async def async_setup(hass: HomeAssistant, config: dict):
"""Set up configured Dexcom."""
hass.data[DOMAIN] = {}
return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up Dexcom from a config entry."""
try:
@ -57,6 +51,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
except SessionError as error:
raise UpdateFailed(error) from error
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = {
COORDINATOR: DataUpdateCoordinator(
hass,

View File

@ -30,12 +30,6 @@ PLATFORMS = ["media_player", "remote"]
SCAN_INTERVAL = timedelta(seconds=30)
async def async_setup(hass: HomeAssistant, config: dict) -> bool:
"""Set up the DirecTV component."""
hass.data.setdefault(DOMAIN, {})
return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up DirecTV from a config entry."""
dtv = DIRECTV(entry.data[CONF_HOST], session=async_get_clientsession(hass))
@ -45,6 +39,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
except DIRECTVError as err:
raise ConfigEntryNotReady from err
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = dtv
for platform in PLATFORMS:

View File

@ -26,8 +26,6 @@ async def test_form(hass):
"""Test that the form is served with valid input."""
with patch(
"homeassistant.components.aemet.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.aemet.async_setup_entry",
return_value=True,
) as mock_setup_entry, requests_mock.mock() as _m:
@ -57,7 +55,6 @@ async def test_form(hass):
assert result["data"][CONF_LONGITUDE] == CONFIG[CONF_LONGITUDE]
assert result["data"][CONF_API_KEY] == CONFIG[CONF_API_KEY]
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1

View File

@ -29,8 +29,6 @@ async def test_form(hass):
"homeassistant.components.aurora.config_flow.AuroraForecast.get_forecast_data",
return_value=True,
), patch(
"homeassistant.components.aurora.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.aurora.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -43,7 +41,6 @@ async def test_form(hass):
assert result2["type"] == "create_entry"
assert result2["title"] == "Aurora - Home"
assert result2["data"] == DATA
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1

View File

@ -23,8 +23,6 @@ async def test_form(hass):
"homeassistant.components.blink.config_flow.Auth.check_key_required",
return_value=False,
), patch(
"homeassistant.components.blink.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.blink.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -47,7 +45,6 @@ async def test_form(hass):
"client_id": None,
"region_id": None,
}
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
@ -61,9 +58,7 @@ async def test_form_2fa(hass):
with patch("homeassistant.components.blink.config_flow.Auth.startup"), patch(
"homeassistant.components.blink.config_flow.Auth.check_key_required",
return_value=True,
), patch(
"homeassistant.components.blink.async_setup", return_value=True
) as mock_setup:
):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{"username": "blink@example.com", "password": "example"},
@ -82,8 +77,6 @@ async def test_form_2fa(hass):
"homeassistant.components.blink.config_flow.Blink.setup_urls",
return_value=True,
), patch(
"homeassistant.components.blink.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.blink.async_setup_entry", return_value=True
) as mock_setup_entry:
result3 = await hass.config_entries.flow.async_configure(
@ -94,7 +87,6 @@ async def test_form_2fa(hass):
assert result3["type"] == "create_entry"
assert result3["title"] == "blink"
assert result3["result"].unique_id == "blink@example.com"
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
@ -108,7 +100,7 @@ async def test_form_2fa_connect_error(hass):
with patch("homeassistant.components.blink.config_flow.Auth.startup"), patch(
"homeassistant.components.blink.config_flow.Auth.check_key_required",
return_value=True,
), patch("homeassistant.components.blink.async_setup", return_value=True):
):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{"username": "blink@example.com", "password": "example"},
@ -126,8 +118,6 @@ async def test_form_2fa_connect_error(hass):
), patch(
"homeassistant.components.blink.config_flow.Blink.setup_urls",
side_effect=BlinkSetupError,
), patch(
"homeassistant.components.blink.async_setup", return_value=True
), patch(
"homeassistant.components.blink.async_setup_entry", return_value=True
):
@ -149,7 +139,7 @@ async def test_form_2fa_invalid_key(hass):
with patch("homeassistant.components.blink.config_flow.Auth.startup"), patch(
"homeassistant.components.blink.config_flow.Auth.check_key_required",
return_value=True,
), patch("homeassistant.components.blink.async_setup", return_value=True):
):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{"username": "blink@example.com", "password": "example"},
@ -167,8 +157,6 @@ async def test_form_2fa_invalid_key(hass):
), patch(
"homeassistant.components.blink.config_flow.Blink.setup_urls",
return_value=True,
), patch(
"homeassistant.components.blink.async_setup", return_value=True
), patch(
"homeassistant.components.blink.async_setup_entry", return_value=True
):
@ -190,7 +178,7 @@ async def test_form_2fa_unknown_error(hass):
with patch("homeassistant.components.blink.config_flow.Auth.startup"), patch(
"homeassistant.components.blink.config_flow.Auth.check_key_required",
return_value=True,
), patch("homeassistant.components.blink.async_setup", return_value=True):
):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{"username": "blink@example.com", "password": "example"},
@ -208,8 +196,6 @@ async def test_form_2fa_unknown_error(hass):
), patch(
"homeassistant.components.blink.config_flow.Blink.setup_urls",
side_effect=KeyError,
), patch(
"homeassistant.components.blink.async_setup", return_value=True
), patch(
"homeassistant.components.blink.async_setup_entry", return_value=True
):

View File

@ -35,7 +35,7 @@ async def test_user_form(hass: core.HomeAssistant):
return_value={"bondid": "test-bond-id"}
), patch_bond_device_ids(
return_value=["f6776c11", "f6776c12"]
), patch_bond_bridge(), patch_bond_device_properties(), patch_bond_device(), _patch_async_setup() as mock_setup, _patch_async_setup_entry() as mock_setup_entry:
), patch_bond_bridge(), patch_bond_device_properties(), patch_bond_device(), _patch_async_setup_entry() as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{CONF_HOST: "some host", CONF_ACCESS_TOKEN: "test-token"},
@ -48,7 +48,6 @@ async def test_user_form(hass: core.HomeAssistant):
CONF_HOST: "some host",
CONF_ACCESS_TOKEN: "test-token",
}
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
@ -71,7 +70,7 @@ async def test_user_form_with_non_bridge(hass: core.HomeAssistant):
}
), patch_bond_bridge(
return_value={}
), _patch_async_setup() as mock_setup, _patch_async_setup_entry() as mock_setup_entry:
), _patch_async_setup_entry() as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{CONF_HOST: "some host", CONF_ACCESS_TOKEN: "test-token"},
@ -84,7 +83,6 @@ async def test_user_form_with_non_bridge(hass: core.HomeAssistant):
CONF_HOST: "some host",
CONF_ACCESS_TOKEN: "test-token",
}
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
@ -180,7 +178,7 @@ async def test_user_form_one_entry_per_device_allowed(hass: core.HomeAssistant):
with patch_bond_version(
return_value={"bondid": "already-registered-bond-id"}
), patch_bond_bridge(), patch_bond_device_ids(), _patch_async_setup() as mock_setup, _patch_async_setup_entry() as mock_setup_entry:
), patch_bond_bridge(), patch_bond_device_ids(), _patch_async_setup_entry() as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{CONF_HOST: "some host", CONF_ACCESS_TOKEN: "test-token"},
@ -190,7 +188,6 @@ async def test_user_form_one_entry_per_device_allowed(hass: core.HomeAssistant):
assert result2["reason"] == "already_configured"
await hass.async_block_till_done()
assert len(mock_setup.mock_calls) == 0
assert len(mock_setup_entry.mock_calls) == 0
@ -207,7 +204,7 @@ async def test_zeroconf_form(hass: core.HomeAssistant):
with patch_bond_version(
return_value={"bondid": "test-bond-id"}
), patch_bond_bridge(), patch_bond_device_ids(), _patch_async_setup() as mock_setup, _patch_async_setup_entry() as mock_setup_entry:
), patch_bond_bridge(), patch_bond_device_ids(), _patch_async_setup_entry() as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{CONF_ACCESS_TOKEN: "test-token"},
@ -220,7 +217,6 @@ async def test_zeroconf_form(hass: core.HomeAssistant):
CONF_HOST: "test-host",
CONF_ACCESS_TOKEN: "test-token",
}
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
@ -237,7 +233,7 @@ async def test_zeroconf_form_token_unavailable(hass: core.HomeAssistant):
assert result["type"] == "form"
assert result["errors"] == {}
with patch_bond_version(), patch_bond_bridge(), patch_bond_device_ids(), _patch_async_setup() as mock_setup, _patch_async_setup_entry() as mock_setup_entry:
with patch_bond_version(), patch_bond_bridge(), patch_bond_device_ids(), _patch_async_setup_entry() as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{CONF_ACCESS_TOKEN: "test-token"},
@ -250,7 +246,6 @@ async def test_zeroconf_form_token_unavailable(hass: core.HomeAssistant):
CONF_HOST: "test-host",
CONF_ACCESS_TOKEN: "test-token",
}
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
@ -271,7 +266,7 @@ async def test_zeroconf_form_with_token_available(hass: core.HomeAssistant):
assert result["type"] == "form"
assert result["errors"] == {}
with _patch_async_setup() as mock_setup, _patch_async_setup_entry() as mock_setup_entry:
with _patch_async_setup_entry() as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{},
@ -284,7 +279,6 @@ async def test_zeroconf_form_with_token_available(hass: core.HomeAssistant):
CONF_HOST: "test-host",
CONF_ACCESS_TOKEN: "discovered-token",
}
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
@ -299,7 +293,7 @@ async def test_zeroconf_already_configured(hass: core.HomeAssistant):
)
entry.add_to_hass(hass)
with _patch_async_setup() as mock_setup, _patch_async_setup_entry() as mock_setup_entry:
with _patch_async_setup_entry() as mock_setup_entry:
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_ZEROCONF},
@ -314,7 +308,6 @@ async def test_zeroconf_already_configured(hass: core.HomeAssistant):
assert entry.data["host"] == "updated-host"
await hass.async_block_till_done()
assert len(mock_setup.mock_calls) == 0
assert len(mock_setup_entry.mock_calls) == 0
@ -356,10 +349,6 @@ async def _help_test_form_unexpected_error(
assert result2["errors"] == {"base": "unknown"}
def _patch_async_setup():
return patch("homeassistant.components.bond.async_setup", return_value=True)
def _patch_async_setup_entry():
return patch(
"homeassistant.components.bond.async_setup_entry",

View File

@ -62,8 +62,6 @@ async def test_form(hass):
"homeassistant.components.control4.config_flow.C4Director",
return_value=c4_director,
), patch(
"homeassistant.components.control4.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.control4.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -85,7 +83,6 @@ async def test_form(hass):
CONF_PASSWORD: "test-password",
"controller_unique_id": "control4_model_00AA00AA00AA",
}
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1

View File

@ -24,8 +24,6 @@ async def test_form(hass):
"homeassistant.components.coolmaster.config_flow.CoolMasterNet.status",
return_value={"test_id": "test_unit"},
), patch(
"homeassistant.components.coolmaster.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.coolmaster.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -41,7 +39,6 @@ async def test_form(hass):
"port": 10102,
"supported_modes": AVAILABLE_MODES,
}
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1

View File

@ -24,8 +24,6 @@ async def test_form(hass):
"homeassistant.components.dexcom.config_flow.Dexcom.create_session",
return_value="test_session_id",
), patch(
"homeassistant.components.dexcom.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.dexcom.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -38,7 +36,6 @@ async def test_form(hass):
assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result2["title"] == CONFIG[CONF_USERNAME]
assert result2["data"] == CONFIG
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1

View File

@ -229,9 +229,7 @@ async def test_full_user_flow_implementation(
assert result["step_id"] == "user"
user_input = MOCK_USER_INPUT.copy()
with patch(
"homeassistant.components.directv.async_setup_entry", return_value=True
), patch("homeassistant.components.directv.async_setup", return_value=True):
with patch("homeassistant.components.directv.async_setup_entry", return_value=True):
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input=user_input,