Cleanup of unused connection_class logic (#49865)

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
This commit is contained in:
Franck Nijhof 2021-04-29 23:12:58 +02:00 committed by GitHub
parent db886ef03a
commit c68b259bd3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
53 changed files with 50 additions and 162 deletions

View file

@ -6,7 +6,6 @@ from typing import Any
from adguardhome import AdGuardHome, AdGuardHomeConnectionError
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow
from homeassistant.const import (
CONF_HOST,
@ -26,7 +25,6 @@ class AdGuardHomeFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a AdGuard Home config flow."""
VERSION = 1
CONNECTION_CLASS = config_entries.CONN_CLASS_LOCAL_POLL
_hassio_discovery = None

View file

@ -386,7 +386,6 @@ def entry_json(entry: config_entries.ConfigEntry) -> dict:
"title": entry.title,
"source": entry.source,
"state": entry.state,
"connection_class": entry.connection_class,
"supports_options": supports_options,
"supports_unload": entry.supports_unload,
"disabled_by": entry.disabled_by,

View file

@ -1,7 +1,6 @@
"""Config flow for Gree."""
from greeclimate.discovery import Discovery
from homeassistant import config_entries
from homeassistant.helpers import config_entry_flow
from .const import DISCOVERY_TIMEOUT, DOMAIN
@ -14,6 +13,4 @@ async def _async_has_devices(hass) -> bool:
return len(devices) > 0
config_entry_flow.register_discovery_flow(
DOMAIN, "Gree Climate", _async_has_devices, config_entries.CONN_CLASS_LOCAL_POLL
)
config_entry_flow.register_discovery_flow(DOMAIN, "Gree Climate", _async_has_devices)

View file

@ -1,7 +1,6 @@
"""Config flow for Hisense AEH-W4A1 integration."""
from pyaehw4a1.aehw4a1 import AehW4a1
from homeassistant import config_entries
from homeassistant.helpers import config_entry_flow
from .const import DOMAIN
@ -14,5 +13,5 @@ async def _async_has_devices(hass):
config_entry_flow.register_discovery_flow(
DOMAIN, "Hisense AEH-W4A1", _async_has_devices, config_entries.CONN_CLASS_LOCAL_POLL
DOMAIN, "Hisense AEH-W4A1", _async_has_devices
)

View file

@ -1,9 +1,6 @@
"""Config flow for iOS."""
from homeassistant import config_entries
from homeassistant.helpers import config_entry_flow
from .const import DOMAIN
config_entry_flow.register_discovery_flow(
DOMAIN, "Home Assistant iOS", lambda *_: True, config_entries.CONN_CLASS_CLOUD_PUSH
)
config_entry_flow.register_discovery_flow(DOMAIN, "Home Assistant iOS", lambda *_: True)

View file

@ -6,7 +6,6 @@ import logging
from async_timeout import timeout
from homeassistant import config_entries
from homeassistant.core import callback
from homeassistant.helpers import config_entry_flow
from homeassistant.helpers.dispatcher import async_dispatcher_connect
@ -42,6 +41,4 @@ async def _async_has_devices(hass):
return True
config_entry_flow.register_discovery_flow(
IZONE, "iZone Aircon", _async_has_devices, config_entries.CONN_CLASS_LOCAL_POLL
)
config_entry_flow.register_discovery_flow(IZONE, "iZone Aircon", _async_has_devices)

View file

@ -3,7 +3,6 @@ import logging
import pykulersky
from homeassistant import config_entries
from homeassistant.helpers import config_entry_flow
from .const import DOMAIN
@ -22,6 +21,4 @@ async def _async_has_devices(hass) -> bool:
return len(devices) > 0
config_entry_flow.register_discovery_flow(
DOMAIN, "Kuler Sky", _async_has_devices, config_entries.CONN_CLASS_LOCAL_POLL
)
config_entry_flow.register_discovery_flow(DOMAIN, "Kuler Sky", _async_has_devices)

View file

@ -1,7 +1,6 @@
"""Config flow flow LIFX."""
import aiolifx
from homeassistant import config_entries
from homeassistant.helpers import config_entry_flow
from .const import DOMAIN
@ -13,6 +12,4 @@ async def _async_has_devices(hass):
return len(lifx_ip_addresses) > 0
config_entry_flow.register_discovery_flow(
DOMAIN, "LIFX", _async_has_devices, config_entries.CONN_CLASS_LOCAL_POLL
)
config_entry_flow.register_discovery_flow(DOMAIN, "LIFX", _async_has_devices)

View file

@ -5,7 +5,6 @@ from typing import Any
from rpi_bad_power import new_under_voltage
from homeassistant import config_entries
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.config_entry_flow import DiscoveryFlowHandler
@ -30,7 +29,6 @@ class RPiPowerFlow(DiscoveryFlowHandler, domain=DOMAIN):
DOMAIN,
"Raspberry Pi Power Supply Checker",
_async_supported,
config_entries.CONN_CLASS_LOCAL_POLL,
)
async def async_step_onboarding(

View file

@ -1,7 +1,6 @@
"""Config flow for SONOS."""
import pysonos
from homeassistant import config_entries
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_entry_flow
@ -14,6 +13,4 @@ async def _async_has_devices(hass: HomeAssistant) -> bool:
return bool(result)
config_entry_flow.register_discovery_flow(
DOMAIN, "Sonos", _async_has_devices, config_entries.CONN_CLASS_LOCAL_PUSH
)
config_entry_flow.register_discovery_flow(DOMAIN, "Sonos", _async_has_devices)

View file

@ -1,5 +1,4 @@
"""Config flow for TP-Link."""
from homeassistant import config_entries
from homeassistant.helpers import config_entry_flow
from .common import async_get_discoverable_devices
@ -9,5 +8,4 @@ config_entry_flow.register_discovery_flow(
DOMAIN,
"TP-Link Smart Home",
async_get_discoverable_devices,
config_entries.CONN_CLASS_LOCAL_POLL,
)

View file

@ -11,12 +11,7 @@ from verisure import (
)
import voluptuous as vol
from homeassistant.config_entries import (
CONN_CLASS_CLOUD_POLL,
ConfigEntry,
ConfigFlow,
OptionsFlow,
)
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
@ -35,7 +30,6 @@ class VerisureConfigFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Verisure."""
VERSION = 1
CONNECTION_CLASS = CONN_CLASS_CLOUD_POLL
email: str
entry: ConfigEntry

View file

@ -2,7 +2,6 @@
import pywemo
from homeassistant import config_entries
from homeassistant.helpers import config_entry_flow
from . import DOMAIN
@ -13,6 +12,4 @@ async def _async_has_devices(hass):
return bool(await hass.async_add_executor_job(pywemo.discover_devices))
config_entry_flow.register_discovery_flow(
DOMAIN, "Wemo", _async_has_devices, config_entries.CONN_CLASS_LOCAL_PUSH
)
config_entry_flow.register_discovery_flow(DOMAIN, "Wemo", _async_has_devices)

View file

@ -3,7 +3,6 @@ import logging
import pyzerproc
from homeassistant import config_entries
from homeassistant.helpers import config_entry_flow
from .const import DOMAIN
@ -21,6 +20,4 @@ async def _async_has_devices(hass) -> bool:
return False
config_entry_flow.register_discovery_flow(
DOMAIN, "Zerproc", _async_has_devices, config_entries.CONN_CLASS_LOCAL_POLL
)
config_entry_flow.register_discovery_flow(DOMAIN, "Zerproc", _async_has_devices)

View file

@ -133,7 +133,6 @@ class ConfigEntry:
"supports_unload",
"system_options",
"source",
"connection_class",
"state",
"disabled_by",
"_setup_lock",
@ -150,7 +149,6 @@ class ConfigEntry:
title: str,
data: Mapping[str, Any],
source: str,
connection_class: str,
system_options: dict,
options: dict | None = None,
unique_id: str | None = None,
@ -183,9 +181,6 @@ class ConfigEntry:
# Source of the configuration (user, discovery, cloud)
self.source = source
# Connection class
self.connection_class = connection_class
# State of the entry (LOADED, NOT_LOADED)
self.state = state
@ -521,7 +516,6 @@ class ConfigEntry:
"options": dict(self.options),
"system_options": self.system_options.as_dict(),
"source": self.source,
"connection_class": self.connection_class,
"unique_id": self.unique_id,
"disabled_by": self.disabled_by,
}
@ -637,7 +631,6 @@ class ConfigEntriesFlowManager(data_entry_flow.FlowManager):
options={},
system_options={},
source=flow.context["source"],
connection_class=flow.CONNECTION_CLASS,
unique_id=flow.unique_id,
)
@ -837,8 +830,6 @@ class ConfigEntries:
data=entry["data"],
source=entry["source"],
title=entry["title"],
# New in 0.79
connection_class=entry.get("connection_class", CONN_CLASS_UNKNOWN),
# New in 0.89
options=entry.get("options"),
# New in 0.98

