Remove unused async_setup method in insteon (#123201)

This commit is contained in:
Michael 2024-08-06 10:13:12 +02:00 committed by GitHub
parent 164cfa85da
commit 0d4ca35784
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 28 deletions

View file

@ -10,8 +10,7 @@ from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.const import CONF_PLATFORM, EVENT_HOMEASSISTANT_STOP
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers import config_validation as cv, device_registry as dr
from homeassistant.helpers.typing import ConfigType
from homeassistant.helpers import device_registry as dr
from . import api
from .const import (
@ -36,8 +35,6 @@ from .utils import (
_LOGGER = logging.getLogger(__name__)
OPTIONS = "options"
CONFIG_SCHEMA = cv.removed(DOMAIN, raise_if_present=False)
async def async_get_device_config(hass, config_entry):
"""Initiate the connection and services."""
@ -77,11 +74,6 @@ async def close_insteon_connection(*args):
await async_close()
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Insteon platform."""
return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up an Insteon entry."""

View file

@ -79,5 +79,4 @@ PATCH_CONNECTION = "homeassistant.components.insteon.config_flow.async_connect"
PATCH_CONNECTION_CLOSE = "homeassistant.components.insteon.config_flow.async_close"
PATCH_DEVICES = "homeassistant.components.insteon.config_flow.devices"
PATCH_USB_LIST = "homeassistant.components.insteon.config_flow.async_get_usb_ports"
PATCH_ASYNC_SETUP = "homeassistant.components.insteon.async_setup"
PATCH_ASYNC_SETUP_ENTRY = "homeassistant.components.insteon.async_setup_entry"

View file

@ -25,7 +25,6 @@ from .const import (
MOCK_USER_INPUT_HUB_V2,
MOCK_USER_INPUT_PLM,
MOCK_USER_INPUT_PLM_MANUAL,
PATCH_ASYNC_SETUP,
PATCH_ASYNC_SETUP_ENTRY,
PATCH_CONNECTION,
PATCH_USB_LIST,
@ -81,7 +80,6 @@ async def _device_form(hass, flow_id, connection, user_input):
PATCH_CONNECTION,
new=connection,
),
patch(PATCH_ASYNC_SETUP, return_value=True) as mock_setup,
patch(
PATCH_ASYNC_SETUP_ENTRY,
return_value=True,
@ -89,7 +87,7 @@ async def _device_form(hass, flow_id, connection, user_input):
):
result = await hass.config_entries.flow.async_configure(flow_id, user_input)
await hass.async_block_till_done()
return result, mock_setup, mock_setup_entry
return result, mock_setup_entry
async def test_form_select_modem(hass: HomeAssistant) -> None:
@ -125,13 +123,12 @@ async def test_form_select_plm(hass: HomeAssistant) -> None:
result = await _init_form(hass, STEP_PLM)
result2, mock_setup, mock_setup_entry = await _device_form(
result2, mock_setup_entry = await _device_form(
hass, result["flow_id"], mock_successful_connection, MOCK_USER_INPUT_PLM
)
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["data"] == MOCK_USER_INPUT_PLM
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
@ -142,7 +139,7 @@ async def test_form_select_plm_no_usb(hass: HomeAssistant) -> None:
USB_PORTS.clear()
result = await _init_form(hass, STEP_PLM)
result2, _, _ = await _device_form(
result2, _ = await _device_form(
hass, result["flow_id"], mock_successful_connection, None
)
USB_PORTS.update(temp_usb_list)
@ -155,18 +152,17 @@ async def test_form_select_plm_manual(hass: HomeAssistant) -> None:
result = await _init_form(hass, STEP_PLM)
result2, mock_setup, mock_setup_entry = await _device_form(
result2, mock_setup_entry = await _device_form(
hass, result["flow_id"], mock_failed_connection, MOCK_USER_INPUT_PLM_MANUAL
)
result3, mock_setup, mock_setup_entry = await _device_form(
result3, mock_setup_entry = await _device_form(
hass, result2["flow_id"], mock_successful_connection, MOCK_USER_INPUT_PLM
)
assert result2["type"] is FlowResultType.FORM
assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["data"] == MOCK_USER_INPUT_PLM
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
@ -175,7 +171,7 @@ async def test_form_select_hub_v1(hass: HomeAssistant) -> None:
result = await _init_form(hass, STEP_HUB_V1)
result2, mock_setup, mock_setup_entry = await _device_form(
result2, mock_setup_entry = await _device_form(
hass, result["flow_id"], mock_successful_connection, MOCK_USER_INPUT_HUB_V1
)
assert result2["type"] is FlowResultType.CREATE_ENTRY
@ -184,7 +180,6 @@ async def test_form_select_hub_v1(hass: HomeAssistant) -> None:
CONF_HUB_VERSION: 1,
}
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
@ -193,7 +188,7 @@ async def test_form_select_hub_v2(hass: HomeAssistant) -> None:
result = await _init_form(hass, STEP_HUB_V2)
result2, mock_setup, mock_setup_entry = await _device_form(
result2, mock_setup_entry = await _device_form(
hass, result["flow_id"], mock_successful_connection, MOCK_USER_INPUT_HUB_V2
)
assert result2["type"] is FlowResultType.CREATE_ENTRY
@ -202,7 +197,6 @@ async def test_form_select_hub_v2(hass: HomeAssistant) -> None:
CONF_HUB_VERSION: 2,
}
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
@ -233,7 +227,7 @@ async def test_failed_connection_plm(hass: HomeAssistant) -> None:
result = await _init_form(hass, STEP_PLM)
result2, _, _ = await _device_form(
result2, _ = await _device_form(
hass, result["flow_id"], mock_failed_connection, MOCK_USER_INPUT_PLM
)
assert result2["type"] is FlowResultType.FORM
@ -245,10 +239,10 @@ async def test_failed_connection_plm_manually(hass: HomeAssistant) -> None:
result = await _init_form(hass, STEP_PLM)
result2, _, _ = await _device_form(
result2, _ = await _device_form(
hass, result["flow_id"], mock_successful_connection, MOCK_USER_INPUT_PLM_MANUAL
)
result3, _, _ = await _device_form(
result3, _ = await _device_form(
hass, result["flow_id"], mock_failed_connection, MOCK_USER_INPUT_PLM
)
assert result3["type"] is FlowResultType.FORM
@ -260,7 +254,7 @@ async def test_failed_connection_hub(hass: HomeAssistant) -> None:
result = await _init_form(hass, STEP_HUB_V2)
result2, _, _ = await _device_form(
result2, _ = await _device_form(
hass, result["flow_id"], mock_failed_connection, MOCK_USER_INPUT_HUB_V2
)
assert result2["type"] is FlowResultType.FORM
@ -284,7 +278,7 @@ async def test_discovery_via_usb(hass: HomeAssistant) -> None:
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm_usb"
with patch(PATCH_CONNECTION), patch(PATCH_ASYNC_SETUP, return_value=True):
with patch(PATCH_CONNECTION):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={}
)