Clean up superfluous integration setup - part 4 (#49295)

* Clean up superfluous integration setup - part 4

* Adjust tests
pull/49308/head^2
Franck Nijhof 2021-04-16 17:46:49 +02:00 committed by GitHub
parent 73a9cb6adb
commit 969c147b77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 20 additions and 267 deletions

View File

@ -24,12 +24,6 @@ PLATFORMS = ["sensor"]
MIN_SCAN_INTERVAL = timedelta(minutes=10)
async def async_setup(hass: HomeAssistant, config: dict):
"""Set up the Garmin Connect component."""
hass.data[DOMAIN] = {}
return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up Garmin Connect from a config entry."""
username = entry.data[CONF_USERNAME]
@ -55,6 +49,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
return False
garmin_data = GarminConnectData(hass, garmin_client)
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = garmin_data
for platform in PLATFORMS:

View File

@ -23,14 +23,6 @@ _LOGGER = logging.getLogger(__name__)
PLATFORMS = ["binary_sensor"]
async def async_setup(hass: HomeAssistant, config):
"""Set up the Goal Zero Yeti component."""
hass.data[DOMAIN] = {}
return True
async def async_setup_entry(hass, entry):
"""Set up Goal Zero Yeti from a config entry."""
name = entry.data[CONF_NAME]
@ -58,6 +50,7 @@ async def async_setup_entry(hass, entry):
update_method=async_update_data,
update_interval=MIN_TIME_BETWEEN_UPDATES,
)
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = {
DATA_KEY_API: api,
DATA_KEY_COORDINATOR: coordinator,

View File

@ -24,13 +24,6 @@ PLATFORMS = ["switch"]
_LOGGER = logging.getLogger(__name__)
async def async_setup(hass: HomeAssistant, config: dict):
"""Set up the kmtronic component."""
hass.data[DOMAIN] = {}
return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up kmtronic from a config entry."""
session = aiohttp_client.async_get_clientsession(hass)
@ -60,6 +53,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] = {
DATA_HUB: hub,
DATA_COORDINATOR: coordinator,

View File

@ -29,12 +29,6 @@ _LOGGER = logging.getLogger(__name__)
PLATFORMS = ["media_player"]
async def async_setup(hass, config):
"""Set up the Kodi integration."""
hass.data.setdefault(DOMAIN, {})
return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up Kodi from a config entry."""
conn = get_kodi_connection(
@ -66,6 +60,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
remove_stop_listener = hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, _close)
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = {
DATA_CONNECTION: conn,
DATA_KODI: kodi,

View File

@ -9,11 +9,6 @@ from .const import DATA_ADDRESSES, DATA_DISCOVERY_SUBSCRIPTION, DOMAIN
PLATFORMS = ["light"]
async def async_setup(hass: HomeAssistant, config: dict):
"""Set up the Kuler Sky component."""
return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up Kuler Sky from a config entry."""
if DOMAIN not in hass.data:

View File

@ -13,7 +13,6 @@ from homeassistant.const import (
LENGTH_FEET,
LENGTH_METERS,
)
from homeassistant.core import Config, HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from homeassistant.util.distance import convert as convert_distance
@ -32,12 +31,6 @@ URL = "https://aa015h6buqvih86i1.api.met.no/weatherapi/locationforecast/2.0/comp
_LOGGER = logging.getLogger(__name__)
async def async_setup(hass: HomeAssistant, config: Config) -> bool:
"""Set up configured Met."""
hass.data.setdefault(DOMAIN, {})
return True
async def async_setup_entry(hass, config_entry):
"""Set up Met as config entry."""
# Don't setup if tracking home location and latitude or longitude isn't set.
@ -60,6 +53,7 @@ async def async_setup_entry(hass, config_entry):
if config_entry.data.get(CONF_TRACK_HOME, False):
coordinator.track_home()
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][config_entry.entry_id] = coordinator
hass.async_create_task(

View File

@ -13,11 +13,6 @@ from .onewirehub import CannotConnect, OneWireHub
_LOGGER = logging.getLogger(__name__)
async def async_setup(hass, config):
"""Set up 1-Wire integrations."""
return True
async def async_setup_entry(hass: HomeAssistantType, config_entry: ConfigEntry):
"""Set up a 1-Wire proxy for a config entry."""
hass.data.setdefault(DOMAIN, {})

View File

@ -25,11 +25,6 @@ from .const import DATA_CLIENT, DATA_COORDINATOR, DOMAIN
_LOGGER = logging.getLogger(__name__)
async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
"""Set up the OVO Energy components."""
return True
async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool:
"""Set up OVO Energy from a config entry."""

View File

@ -28,12 +28,6 @@ PLATFORMS = ["media_player", "remote"]
LOGGER = logging.getLogger(__name__)
async def async_setup(hass: HomeAssistant, config: dict):
"""Set up the Philips TV component."""
hass.data[DOMAIN] = {}
return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up Philips TV from a config entry."""
@ -47,6 +41,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
coordinator = PhilipsTVDataUpdateCoordinator(hass, tvapi)
await coordinator.async_refresh()
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = coordinator
for platform in PLATFORMS:

View File

@ -84,15 +84,9 @@ WEBHOOK_SCHEMA = vol.Schema(
)
async def async_setup(hass: HomeAssistant, config: dict):
"""Set up the Plaato component."""
hass.data.setdefault(DOMAIN, {})
return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Configure based on config entry."""
hass.data.setdefault(DOMAIN, {})
use_webhook = entry.data[CONF_USE_WEBHOOK]
if use_webhook:

View File

@ -7,11 +7,6 @@ from homeassistant.core import HomeAssistant
from .gateway import async_setup_entry_gw, async_unload_entry_gw
async def async_setup(hass: HomeAssistant, config: dict):
"""Set up the Plugwise platform."""
return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Plugwise components from a config entry."""
if entry.data.get(CONF_HOST):

View File

@ -25,13 +25,6 @@ PLATFORMS = ["sensor", "binary_sensor"]
_LOGGER = logging.getLogger(__name__)
async def async_setup(hass: HomeAssistant, config: dict):
"""Set up the PoolSense component."""
# Make sure coordinator is initialized.
hass.data.setdefault(DOMAIN, {})
return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up PoolSense from a config entry."""
@ -50,6 +43,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
for platform in PLATFORMS:

View File

@ -43,13 +43,6 @@ PLATFORMS = ["binary_sensor", "sensor"]
_LOGGER = logging.getLogger(__name__)
async def async_setup(hass: HomeAssistant, config: dict):
"""Set up the Tesla Powerwall component."""
hass.data.setdefault(DOMAIN, {})
return True
async def _migrate_old_unique_ids(hass, entry_id, powerwall_data):
serial_numbers = powerwall_data[POWERWALL_API_SERIAL_NUMBERS]
site_info = powerwall_data[POWERWALL_API_SITE_INFO]
@ -96,6 +89,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
entry_id = entry.entry_id
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN].setdefault(entry_id, {})
http_session = requests.Session()