View file

@ -1,15 +1,18 @@
"""Helpers for data entry flows for config entries."""
from __future__ import annotations
import logging
from typing import Any, Awaitable, Callable, Union
from homeassistant import config_entries
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.typing import DiscoveryInfoType
from homeassistant.helpers.typing import UNDEFINED, DiscoveryInfoType, UndefinedType
DiscoveryFunctionType = Callable[[], Union[Awaitable[bool], bool]]
_LOGGER = logging.getLogger(__name__)
class DiscoveryFlowHandler(config_entries.ConfigFlow):
"""Handle a discovery config flow."""
@ -21,13 +24,11 @@ class DiscoveryFlowHandler(config_entries.ConfigFlow):
domain: str,
title: str,
discovery_function: DiscoveryFunctionType,
connection_class: str,
) -> None:
"""Initialize the discovery config flow."""
self._domain = domain
self._title = title
self._discovery_function = discovery_function
self.CONNECTION_CLASS = connection_class # pylint: disable=invalid-name
async def async_step_user(
self, user_input: dict[str, Any] | None = None
@ -104,15 +105,29 @@ def register_discovery_flow(
domain: str,
title: str,
discovery_function: DiscoveryFunctionType,
connection_class: str,
connection_class: str | UndefinedType = UNDEFINED,
) -> None:
"""Register flow for discovered integrations that not require auth."""
if connection_class is not UNDEFINED:
_LOGGER.warning(
(
"The %s (%s) integration is setting a connection_class"
" when calling the 'register_discovery_flow()' method in its"
" config flow. The connection class has been deprecated and will"
" be removed in a future release of Home Assistant."
" If '%s' is a custom integration, please contact the author"
" of that integration about this warning.",
),
title,
domain,
domain,
)
class DiscoveryFlow(DiscoveryFlowHandler):
"""Discovery flow handler."""
def __init__(self) -> None:
super().__init__(domain, title, discovery_function, connection_class)
super().__init__(domain, title, discovery_function)
config_entries.HANDLERS.register(domain)(DiscoveryFlow)

View file

@ -1,7 +1,6 @@
"""Config flow for NEW_NAME."""
import my_pypi_dependency
from homeassistant import config_entries
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_entry_flow
@ -15,6 +14,4 @@ async def _async_has_devices(hass: HomeAssistant) -> bool:
return len(devices) > 0
config_entry_flow.register_discovery_flow(
DOMAIN, "NEW_NAME", _async_has_devices, config_entries.CONN_CLASS_UNKNOWN
)
config_entry_flow.register_discovery_flow(DOMAIN, "NEW_NAME", _async_has_devices)

View file

@ -731,7 +731,6 @@ class MockConfigEntry(config_entries.ConfigEntry):
state=None,
options={},
system_options={},
connection_class=config_entries.CONN_CLASS_UNKNOWN,
unique_id=None,
disabled_by=None,
reason=None,
@ -745,7 +744,6 @@ class MockConfigEntry(config_entries.ConfigEntry):
"options": options,
"version": version,
"title": title,
"connection_class": connection_class,
"unique_id": unique_id,
"disabled_by": disabled_by,
}

View file

@ -8,7 +8,6 @@ from axis.event_stream import OPERATION_INITIALIZED
import pytest
import respx
from homeassistant import config_entries
from homeassistant.components import axis
from homeassistant.components.axis.const import (
CONF_EVENTS,
@ -283,7 +282,6 @@ async def setup_axis_integration(hass, config=ENTRY_CONFIG, options=ENTRY_OPTION
config_entry = MockConfigEntry(
domain=AXIS_DOMAIN,
data=deepcopy(config),
connection_class=config_entries.CONN_CLASS_LOCAL_PUSH,
options=deepcopy(options),
version=3,
unique_id=FORMATTED_MAC,

View file

@ -31,7 +31,6 @@ FIXTURE_CONFIG_ENTRY = {
"options": {CONF_READ_ONLY: False, CONF_USE_LOCATION: False},
"system_options": {"disable_new_entities": False},
"source": config_entries.SOURCE_USER,
"connection_class": config_entries.CONN_CLASS_CLOUD_POLL,
"unique_id": f"{FIXTURE_USER_INPUT[CONF_REGION]}-{FIXTURE_USER_INPUT[CONF_REGION]}",
}

View file

@ -2,7 +2,6 @@
from unittest.mock import patch
from homeassistant import config_entries
from homeassistant.components.cast import home_assistant_cast
from homeassistant.config import async_process_ha_core_config
@ -93,7 +92,6 @@ async def test_use_cloud_url(hass, mock_zeroconf):
async def test_remove_entry(hass, mock_zeroconf):
"""Test removing config entry removes user."""
entry = MockConfigEntry(
connection_class=config_entries.CONN_CLASS_LOCAL_PUSH,
data={},
domain="cast",
title="Google Cast",

View file

@ -50,14 +50,13 @@ async def test_get_entries(hass, client):
pass
hass.helpers.config_entry_flow.register_discovery_flow(
"comp2", "Comp 2", lambda: None, core_ce.CONN_CLASS_ASSUMED
"comp2", "Comp 2", lambda: None
)
entry = MockConfigEntry(
domain="comp1",
title="Test 1",
source="bla",
connection_class=core_ce.CONN_CLASS_LOCAL_POLL,
)
entry.supports_unload = True
entry.add_to_hass(hass)
@ -67,7 +66,6 @@ async def test_get_entries(hass, client):
source="bla2",
state=core_ce.ENTRY_STATE_SETUP_ERROR,
reason="Unsupported API",
connection_class=core_ce.CONN_CLASS_ASSUMED,
).add_to_hass(hass)
MockConfigEntry(
domain="comp3",
@ -87,7 +85,6 @@ async def test_get_entries(hass, client):
"title": "Test 1",
"source": "bla",
"state": "not_loaded",
"connection_class": "local_poll",
"supports_options": True,
"supports_unload": True,
"disabled_by": None,
@ -98,7 +95,6 @@ async def test_get_entries(hass, client):
"title": "Test 2",
"source": "bla2",
"state": "setup_error",
"connection_class": "assumed",
"supports_options": False,
"supports_unload": False,
"disabled_by": None,
@ -109,7 +105,6 @@ async def test_get_entries(hass, client):
"title": "Test 3",
"source": "bla3",
"state": "not_loaded",
"connection_class": "unknown",
"supports_options": False,
"supports_unload": False,
"disabled_by": core_ce.DISABLED_USER,
@ -326,7 +321,6 @@ async def test_create_account(hass, client):
"type": "create_entry",
"version": 1,
"result": {
"connection_class": "unknown",
"disabled_by": None,
"domain": "test",
"entry_id": entries[0].entry_id,
@ -397,7 +391,6 @@ async def test_two_step_flow(hass, client):
"title": "user-title",
"version": 1,
"result": {
"connection_class": "unknown",
"disabled_by": None,
"domain": "test",
"entry_id": entries[0].entry_id,
@ -596,7 +589,6 @@ async def test_options_flow(hass, client):
domain="test",
entry_id="test1",
source="bla",
connection_class=core_ce.CONN_CLASS_LOCAL_POLL,
).add_to_hass(hass)
entry = hass.config_entries.async_entries()[0]
@ -646,7 +638,6 @@ async def test_two_step_options_flow(hass, client):
domain="test",
entry_id="test1",
source="bla",
connection_class=core_ce.CONN_CLASS_LOCAL_POLL,
).add_to_hass(hass)
entry = hass.config_entries.async_entries()[0]

View file

@ -32,7 +32,7 @@ from homeassistant.components.ssdp import (
ATTR_UPNP_UDN,
)
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
from homeassistant.config_entries import CONN_CLASS_LOCAL_PUSH, SOURCE_SSDP, SOURCE_USER
from homeassistant.config_entries import SOURCE_SSDP, SOURCE_USER
from homeassistant.const import (
CONF_API_KEY,
CONF_HOST,
@ -116,7 +116,6 @@ async def setup_deconz_integration(
domain=DECONZ_DOMAIN,
source=source,
data=deepcopy(config),
connection_class=CONN_CLASS_LOCAL_PUSH,
options=deepcopy(options),
entry_id=entry_id,
unique_id=unique_id,

View file

@ -31,7 +31,6 @@ async def async_setup_test_fixture(hass, mock_get_station, initial_value):
entry_id="VikingRecorder1234",
data={"station": "L1234"},
title="Viking Recorder",
connection_class=config_entries.CONN_CLASS_CLOUD_PUSH,
)
entry.add_to_hass(hass)

View file

@ -11,11 +11,7 @@ from homeassistant.components.forked_daapd.const import (
CONF_TTS_VOLUME,
DOMAIN,
)
from homeassistant.config_entries import (
CONN_CLASS_LOCAL_PUSH,
SOURCE_USER,
SOURCE_ZEROCONF,
)
from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT
from tests.common import MockConfigEntry
@ -52,7 +48,6 @@ def config_entry_fixture():
options={},
system_options={},
source=SOURCE_USER,
connection_class=CONN_CLASS_LOCAL_PUSH,
entry_id=1,
)

View file

@ -54,7 +54,7 @@ from homeassistant.components.media_player.const import (
MEDIA_TYPE_MUSIC,
MEDIA_TYPE_TVSHOW,
)
from homeassistant.config_entries import CONN_CLASS_LOCAL_PUSH, SOURCE_USER
from homeassistant.config_entries import SOURCE_USER
from homeassistant.const import (
ATTR_ENTITY_ID,
ATTR_FRIENDLY_NAME,
@ -284,7 +284,6 @@ def config_entry_fixture():
options={CONF_TTS_PAUSE_TIME: 0},
system_options={},
source=SOURCE_USER,
connection_class=CONN_CLASS_LOCAL_PUSH,
entry_id=1,
)

View file

@ -3,7 +3,6 @@ from homepluscontrol.homeplusinteractivemodule import HomePlusInteractiveModule
from homepluscontrol.homeplusplant import HomePlusPlant
import pytest
from homeassistant import config_entries
from homeassistant.components.home_plus_control.const import DOMAIN
from tests.common import MockConfigEntry
@ -35,7 +34,6 @@ def mock_config_entry():
},
},
source="test",
connection_class=config_entries.CONN_CLASS_LOCAL_POLL,
options={},
system_options={"disable_new_entities": False},
unique_id=DOMAIN,

View file

@ -9,7 +9,6 @@ from aiohomekit.model.characteristics import CharacteristicsTypes
from aiohomekit.model.services import ServicesTypes
from aiohomekit.testing import FakeController
from homeassistant import config_entries
from homeassistant.components.homekit_controller import config_flow
from homeassistant.components.homekit_controller.const import (
CONTROLLER,
@ -99,7 +98,6 @@ async def setup_test_accessories(hass, accessories):
entry_id="TestData",
data={"AccessoryPairingID": pairing_id},
title="test",
connection_class=config_entries.CONN_CLASS_LOCAL_PUSH,
)
config_entry.add_to_hass(hass)

View file

@ -95,7 +95,6 @@ async def test_storage_is_removed_on_config_entry_removal(hass, utcnow):
"TestData",
pairing_data,
"test",
config_entries.CONN_CLASS_LOCAL_PUSH,
system_options={},
)

View file

@ -62,7 +62,6 @@ def hmip_config_entry_fixture() -> config_entries.ConfigEntry:
unique_id=HAPID,
data=entry_data,
source=SOURCE_IMPORT,
connection_class=config_entries.CONN_CLASS_CLOUD_PUSH,
system_options={"disable_new_entities": False},
)