View File

@ -15,7 +15,6 @@ from homeassistant.core import HomeAssistant, ServiceCall
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.service import async_register_admin_service
from homeassistant.helpers.typing import ConfigType
from .const import DOMAIN
@ -44,11 +43,6 @@ LOG_INTERVAL_SUB = "log_interval_subscription"
_LOGGER = logging.getLogger(__name__)
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the profiler component."""
return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up Profiler from a config entry."""

View File

@ -13,16 +13,9 @@ from .const import DOMAIN
PLATFORMS = ["switch", "binary_sensor"]
async def async_setup(hass, config):
"""Set up the ProgettiHWSW Automation component."""
hass.data[DOMAIN] = {}
return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up ProgettiHWSW Automation from a config entry."""
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = ProgettiHWSWAPI(
f'{entry.data["host"]}:{entry.data["port"]}'
)

View File

@ -27,12 +27,6 @@ LAST_EVENT_TIMESTAMP_KEY = "last_event_timestamp"
_LOGGER = logging.getLogger(__name__)
async def async_setup(hass: HomeAssistant, config: dict):
"""Set up the Risco component."""
hass.data.setdefault(DOMAIN, {})
return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up Risco from a config entry."""
data = entry.data
@ -54,6 +48,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
undo_listener = entry.add_update_listener(_update_listener)
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = {
DATA_COORDINATOR: coordinator,
UNDO_UPDATE_LISTENER: undo_listener,

View File

@ -6,14 +6,9 @@ from .const import DOMAIN
from .server import RoonServer
async def async_setup(hass, config):
"""Set up the Roon platform."""
hass.data[DOMAIN] = {}
return True
async def async_setup_entry(hass, entry):
"""Set up a roonserver from a config entry."""
hass.data.setdefault(DOMAIN, {})
host = entry.data[CONF_HOST]
roonserver = RoonServer(hass, entry)

View File

@ -23,12 +23,6 @@ class CannotConnect(exceptions.HomeAssistantError):
"""Error to indicate we cannot connect."""
async def async_setup(hass, config):
"""Set up the sharkiq environment."""
hass.data.setdefault(DOMAIN, {})
return True
async def async_connect_or_timeout(ayla_api: AylaApi) -> bool:
"""Connect to vacuum."""
try:
@ -66,6 +60,7 @@ async def async_setup_entry(hass, config_entry):
await coordinator.async_config_entry_first_refresh()
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][config_entry.entry_id] = coordinator
for platform in PLATFORMS:

View File

@ -16,11 +16,6 @@ _LOGGER = logging.getLogger(__name__)
PLATFORMS = ["sensor"]
async def async_setup(hass, config):
"""Old way of setting up the srp_energy component."""
return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up the SRP Energy component from a config entry."""
# Store an SrpEnergyClient object for your srp_energy to access

View File

@ -37,12 +37,6 @@ from .const import (
_LOGGER = logging.getLogger(__name__)
async def async_setup(hass, base_config):
"""Do nothing since this integration does not support configuration.yml setup."""
hass.data.setdefault(DOMAIN, {})
return True
async def async_setup_entry(hass, entry):
"""Set up Subaru from a config entry."""
config = entry.data
@ -88,6 +82,7 @@ async def async_setup_entry(hass, entry):
await coordinator.async_refresh()
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = {
ENTRY_CONTROLLER: controller,
ENTRY_COORDINATOR: coordinator,

View File

@ -45,7 +45,7 @@ async def test_step_user(hass, mock_garmin_connect):
with patch(
"homeassistant.components.garmin_connect.async_setup_entry", return_value=True
), patch("homeassistant.components.garmin_connect.async_setup", return_value=True):
):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": "user"}, data=MOCK_CONF
)

View File

@ -23,8 +23,6 @@ async def test_form(hass):
"homeassistant.components.kmtronic.config_flow.KMTronicHubAPI.async_get_status",
return_value=[Mock()],
), patch(
"homeassistant.components.kmtronic.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.kmtronic.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -45,7 +43,6 @@ async def test_form(hass):
"password": "test-password",
}
await hass.async_block_till_done()
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1

View File

@ -47,8 +47,6 @@ async def test_user_flow(hass, user_flow):
"homeassistant.components.kodi.config_flow.get_kodi_connection",
return_value=MockConnection(),
), patch(
"homeassistant.components.kodi.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.kodi.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -66,7 +64,6 @@ async def test_user_flow(hass, user_flow):
"timeout": DEFAULT_TIMEOUT,
}
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
@ -92,8 +89,6 @@ async def test_form_valid_auth(hass, user_flow):
"homeassistant.components.kodi.config_flow.get_kodi_connection",
return_value=MockConnection(),
), patch(
"homeassistant.components.kodi.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.kodi.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -112,7 +107,6 @@ async def test_form_valid_auth(hass, user_flow):
"timeout": DEFAULT_TIMEOUT,
}
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
@ -142,8 +136,6 @@ async def test_form_valid_ws_port(hass, user_flow):
"homeassistant.components.kodi.config_flow.get_kodi_connection",
return_value=MockConnection(),
), patch(
"homeassistant.components.kodi.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.kodi.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -163,7 +155,6 @@ async def test_form_valid_ws_port(hass, user_flow):
"timeout": DEFAULT_TIMEOUT,
}
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
@ -187,8 +178,6 @@ async def test_form_empty_ws_port(hass, user_flow):
assert result["errors"] == {}
with patch(
"homeassistant.components.kodi.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.kodi.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -208,7 +197,6 @@ async def test_form_empty_ws_port(hass, user_flow):
"timeout": DEFAULT_TIMEOUT,
}
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
@ -430,8 +418,6 @@ async def test_discovery(hass):
assert result["step_id"] == "discovery_confirm"
with patch(
"homeassistant.components.kodi.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.kodi.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -451,7 +437,6 @@ async def test_discovery(hass):
"timeout": DEFAULT_TIMEOUT,
}
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
@ -594,8 +579,6 @@ async def test_form_import(hass):
"homeassistant.components.kodi.config_flow.get_kodi_connection",
return_value=MockConnection(),
), patch(
"homeassistant.components.kodi.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.kodi.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -610,7 +593,6 @@ async def test_form_import(hass):
assert result["title"] == TEST_IMPORT["name"]
assert result["data"] == TEST_IMPORT
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1

View File

@ -23,8 +23,6 @@ async def test_flow_success(hass):
"homeassistant.components.kulersky.config_flow.pykulersky.discover",
return_value=[light],
), patch(
"homeassistant.components.kulersky.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.kulersky.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -38,7 +36,6 @@ async def test_flow_success(hass):
assert result2["title"] == "Kuler Sky"
assert result2["data"] == {}
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
@ -55,8 +52,6 @@ async def test_flow_no_devices_found(hass):
"homeassistant.components.kulersky.config_flow.pykulersky.discover",
return_value=[],
), patch(
"homeassistant.components.kulersky.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.kulersky.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -68,7 +63,6 @@ async def test_flow_no_devices_found(hass):
assert result2["type"] == "abort"
assert result2["reason"] == "no_devices_found"
await hass.async_block_till_done()
assert len(mock_setup.mock_calls) == 0
assert len(mock_setup_entry.mock_calls) == 0
@ -85,8 +79,6 @@ async def test_flow_exceptions_caught(hass):
"homeassistant.components.kulersky.config_flow.pykulersky.discover",
side_effect=pykulersky.PykulerskyException("TEST"),
), patch(
"homeassistant.components.kulersky.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.kulersky.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -98,5 +90,4 @@ async def test_flow_exceptions_caught(hass):
assert result2["type"] == "abort"
assert result2["reason"] == "no_devices_found"
await hass.async_block_till_done()
assert len(mock_setup.mock_calls) == 0
assert len(mock_setup_entry.mock_calls) == 0

View File

@ -55,8 +55,6 @@ async def test_user_owserver(hass):
# Valid server
with patch("homeassistant.components.onewire.onewirehub.protocol.proxy",), patch(
"homeassistant.components.onewire.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.onewire.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -73,15 +71,12 @@ async def test_user_owserver(hass):
CONF_PORT: 1234,
}
await hass.async_block_till_done()
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
async def test_user_owserver_duplicate(hass):
"""Test OWServer flow."""
with patch(
"homeassistant.components.onewire.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.onewire.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -111,7 +106,6 @@ async def test_user_owserver_duplicate(hass):
assert result["type"] == RESULT_TYPE_ABORT
assert result["reason"] == "already_configured"
await hass.async_block_till_done()
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
@ -151,8 +145,6 @@ async def test_user_sysbus(hass):
"homeassistant.components.onewire.onewirehub.os.path.isdir",
return_value=True,
), patch(
"homeassistant.components.onewire.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.onewire.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -168,15 +160,12 @@ async def test_user_sysbus(hass):
CONF_MOUNT_DIR: "/sys/bus/directory",
}
await hass.async_block_till_done()
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
async def test_user_sysbus_duplicate(hass):
"""Test SysBus duplicate flow."""
with patch(
"homeassistant.components.onewire.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.onewire.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -211,7 +200,6 @@ async def test_user_sysbus_duplicate(hass):
assert result["type"] == RESULT_TYPE_ABORT
assert result["reason"] == "already_configured"
await hass.async_block_till_done()
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
@ -222,8 +210,6 @@ async def test_import_sysbus(hass):
"homeassistant.components.onewire.onewirehub.os.path.isdir",
return_value=True,
), patch(
"homeassistant.components.onewire.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.onewire.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -239,7 +225,6 @@ async def test_import_sysbus(hass):
CONF_MOUNT_DIR: DEFAULT_SYSBUS_MOUNT_DIR,
}
await hass.async_block_till_done()
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
@ -250,8 +235,6 @@ async def test_import_sysbus_with_mount_dir(hass):
"homeassistant.components.onewire.onewirehub.os.path.isdir",
return_value=True,
), patch(
"homeassistant.components.onewire.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.onewire.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -270,7 +253,6 @@ async def test_import_sysbus_with_mount_dir(hass):
CONF_MOUNT_DIR: DEFAULT_SYSBUS_MOUNT_DIR,
}
await hass.async_block_till_done()
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
@ -278,8 +260,6 @@ async def test_import_owserver(hass):
"""Test import step."""
with patch("homeassistant.components.onewire.onewirehub.protocol.proxy",), patch(
"homeassistant.components.onewire.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.onewire.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -299,7 +279,6 @@ async def test_import_owserver(hass):
CONF_PORT: DEFAULT_OWSERVER_PORT,
}
await hass.async_block_till_done()
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
@ -307,8 +286,6 @@ async def test_import_owserver_with_port(hass):
"""Test import step."""
with patch("homeassistant.components.onewire.onewirehub.protocol.proxy",), patch(
"homeassistant.components.onewire.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.onewire.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -329,7 +306,6 @@ async def test_import_owserver_with_port(hass):
CONF_PORT: 1234,
}
await hass.async_block_till_done()
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
@ -337,8 +313,6 @@ async def test_import_owserver_duplicate(hass):
"""Test OWServer flow."""
# Initialise with single entry
with patch(
"homeassistant.components.onewire.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.onewire.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -358,5 +332,4 @@ async def test_import_owserver_duplicate(hass):
assert result["type"] == RESULT_TYPE_ABORT
assert result["reason"] == "already_configured"
await hass.async_block_till_done()
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1

View File

@ -84,9 +84,6 @@ async def test_full_flow_implementation(hass: HomeAssistant) -> None:
with patch(
"homeassistant.components.ovo_energy.config_flow.OVOEnergy.authenticate",
return_value=True,
), patch(
"homeassistant.components.ovo_energy.async_setup",
return_value=True,
), patch(
"homeassistant.components.ovo_energy.async_setup_entry",
return_value=True,

View File

@ -18,15 +18,6 @@ from . import (
)
@fixture(autouse=True)
def mock_setup():
"""Disable component setup."""
with patch(
"homeassistant.components.philips_js.async_setup", return_value=True
) as mock_setup:
yield mock_setup
@fixture(autouse=True)
def mock_setup_entry():
"""Disable component setup."""
@ -50,7 +41,7 @@ async def mock_tv_pairable(mock_tv):
return mock_tv
async def test_import(hass, mock_setup, mock_setup_entry):
async def test_import(hass, mock_setup_entry):
"""Test we get an item on import."""
result = await hass.config_entries.flow.async_init(
DOMAIN,
@ -61,7 +52,6 @@ async def test_import(hass, mock_setup, mock_setup_entry):
assert result["type"] == "create_entry"
assert result["title"] == "Philips TV (1234567890)"
assert result["data"] == MOCK_CONFIG
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
@ -77,7 +67,7 @@ async def test_import_exist(hass, mock_config_entry):
assert result["reason"] == "already_configured"
async def test_form(hass, mock_setup, mock_setup_entry):
async def test_form(hass, mock_setup_entry):
"""Test we get the form."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
@ -94,7 +84,6 @@ async def test_form(hass, mock_setup, mock_setup_entry):
assert result2["type"] == "create_entry"
assert result2["title"] == "Philips TV (1234567890)"
assert result2["data"] == MOCK_CONFIG
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
@ -128,7 +117,7 @@ async def test_form_unexpected_error(hass, mock_tv):
assert result["errors"] == {"base": "unknown"}
async def test_pairing(hass, mock_tv_pairable, mock_setup, mock_setup_entry):
async def test_pairing(hass, mock_tv_pairable, mock_setup_entry):
"""Test we get the form."""
mock_tv = mock_tv_pairable
@ -166,13 +155,10 @@ async def test_pairing(hass, mock_tv_pairable, mock_setup, mock_setup_entry):
}
await hass.async_block_till_done()
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
async def test_pair_request_failed(
hass, mock_tv_pairable, mock_setup, mock_setup_entry
):
async def test_pair_request_failed(hass, mock_tv_pairable, mock_setup_entry):
"""Test we get the form."""
mock_tv = mock_tv_pairable
mock_tv.pairRequest.side_effect = PairingFailure({})
@ -197,7 +183,7 @@ async def test_pair_request_failed(
}
async def test_pair_grant_failed(hass, mock_tv_pairable, mock_setup, mock_setup_entry):
async def test_pair_grant_failed(hass, mock_tv_pairable, mock_setup_entry):
"""Test we get the form."""
mock_tv = mock_tv_pairable