View file

@ -8,7 +8,6 @@ from aiohue.scenes import Scenes
from aiohue.sensors import Sensors
import pytest
from homeassistant import config_entries
from homeassistant.components import hue
from homeassistant.components.hue import sensor_base as hue_sensor_base
@ -116,7 +115,6 @@ async def setup_bridge_for_sensors(hass, mock_bridge, hostname=None):
domain=hue.DOMAIN,
title="Mock Title",
data={"host": hostname},
connection_class=config_entries.CONN_CLASS_LOCAL_POLL,
system_options={},
)
mock_bridge.config_entry = config_entry

View file

@ -166,7 +166,6 @@ async def test_hue_activate_scene(hass, mock_api):
"Mock Title",
{"host": "mock-host", "username": "mock-username"},
"test",
config_entries.CONN_CLASS_LOCAL_POLL,
system_options={},
options={CONF_ALLOW_HUE_GROUPS: True, CONF_ALLOW_UNREACHABLE: False},
)
@ -201,7 +200,6 @@ async def test_hue_activate_scene_transition(hass, mock_api):
"Mock Title",
{"host": "mock-host", "username": "mock-username"},
"test",
config_entries.CONN_CLASS_LOCAL_POLL,
system_options={},
options={CONF_ALLOW_HUE_GROUPS: True, CONF_ALLOW_UNREACHABLE: False},
)
@ -236,7 +234,6 @@ async def test_hue_activate_scene_group_not_found(hass, mock_api):
"Mock Title",
{"host": "mock-host", "username": "mock-username"},
"test",
config_entries.CONN_CLASS_LOCAL_POLL,
system_options={},
options={CONF_ALLOW_HUE_GROUPS: True, CONF_ALLOW_UNREACHABLE: False},
)
@ -266,7 +263,6 @@ async def test_hue_activate_scene_scene_not_found(hass, mock_api):
"Mock Title",
{"host": "mock-host", "username": "mock-username"},
"test",
config_entries.CONN_CLASS_LOCAL_POLL,
system_options={},
options={CONF_ALLOW_HUE_GROUPS: True, CONF_ALLOW_UNREACHABLE: False},
)

View file

@ -7,7 +7,6 @@ from aiohue.scenes import Scenes
from aiohue.sensors import Sensors
import pytest
from homeassistant import config_entries
from homeassistant.components import hue
from homeassistant.components.hue import sensor_base as hue_sensor_base
from homeassistant.setup import async_setup_component
@ -132,7 +131,6 @@ def create_config_entry():
return MockConfigEntry(
domain=hue.DOMAIN,
data={"host": "mock-host"},
connection_class=config_entries.CONN_CLASS_LOCAL_POLL,
)

View file

@ -179,7 +179,6 @@ async def setup_bridge(hass, mock_bridge):
"Mock Title",
{"host": "mock-host"},
"test",
config_entries.CONN_CLASS_LOCAL_POLL,
system_options={},
)
mock_bridge.config_entry = config_entry

View file

@ -5,7 +5,6 @@ from huisbaasje import HuisbaasjeException
from homeassistant.components import huisbaasje
from homeassistant.config_entries import (
CONN_CLASS_CLOUD_POLL,
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_ERROR,
@ -46,7 +45,6 @@ async def test_setup_entry(hass: HomeAssistant):
CONF_PASSWORD: "password",
},
source="test",
connection_class=CONN_CLASS_CLOUD_POLL,
system_options={},
)
config_entry.add_to_hass(hass)
@ -87,7 +85,6 @@ async def test_setup_entry_error(hass: HomeAssistant):
CONF_PASSWORD: "password",
},
source="test",
connection_class=CONN_CLASS_CLOUD_POLL,
system_options={},
)
config_entry.add_to_hass(hass)
@ -129,7 +126,6 @@ async def test_unload_entry(hass: HomeAssistant):
CONF_PASSWORD: "password",
},
source="test",
connection_class=CONN_CLASS_CLOUD_POLL,
system_options={},
)
config_entry.add_to_hass(hass)

View file

@ -2,7 +2,6 @@
from unittest.mock import patch
from homeassistant.components import huisbaasje
from homeassistant.config_entries import CONN_CLASS_CLOUD_POLL
from homeassistant.const import CONF_ID, CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant
@ -35,7 +34,6 @@ async def test_setup_entry(hass: HomeAssistant):
CONF_PASSWORD: "password",
},
source="test",
connection_class=CONN_CLASS_CLOUD_POLL,
system_options={},
)
config_entry.add_to_hass(hass)
@ -92,7 +90,6 @@ async def test_setup_entry_absent_measurement(hass: HomeAssistant):
CONF_PASSWORD: "password",
},
source="test",
connection_class=CONN_CLASS_CLOUD_POLL,
system_options={},
)
config_entry.add_to_hass(hass)

View file