View File

@ -243,8 +243,6 @@ async def test_options(hass):
config_entry.add_to_hass(hass)
with patch(
"homeassistant.components.plaato.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.plaato.async_setup_entry", return_value=True
) as mock_setup_entry:
@ -266,7 +264,6 @@ async def test_options(hass):
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["data"][CONF_SCAN_INTERVAL] == 10
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
@ -281,8 +278,6 @@ async def test_options_webhook(hass, webhook_id):
config_entry.add_to_hass(hass)
with patch(
"homeassistant.components.plaato.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.plaato.async_setup_entry", return_value=True
) as mock_setup_entry:
@ -305,5 +300,4 @@ async def test_options_webhook(hass, webhook_id):
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["data"][CONF_WEBHOOK_ID] == CONF_WEBHOOK_ID
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1

View File

@ -72,9 +72,6 @@ async def test_form(hass):
"homeassistant.components.plugwise.config_flow.Smile.connect",
return_value=True,
), patch(
"homeassistant.components.plugwise.async_setup",
return_value=True,
) as mock_setup, patch(
"homeassistant.components.plugwise.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -93,7 +90,6 @@ async def test_form(hass):
CONF_USERNAME: TEST_USERNAME,
}
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
@ -112,9 +108,6 @@ async def test_zeroconf_form(hass):
"homeassistant.components.plugwise.config_flow.Smile.connect",
return_value=True,
), patch(
"homeassistant.components.plugwise.async_setup",
return_value=True,
) as mock_setup, patch(
"homeassistant.components.plugwise.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -133,7 +126,6 @@ async def test_zeroconf_form(hass):
CONF_USERNAME: TEST_USERNAME,
}
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
@ -149,9 +141,6 @@ async def test_form_username(hass):
"homeassistant.components.plugwise.config_flow.Smile.connect",
return_value=True,
), patch(
"homeassistant.components.plugwise.async_setup",
return_value=True,
) as mock_setup, patch(
"homeassistant.components.plugwise.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -174,7 +163,6 @@ async def test_form_username(hass):
CONF_USERNAME: TEST_USERNAME2,
}
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
result3 = await hass.config_entries.flow.async_init(
@ -189,9 +177,6 @@ async def test_form_username(hass):
"homeassistant.components.plugwise.config_flow.Smile.connect",
return_value=True,
), patch(
"homeassistant.components.plugwise.async_setup",
return_value=True,
) as mock_setup, patch(
"homeassistant.components.plugwise.async_setup_entry",
return_value=True,
) as mock_setup_entry:

View File

@ -38,8 +38,6 @@ async def test_valid_credentials(hass):
with patch(
"poolsense.PoolSense.test_poolsense_credentials", return_value=True
), patch(
"homeassistant.components.poolsense.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.poolsense.async_setup_entry", return_value=True
) as mock_setup_entry:
result = await hass.config_entries.flow.async_init(
@ -52,5 +50,4 @@ async def test_valid_credentials(hass):
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["title"] == "test-email"
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1

View File

@ -35,8 +35,6 @@ async def test_form_source_user(hass):
"homeassistant.components.powerwall.config_flow.Powerwall",
return_value=mock_powerwall,
), patch(
"homeassistant.components.powerwall.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.powerwall.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -49,7 +47,6 @@ async def test_form_source_user(hass):
assert result2["type"] == "create_entry"
assert result2["title"] == "My site"
assert result2["data"] == VALID_CONFIG
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
@ -197,8 +194,6 @@ async def test_dhcp_discovery(hass):
"homeassistant.components.powerwall.config_flow.Powerwall",
return_value=mock_powerwall,
), patch(
"homeassistant.components.powerwall.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.powerwall.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -211,7 +206,6 @@ async def test_dhcp_discovery(hass):
assert result2["type"] == "create_entry"
assert result2["title"] == "Some site"
assert result2["data"] == VALID_CONFIG
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
@ -237,8 +231,6 @@ async def test_form_reauth(hass):
"homeassistant.components.powerwall.config_flow.Powerwall",
return_value=mock_powerwall,
), patch(
"homeassistant.components.powerwall.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.powerwall.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -253,5 +245,4 @@ async def test_form_reauth(hass):
assert result2["type"] == "abort"
assert result2["reason"] == "reauth_successful"
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1

View File

@ -17,8 +17,6 @@ async def test_form_user(hass):
assert result["errors"] is None
with patch(
"homeassistant.components.profiler.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.profiler.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -31,7 +29,6 @@ async def test_form_user(hass):
assert result2["type"] == "create_entry"
assert result2["title"] == "Profiler"
assert result2["data"] == {}
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1

View File

@ -48,9 +48,6 @@ async def test_form(hass):
assert result2["errors"] == {}
with patch(
"homeassistant.components.progettihwsw.async_setup",
return_value=True,
), patch(
"homeassistant.components.progettihwsw.async_setup_entry",
return_value=True,
):

View File

@ -59,8 +59,6 @@ async def test_form(hass):
), patch(
"homeassistant.components.risco.config_flow.RiscoAPI.close"
) as mock_close, patch(
"homeassistant.components.risco.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.risco.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -72,7 +70,6 @@ async def test_form(hass):
assert result2["type"] == "create_entry"
assert result2["title"] == TEST_SITE_NAME
assert result2["data"] == TEST_DATA
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
mock_close.assert_awaited_once()

View File

@ -71,8 +71,6 @@ async def test_successful_discovery_and_auth(hass):
), patch(
"homeassistant.components.roon.config_flow.RoonDiscovery",
return_value=RoonDiscoveryMock(),
), patch(
"homeassistant.components.roon.async_setup", return_value=True
), patch(
"homeassistant.components.roon.async_setup_entry",
return_value=True,
@ -111,8 +109,6 @@ async def test_unsuccessful_discovery_user_form_and_auth(hass):
), patch(
"homeassistant.components.roon.config_flow.RoonDiscovery",
return_value=RoonDiscoveryFailedMock(),
), patch(
"homeassistant.components.roon.async_setup", return_value=True
), patch(
"homeassistant.components.roon.async_setup_entry",
return_value=True,
@ -160,8 +156,6 @@ async def test_successful_discovery_no_auth(hass):
), patch(
"homeassistant.components.roon.config_flow.AUTHENTICATE_TIMEOUT",
0.01,
), patch(
"homeassistant.components.roon.async_setup", return_value=True
), patch(
"homeassistant.components.roon.async_setup_entry",
return_value=True,
@ -195,8 +189,6 @@ async def test_unexpected_exception(hass):
), patch(
"homeassistant.components.roon.config_flow.RoonDiscovery",
return_value=RoonDiscoveryMock(),
), patch(
"homeassistant.components.roon.async_setup", return_value=True
), patch(
"homeassistant.components.roon.async_setup_entry",
return_value=True,

View File

@ -24,8 +24,6 @@ async def test_form(hass):
assert result["errors"] == {}
with patch("sharkiqpy.AylaApi.async_sign_in", return_value=True), patch(
"homeassistant.components.sharkiq.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.sharkiq.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -41,7 +39,6 @@ async def test_form(hass):
"password": TEST_PASSWORD,
}
await hass.async_block_till_done()
mock_setup.assert_called_once()
mock_setup_entry.assert_called_once()

View File

@ -21,8 +21,6 @@ async def test_form(hass):
with patch(
"homeassistant.components.srp_energy.config_flow.SrpEnergyClient"
), patch(
"homeassistant.components.srp_energy.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.srp_energy.async_setup_entry",
return_value=True,
) as mock_setup_entry:
@ -36,7 +34,6 @@ async def test_form(hass):
assert result["title"] == "Test"
assert result["data"][CONF_IS_TOU] is False
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1

View File

@ -27,7 +27,6 @@ from .conftest import (
from tests.common import MockConfigEntry
ASYNC_SETUP = "homeassistant.components.subaru.async_setup"
ASYNC_SETUP_ENTRY = "homeassistant.components.subaru.async_setup_entry"
@ -96,8 +95,6 @@ async def test_user_form_pin_not_required(hass, user_form):
MOCK_API_IS_PIN_REQUIRED,
return_value=False,
) as mock_is_pin_required, patch(
ASYNC_SETUP, return_value=True
) as mock_setup, patch(
ASYNC_SETUP_ENTRY, return_value=True
) as mock_setup_entry:
result = await hass.config_entries.flow.async_configure(
@ -106,7 +103,6 @@ async def test_user_form_pin_not_required(hass, user_form):
)
assert len(mock_connect.mock_calls) == 1
assert len(mock_is_pin_required.mock_calls) == 1
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
expected = {
@ -160,8 +156,6 @@ async def test_pin_form_success(hass, pin_form):
MOCK_API_UPDATE_SAVED_PIN,
return_value=True,
) as mock_update_saved_pin, patch(
ASYNC_SETUP, return_value=True
) as mock_setup, patch(
ASYNC_SETUP_ENTRY, return_value=True
) as mock_setup_entry:
result = await hass.config_entries.flow.async_configure(
@ -170,7 +164,6 @@ async def test_pin_form_success(hass, pin_form):
assert len(mock_test_pin.mock_calls) == 1
assert len(mock_update_saved_pin.mock_calls) == 1
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
expected = {
"title": TEST_USERNAME,