@ -11,7 +11,7 @@ from homeassistant.components.hvv_departures.const import (
CONF_STATION,
DOMAIN,
)
from homeassistant.config_entries import CONN_CLASS_CLOUD_POLL, SOURCE_USER
from homeassistant.config_entries import SOURCE_USER
from homeassistant.const import CONF_HOST, CONF_OFFSET, CONF_PASSWORD, CONF_USERNAME
from tests.common import MockConfigEntry, load_fixture
@ -256,7 +256,6 @@ async def test_options_flow(hass):
title="Wartenau",
data=FIXTURE_CONFIG_ENTRY,
source=SOURCE_USER,
connection_class=CONN_CLASS_CLOUD_POLL,
system_options={"disable_new_entities": False},
options=FIXTURE_OPTIONS,
unique_id="1234",
@ -307,7 +306,6 @@ async def test_options_flow_invalid_auth(hass):
title="Wartenau",
data=FIXTURE_CONFIG_ENTRY,
source=SOURCE_USER,
connection_class=CONN_CLASS_CLOUD_POLL,
system_options={"disable_new_entities": False},
options=FIXTURE_OPTIONS,
unique_id="1234",
@ -348,7 +346,6 @@ async def test_options_flow_cannot_connect(hass):
title="Wartenau",
data=FIXTURE_CONFIG_ENTRY,
source=SOURCE_USER,
connection_class=CONN_CLASS_CLOUD_POLL,
system_options={"disable_new_entities": False},
options=FIXTURE_OPTIONS,
unique_id="1234",

View file

@ -34,7 +34,6 @@ async def setup_push_receiver(hass, aioclient_mock):
)
entry = MockConfigEntry(
connection_class="cloud_push",
data={
"app_data": {"push_token": "PUSH_TOKEN", "push_url": push_url},
"app_id": "io.homeassistant.mobile_app",
@ -62,7 +61,6 @@ async def setup_push_receiver(hass, aioclient_mock):
await hass.async_block_till_done()
loaded_late_entry = MockConfigEntry(
connection_class="cloud_push",
data={
"app_data": {"push_token": "PUSH_TOKEN2", "push_url": f"{push_url}2"},
"app_id": "io.homeassistant.mobile_app",

View file

@ -14,7 +14,7 @@ from homeassistant.components.onewire.const import (
DEFAULT_SYSBUS_MOUNT_DIR,
DOMAIN,
)
from homeassistant.config_entries import CONN_CLASS_LOCAL_POLL, SOURCE_USER
from homeassistant.config_entries import SOURCE_USER
from homeassistant.const import CONF_HOST, CONF_PORT, CONF_TYPE
from .const import MOCK_OWPROXY_DEVICES, MOCK_SYSBUS_DEVICES
@ -32,7 +32,6 @@ async def setup_onewire_sysbus_integration(hass):
CONF_MOUNT_DIR: DEFAULT_SYSBUS_MOUNT_DIR,
},
unique_id=f"{CONF_TYPE_SYSBUS}:{DEFAULT_SYSBUS_MOUNT_DIR}",
connection_class=CONN_CLASS_LOCAL_POLL,
options={},
entry_id="1",
)
@ -57,7 +56,6 @@ async def setup_onewire_owserver_integration(hass):
CONF_HOST: "1.2.3.4",
CONF_PORT: 1234,
},
connection_class=CONN_CLASS_LOCAL_POLL,
options={},
entry_id="2",
)
@ -85,7 +83,6 @@ async def setup_onewire_patched_owserver_integration(hass):
"10.111111111111": "My DS18B20",
},
},
connection_class=CONN_CLASS_LOCAL_POLL,
options={},
entry_id="2",
)

View file

@ -6,7 +6,6 @@ from pyownet.protocol import ConnError, OwnetError
from homeassistant.components.onewire.const import CONF_TYPE_OWSERVER, DOMAIN
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
from homeassistant.config_entries import (
CONN_CLASS_LOCAL_POLL,
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_RETRY,
@ -37,7 +36,6 @@ async def test_owserver_connect_failure(hass):
CONF_PORT: "1234",
},
unique_id=f"{CONF_TYPE_OWSERVER}:1.2.3.4:1234",
connection_class=CONN_CLASS_LOCAL_POLL,
options={},
entry_id="2",
)
@ -66,7 +64,6 @@ async def test_failed_owserver_listing(hass):
CONF_PORT: "1234",
},
unique_id=f"{CONF_TYPE_OWSERVER}:1.2.3.4:1234",
connection_class=CONN_CLASS_LOCAL_POLL,
options={},
entry_id="2",
)

View file

@ -153,7 +153,6 @@ async def setup_onvif_integration(
domain=config_flow.DOMAIN,
source=source,
data={**config},
connection_class=config_entries.CONN_CLASS_LOCAL_PUSH,
options=options or {},
entry_id=entry_id,
unique_id=unique_id,

View file

@ -17,7 +17,6 @@ async def setup_ozw(hass, entry=None, fixture=None):
entry = MockConfigEntry(
domain=DOMAIN,
title="Z-Wave",
connection_class=config_entries.CONN_CLASS_LOCAL_PUSH,
)
entry.add_to_hass(hass)

View file

@ -31,7 +31,6 @@ async def test_setup_entry_without_mqtt(hass):
entry = MockConfigEntry(
domain=DOMAIN,
title="OpenZWave",
connection_class=config_entries.CONN_CLASS_LOCAL_PUSH,
)
entry.add_to_hass(hass)
@ -64,7 +63,6 @@ async def test_unload_entry(hass, generic_data, switch_msg, caplog):
entry = MockConfigEntry(
domain=DOMAIN,
title="Z-Wave",
connection_class=config_entries.CONN_CLASS_LOCAL_PUSH,
)
entry.add_to_hass(hass)
assert entry.state == config_entries.ENTRY_STATE_NOT_LOADED
@ -112,7 +110,6 @@ async def test_remove_entry(hass, stop_addon, uninstall_addon, caplog):
entry = MockConfigEntry(
domain=DOMAIN,
title="Z-Wave",
connection_class=config_entries.CONN_CLASS_LOCAL_PUSH,
data={"integration_created_addon": False},
)
entry.add_to_hass(hass)
@ -128,7 +125,6 @@ async def test_remove_entry(hass, stop_addon, uninstall_addon, caplog):
entry = MockConfigEntry(
domain=DOMAIN,
title="Z-Wave",
connection_class=config_entries.CONN_CLASS_LOCAL_PUSH,
data={"integration_created_addon": True},
)
entry.add_to_hass(hass)
@ -178,7 +174,6 @@ async def test_setup_entry_with_addon(hass, get_addon_discovery_info):
entry = MockConfigEntry(
domain=DOMAIN,
title="OpenZWave",
connection_class=config_entries.CONN_CLASS_LOCAL_PUSH,
data={"use_addon": True},
)
entry.add_to_hass(hass)
@ -205,7 +200,6 @@ async def test_setup_entry_without_addon_info(hass, get_addon_discovery_info):
entry = MockConfigEntry(
domain=DOMAIN,
title="OpenZWave",
connection_class=config_entries.CONN_CLASS_LOCAL_PUSH,
data={"use_addon": True},
)
entry.add_to_hass(hass)
@ -226,7 +220,6 @@ async def test_unload_entry_with_addon(
entry = MockConfigEntry(
domain=DOMAIN,
title="OpenZWave",
connection_class=config_entries.CONN_CLASS_LOCAL_PUSH,
data={"use_addon": True},
)
entry.add_to_hass(hass)

View file

@ -10,7 +10,6 @@ import requests
from homeassistant import config_entries
from homeassistant.components.picnic import const
from homeassistant.components.picnic.const import CONF_COUNTRY_CODE, SENSOR_TYPES
from homeassistant.config_entries import CONN_CLASS_CLOUD_POLL
from homeassistant.const import (
CONF_ACCESS_TOKEN,
CURRENCY_EURO,
@ -110,7 +109,6 @@ class TestPicnicSensor(unittest.IsolatedAsyncioTestCase):
self.config_entry = MockConfigEntry(
domain=const.DOMAIN,
data=config_data,
connection_class=CONN_CLASS_CLOUD_POLL,
unique_id="295-6y3-1nf4",
)
self.config_entry.add_to_hass(self.hass)

View file

@ -37,7 +37,7 @@ from homeassistant.components.smartthings.const import (
STORAGE_VERSION,
)
from homeassistant.config import async_process_ha_core_config
from homeassistant.config_entries import CONN_CLASS_CLOUD_PUSH, SOURCE_USER, ConfigEntry
from homeassistant.config_entries import SOURCE_USER, ConfigEntry
from homeassistant.const import (
CONF_ACCESS_TOKEN,
CONF_CLIENT_ID,
@ -61,7 +61,6 @@ async def setup_platform(hass, platform: str, *, devices=None, scenes=None):
"Test",
{CONF_INSTALLED_APP_ID: str(uuid4())},
SOURCE_USER,
CONN_CLASS_CLOUD_PUSH,
system_options={},
)
broker = DeviceBroker(
@ -231,7 +230,6 @@ def config_entry_fixture(hass, installed_app, location):
title=location.name,
version=2,
source=SOURCE_USER,
connection_class=CONN_CLASS_CLOUD_PUSH,
)

View file

@ -38,7 +38,6 @@ async def init_integration(
domain=srp_energy.SRP_ENERGY_DOMAIN,
source=source,
data=config,
connection_class=config_entries.CONN_CLASS_CLOUD_POLL,
options=options,
entry_id=entry_id,
)

View file

@ -4,7 +4,6 @@ from unittest.mock import patch
from hatasmota.discovery import get_status_sensor_entities
import pytest
from homeassistant import config_entries
from homeassistant.components.tasmota.const import (
CONF_DISCOVERY_PREFIX,
DEFAULT_PREFIX,
@ -64,7 +63,6 @@ async def setup_tasmota_helper(hass):
hass.config.components.add("tasmota")
entry = MockConfigEntry(
connection_class=config_entries.CONN_CLASS_LOCAL_PUSH,
data={CONF_DISCOVERY_PREFIX: DEFAULT_PREFIX},
domain=DOMAIN,
title="Tasmota",

View file

@ -943,7 +943,6 @@ async def test_restoring_client(hass, aioclient_mock):
title="Mock Title",
data=ENTRY_CONFIG,
source="test",
connection_class=config_entries.CONN_CLASS_LOCAL_POLL,
system_options={},
options={},
entry_id=1,

View file

@ -793,7 +793,6 @@ async def test_restore_client_succeed(hass, aioclient_mock):
title="Mock Title",
data=ENTRY_CONFIG,
source="test",
connection_class=config_entries.CONN_CLASS_LOCAL_POLL,
system_options={},
options={},
entry_id=1,
@ -885,7 +884,6 @@ async def test_restore_client_no_old_state(hass, aioclient_mock):
title="Mock Title",
data=ENTRY_CONFIG,
source="test",
connection_class=config_entries.CONN_CLASS_LOCAL_POLL,
system_options={},
options={},
entry_id=1,

View file

@ -286,7 +286,6 @@ async def setup_ozw(hass, mock_openzwave):
"Mock Title",
{"usb_path": "mock-path", "network_key": "mock-key"},
"test",
config_entries.CONN_CLASS_LOCAL_PUSH,
system_options={},
)
await hass.config_entries.async_forward_entry_setup(config_entry, "lock")

View file

@ -10,7 +10,6 @@ from homeassistant.components.hassio.handler import HassioAPIError
from homeassistant.components.zwave_js.const import DOMAIN
from homeassistant.components.zwave_js.helpers import get_device_id
from homeassistant.config_entries import (
CONN_CLASS_LOCAL_PUSH,
DISABLED_USER,
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
@ -584,7 +583,6 @@ async def test_start_addon(
entry = MockConfigEntry(
domain=DOMAIN,
title="Z-Wave JS",
connection_class=CONN_CLASS_LOCAL_PUSH,
data={"use_addon": True, "usb_path": device, "network_key": network_key},
)
entry.add_to_hass(hass)
@ -616,7 +614,6 @@ async def test_install_addon(
entry = MockConfigEntry(
domain=DOMAIN,
title="Z-Wave JS",
connection_class=CONN_CLASS_LOCAL_PUSH,
data={"use_addon": True, "usb_path": device, "network_key": network_key},
)
entry.add_to_hass(hass)
@ -650,7 +647,6 @@ async def test_addon_info_failure(
entry = MockConfigEntry(
domain=DOMAIN,
title="Z-Wave JS",
connection_class=CONN_CLASS_LOCAL_PUSH,
data={"use_addon": True, "usb_path": device, "network_key": network_key},
)
entry.add_to_hass(hass)
@ -700,7 +696,6 @@ async def test_update_addon(
entry = MockConfigEntry(
domain=DOMAIN,
title="Z-Wave JS",
connection_class=CONN_CLASS_LOCAL_PUSH,
data={
"url": "ws://host1:3001",
"use_addon": True,
@ -742,7 +737,6 @@ async def test_stop_addon(
entry = MockConfigEntry(
domain=DOMAIN,
title="Z-Wave JS",
connection_class=CONN_CLASS_LOCAL_PUSH,
data={
"url": "ws://host1:3001",
"use_addon": True,
@ -773,7 +767,6 @@ async def test_remove_entry(
entry = MockConfigEntry(
domain=DOMAIN,
title="Z-Wave JS",
connection_class=CONN_CLASS_LOCAL_PUSH,
data={"integration_created_addon": False},
)
entry.add_to_hass(hass)
@ -789,7 +782,6 @@ async def test_remove_entry(
entry = MockConfigEntry(
domain=DOMAIN,
title="Z-Wave JS",
connection_class=CONN_CLASS_LOCAL_PUSH,
data={"integration_created_addon": True},
)
entry.add_to_hass(hass)

View file

@ -26,7 +26,7 @@ def discovery_flow_conf(hass):
with patch.dict(config_entries.HANDLERS):
config_entry_flow.register_discovery_flow(
"test", "Test", has_discovered_devices, config_entries.CONN_CLASS_LOCAL_POLL
"test", "Test", has_discovered_devices
)
yield handler_conf
@ -344,3 +344,14 @@ async def test_webhook_create_cloudhook(hass, webhook_flow_conf):
assert len(mock_delete.mock_calls) == 1
assert result["require_restart"] is False
async def test_warning_deprecated_connection_class(hass, caplog):
"""Test that we log a warning when the connection_class is used."""
discovery_function = Mock()
with patch.dict(config_entries.HANDLERS):
config_entry_flow.register_discovery_flow(
"test", "Test", discovery_function, connection_class="local_polling"
)
assert "integration is setting a connection_class" in caplog.text

View file

@ -546,7 +546,6 @@ async def test_saving_and_loading(hass):
"""Test flow."""
VERSION = 5
CONNECTION_CLASS = config_entries.CONN_CLASS_LOCAL_POLL
async def async_step_user(self, user_input=None):
"""Test user step."""
@ -562,7 +561,6 @@ async def test_saving_and_loading(hass):
"""Test flow."""
VERSION = 3
CONNECTION_CLASS = config_entries.CONN_CLASS_CLOUD_PUSH
async def async_step_user(self, user_input=None):
"""Test user step."""
@ -597,7 +595,6 @@ async def test_saving_and_loading(hass):
assert orig.title == loaded.title
assert orig.data == loaded.data
assert orig.source == loaded.source
assert orig.connection_class == loaded.connection_class
assert orig.unique_id == loaded.unique_id