Refactor persistent notification to no longer route all data via a service (#57157)

* Convert persistent notification tests to async

* Create/dismiss persistent notifications in exposed functions, not service calls

* Fix notify persistent_notification

* Remove setting up persistent_notification

* Drop more setups

* Empty methods

* Undeprecate sync methods because too big task

* Fix setup clearing notifications

* Fix a bunch of tests

* Fix more tests

* Uno mas

* Test persistent notification events

* Clean up stale comment

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
Paulus Schoutsen 2021-10-07 03:58:00 -07:00 committed by GitHub
parent 750dd9186e
commit a4d9019ffc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
198 changed files with 848 additions and 1114 deletions

View file

@ -273,21 +273,17 @@ async def async_setup(hass, config):
async def persistent_notification(service: ServiceCall) -> None:
"""Send notification via the built-in persistsent_notify integration."""
payload = {}
message = service.data[ATTR_MESSAGE]
message.hass = hass
_check_templates_warn(hass, message)
payload[ATTR_MESSAGE] = message.async_render(parse_result=False)
title = service.data.get(ATTR_TITLE)
if title:
_check_templates_warn(hass, title)
title.hass = hass
payload[ATTR_TITLE] = title.async_render(parse_result=False)
title = None
if title_tpl := service.data.get(ATTR_TITLE):
_check_templates_warn(hass, title_tpl)
title_tpl.hass = hass
title = title_tpl.async_render(parse_result=False)
await hass.services.async_call(
pn.DOMAIN, pn.SERVICE_CREATE, payload, blocking=True
)
pn.async_create(hass, message.async_render(parse_result=False), title)
async def async_setup_platform(
integration_name, p_config=None, discovery_info=None

View file

@ -1,27 +1,24 @@
"""Support for displaying persistent notifications."""
from __future__ import annotations
from collections import OrderedDict
from collections.abc import Mapping, MutableMapping
from collections.abc import Mapping
import logging
from typing import Any
from typing import Any, cast
import voluptuous as vol
from homeassistant.components import websocket_api
from homeassistant.const import ATTR_FRIENDLY_NAME
from homeassistant.core import HomeAssistant, callback
from homeassistant.core import Context, HomeAssistant, ServiceCall, callback
from homeassistant.exceptions import TemplateError
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.entity import async_generate_entity_id
from homeassistant.helpers.template import Template
from homeassistant.helpers.template import Template, is_template_string
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
from homeassistant.util import slugify
import homeassistant.util.dt as dt_util
# mypy: allow-untyped-calls, allow-untyped-defs
ATTR_CREATED_AT = "created_at"
ATTR_MESSAGE = "message"
ATTR_NOTIFICATION_ID = "notification_id"
@ -34,22 +31,10 @@ ENTITY_ID_FORMAT = DOMAIN + ".{}"
EVENT_PERSISTENT_NOTIFICATIONS_UPDATED = "persistent_notifications_updated"
SERVICE_CREATE = "create"
SERVICE_DISMISS = "dismiss"
SERVICE_MARK_READ = "mark_read"
SCHEMA_SERVICE_CREATE = vol.Schema(
{
vol.Required(ATTR_MESSAGE): vol.Any(cv.dynamic_template, cv.string),
vol.Optional(ATTR_TITLE): vol.Any(cv.dynamic_template, cv.string),
vol.Optional(ATTR_NOTIFICATION_ID): cv.string,
}
SCHEMA_SERVICE_NOTIFICATION = vol.Schema(
{vol.Required(ATTR_NOTIFICATION_ID): cv.string}
)
SCHEMA_SERVICE_DISMISS = vol.Schema({vol.Required(ATTR_NOTIFICATION_ID): cv.string})
SCHEMA_SERVICE_MARK_READ = vol.Schema({vol.Required(ATTR_NOTIFICATION_ID): cv.string})
DEFAULT_OBJECT_ID = "notification"
_LOGGER = logging.getLogger(__name__)
@ -59,13 +44,18 @@ STATUS_READ = "read"
@bind_hass
def create(hass, message, title=None, notification_id=None):
def create(
hass: HomeAssistant,
message: str,
title: str | None = None,
notification_id: str | None = None,
) -> None:
"""Generate a notification."""
hass.add_job(async_create, hass, message, title, notification_id)
@bind_hass
def dismiss(hass, notification_id):
def dismiss(hass: HomeAssistant, notification_id: str) -> None:
"""Remove a notification."""
hass.add_job(async_dismiss, hass, notification_id)
@ -77,108 +67,115 @@ def async_create(
message: str,
title: str | None = None,
notification_id: str | None = None,
*,
context: Context | None = None,
) -> None:
"""Generate a notification."""
data = {
key: value
for key, value in (
(ATTR_TITLE, title),
(ATTR_MESSAGE, message),
(ATTR_NOTIFICATION_ID, notification_id),
notifications = hass.data.get(DOMAIN)
if notifications is None:
notifications = hass.data[DOMAIN] = {}
if notification_id is not None:
entity_id = ENTITY_ID_FORMAT.format(slugify(notification_id))
else:
entity_id = async_generate_entity_id(
ENTITY_ID_FORMAT, DEFAULT_OBJECT_ID, hass=hass
)
if value is not None
notification_id = entity_id.split(".")[1]
warn = False
attr: dict[str, str] = {}
if title is not None:
if is_template_string(title):
warn = True
try:
title = cast(
str, Template(title, hass).async_render(parse_result=False) # type: ignore[no-untyped-call]
)
except TemplateError as ex:
_LOGGER.error("Error rendering title %s: %s", title, ex)
attr[ATTR_TITLE] = title
attr[ATTR_FRIENDLY_NAME] = title
if is_template_string(message):
warn = True
try:
message = Template(message, hass).async_render(parse_result=False) # type: ignore[no-untyped-call]
except TemplateError as ex:
_LOGGER.error("Error rendering message %s: %s", message, ex)
attr[ATTR_MESSAGE] = message
if warn:
_LOGGER.warning(
"Passing a template string to persistent_notification.async_create function is deprecated"
)
hass.states.async_set(entity_id, STATE, attr, context=context)
# Store notification and fire event
# This will eventually replace state machine storage
notifications[entity_id] = {
ATTR_MESSAGE: message,
ATTR_NOTIFICATION_ID: notification_id,
ATTR_STATUS: STATUS_UNREAD,
ATTR_TITLE: title,
ATTR_CREATED_AT: dt_util.utcnow(),
}
hass.async_create_task(hass.services.async_call(DOMAIN, SERVICE_CREATE, data))
hass.bus.async_fire(EVENT_PERSISTENT_NOTIFICATIONS_UPDATED, context=context)
@callback
@bind_hass
def async_dismiss(hass: HomeAssistant, notification_id: str) -> None:
def async_dismiss(
hass: HomeAssistant, notification_id: str, *, context: Context | None = None
) -> None:
"""Remove a notification."""
data = {ATTR_NOTIFICATION_ID: notification_id}
notifications = hass.data.get(DOMAIN)
if notifications is None:
notifications = hass.data[DOMAIN] = {}
hass.async_create_task(hass.services.async_call(DOMAIN, SERVICE_DISMISS, data))
entity_id = ENTITY_ID_FORMAT.format(slugify(notification_id))
if entity_id not in notifications:
return
hass.states.async_remove(entity_id, context)
del notifications[entity_id]
hass.bus.async_fire(EVENT_PERSISTENT_NOTIFICATIONS_UPDATED)
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the persistent notification component."""
persistent_notifications: MutableMapping[str, MutableMapping] = OrderedDict()
hass.data[DOMAIN] = {"notifications": persistent_notifications}
notifications = hass.data.setdefault(DOMAIN, {})
@callback
def create_service(call):
def create_service(call: ServiceCall) -> None:
"""Handle a create notification service call."""
title = call.data.get(ATTR_TITLE)
message = call.data.get(ATTR_MESSAGE)
notification_id = call.data.get(ATTR_NOTIFICATION_ID)
if notification_id is not None:
entity_id = ENTITY_ID_FORMAT.format(slugify(notification_id))
else:
entity_id = async_generate_entity_id(
ENTITY_ID_FORMAT, DEFAULT_OBJECT_ID, hass=hass
)
notification_id = entity_id.split(".")[1]
attr = {}
if title is not None:
if isinstance(title, Template):
try:
title.hass = hass
title = title.async_render(parse_result=False)
except TemplateError as ex:
_LOGGER.error("Error rendering title %s: %s", title, ex)
title = title.template
attr[ATTR_TITLE] = title
attr[ATTR_FRIENDLY_NAME] = title
if isinstance(message, Template):
try:
message.hass = hass
message = message.async_render(parse_result=False)
except TemplateError as ex:
_LOGGER.error("Error rendering message %s: %s", message, ex)
message = message.template
attr[ATTR_MESSAGE] = message
hass.states.async_set(entity_id, STATE, attr)
# Store notification and fire event
# This will eventually replace state machine storage
persistent_notifications[entity_id] = {
ATTR_MESSAGE: message,
ATTR_NOTIFICATION_ID: notification_id,
ATTR_STATUS: STATUS_UNREAD,
ATTR_TITLE: title,
ATTR_CREATED_AT: dt_util.utcnow(),
}
hass.bus.async_fire(EVENT_PERSISTENT_NOTIFICATIONS_UPDATED)
async_create(
hass,
call.data[ATTR_MESSAGE],
call.data.get(ATTR_TITLE),
call.data.get(ATTR_NOTIFICATION_ID),
context=call.context,
)
@callback
def dismiss_service(call):
def dismiss_service(call: ServiceCall) -> None:
"""Handle the dismiss notification service call."""
notification_id = call.data.get(ATTR_NOTIFICATION_ID)
entity_id = ENTITY_ID_FORMAT.format(slugify(notification_id))
if entity_id not in persistent_notifications:
return
hass.states.async_remove(entity_id, call.context)
del persistent_notifications[entity_id]
hass.bus.async_fire(EVENT_PERSISTENT_NOTIFICATIONS_UPDATED)
async_dismiss(hass, call.data[ATTR_NOTIFICATION_ID], context=call.context)
@callback
def mark_read_service(call):
def mark_read_service(call: ServiceCall) -> None:
"""Handle the mark_read notification service call."""
notification_id = call.data.get(ATTR_NOTIFICATION_ID)
entity_id = ENTITY_ID_FORMAT.format(slugify(notification_id))
if entity_id not in persistent_notifications:
if entity_id not in notifications:
_LOGGER.error(
"Marking persistent_notification read failed: "
"Notification ID %s not found",
@ -186,19 +183,30 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
)
return
persistent_notifications[entity_id][ATTR_STATUS] = STATUS_READ
hass.bus.async_fire(EVENT_PERSISTENT_NOTIFICATIONS_UPDATED)
notifications[entity_id][ATTR_STATUS] = STATUS_READ
hass.bus.async_fire(
EVENT_PERSISTENT_NOTIFICATIONS_UPDATED, context=call.context
)
hass.services.async_register(
DOMAIN, SERVICE_CREATE, create_service, SCHEMA_SERVICE_CREATE
DOMAIN,
"create",
create_service,
vol.Schema(
{
vol.Required(ATTR_MESSAGE): vol.Any(cv.dynamic_template, cv.string),
vol.Optional(ATTR_TITLE): vol.Any(cv.dynamic_template, cv.string),
vol.Optional(ATTR_NOTIFICATION_ID): cv.string,
}
),
)
hass.services.async_register(
DOMAIN, SERVICE_DISMISS, dismiss_service, SCHEMA_SERVICE_DISMISS
DOMAIN, "dismiss", dismiss_service, SCHEMA_SERVICE_NOTIFICATION
)
hass.services.async_register(
DOMAIN, SERVICE_MARK_READ, mark_read_service, SCHEMA_SERVICE_MARK_READ
DOMAIN, "mark_read", mark_read_service, SCHEMA_SERVICE_NOTIFICATION
)
hass.components.websocket_api.async_register_command(websocket_get_notifications)
@ -228,7 +236,7 @@ def websocket_get_notifications(
ATTR_CREATED_AT,
)
}
for data in hass.data[DOMAIN]["notifications"].values()
for data in hass.data[DOMAIN].values()
],
)
)

View file

@ -1,7 +1,7 @@
"""Test the NEW_NAME config flow."""
from unittest.mock import patch
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.NEW_DOMAIN.config_flow import CannotConnect, InvalidAuth
from homeassistant.components.NEW_DOMAIN.const import DOMAIN
from homeassistant.core import HomeAssistant
@ -10,7 +10,6 @@ from homeassistant.data_entry_flow import RESULT_TYPE_CREATE_ENTRY, RESULT_TYPE_
async def test_form(hass: HomeAssistant) -> None:
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -3,7 +3,7 @@ from unittest.mock import patch
from pyairnow.errors import AirNowError, InvalidKeyError
from homeassistant import config_entries, data_entry_flow, setup
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.airnow.const import DOMAIN
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_RADIUS
@ -68,7 +68,7 @@ MOCK_RESPONSE = [
async def test_form(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -3,7 +3,7 @@ from unittest.mock import patch
import airthings
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.airthings.const import CONF_ID, CONF_SECRET, DOMAIN
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import RESULT_TYPE_CREATE_ENTRY, RESULT_TYPE_FORM
@ -18,7 +18,7 @@ TEST_DATA = {
async def test_form(hass: HomeAssistant) -> None:
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -3,7 +3,7 @@ from unittest.mock import patch
from yalexs.authenticator import ValidationResult
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.august.const import (
CONF_ACCESS_TOKEN_CACHE_FILE,
CONF_INSTALL_ID,
@ -23,7 +23,7 @@ from tests.common import MockConfigEntry
async def test_form(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -6,7 +6,6 @@ from aiohttp import ClientResponseError
from yalexs.authenticator_common import AuthenticationState
from yalexs.exceptions import AugustApiAIOHTTPError
from homeassistant import setup
from homeassistant.components.august.const import DOMAIN
from homeassistant.components.lock import DOMAIN as LOCK_DOMAIN
from homeassistant.config_entries import ConfigEntryState
@ -41,7 +40,6 @@ async def test_august_is_offline(hass):
)
config_entry.add_to_hass(hass)
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"yalexs.authenticator_async.AuthenticatorAsync.async_authenticate",
side_effect=asyncio.TimeoutError,
@ -147,7 +145,6 @@ async def test_auth_fails(hass):
config_entry.add_to_hass(hass)
assert hass.config_entries.flow.async_progress() == []
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"yalexs.authenticator_async.AuthenticatorAsync.async_authenticate",
side_effect=ClientResponseError(None, None, status=401),
@ -173,7 +170,6 @@ async def test_bad_password(hass):
config_entry.add_to_hass(hass)
assert hass.config_entries.flow.async_progress() == []
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"yalexs.authenticator_async.AuthenticatorAsync.async_authenticate",
return_value=_mock_august_authentication(
@ -201,7 +197,6 @@ async def test_http_failure(hass):
config_entry.add_to_hass(hass)
assert hass.config_entries.flow.async_progress() == []
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"yalexs.authenticator_async.AuthenticatorAsync.async_authenticate",
side_effect=ClientResponseError(None, None, status=500),
@ -225,7 +220,6 @@ async def test_unknown_auth_state(hass):
config_entry.add_to_hass(hass)
assert hass.config_entries.flow.async_progress() == []
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"yalexs.authenticator_async.AuthenticatorAsync.async_authenticate",
return_value=_mock_august_authentication("original_token", 1234, None),
@ -251,7 +245,6 @@ async def test_requires_validation_state(hass):
config_entry.add_to_hass(hass)
assert hass.config_entries.flow.async_progress() == []
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"yalexs.authenticator_async.AuthenticatorAsync.async_authenticate",
return_value=_mock_august_authentication(
@ -278,7 +271,6 @@ async def test_unknown_auth_http_401(hass):
config_entry.add_to_hass(hass)
assert hass.config_entries.flow.async_progress() == []
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"yalexs.authenticator_async.AuthenticatorAsync.async_authenticate",
return_value=_mock_august_authentication("original_token", 1234, None),

View file

@ -4,7 +4,7 @@ from unittest.mock import patch
from aiohttp import ClientError
from homeassistant import config_entries, data_entry_flow, setup
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.aurora.const import DOMAIN
from tests.common import MockConfigEntry
@ -18,7 +18,7 @@ DATA = {
async def test_form(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -47,7 +47,6 @@ async def test_form(hass):
async def test_form_cannot_connect(hass):
"""Test if invalid response or no connection returned from the API."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -68,7 +67,7 @@ async def test_form_cannot_connect(hass):
async def test_with_unknown_error(hass):
"""Test with unknown error response from the API."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -4,7 +4,7 @@ from unittest.mock import Mock, patch
from blinkpy.auth import LoginError
from blinkpy.blinkpy import BlinkSetupError
from homeassistant import config_entries, data_entry_flow, setup
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.blink import DOMAIN
from tests.common import MockConfigEntry
@ -12,7 +12,7 @@ from tests.common import MockConfigEntry
async def test_form(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -50,7 +50,7 @@ async def test_form(hass):
async def test_form_2fa(hass):
"""Test we get the 2fa form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -92,7 +92,7 @@ async def test_form_2fa(hass):
async def test_form_2fa_connect_error(hass):
"""Test we report a connect error during 2fa setup."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -131,7 +131,7 @@ async def test_form_2fa_connect_error(hass):
async def test_form_2fa_invalid_key(hass):
"""Test we report an error if key is invalid."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -170,7 +170,7 @@ async def test_form_2fa_invalid_key(hass):
async def test_form_2fa_unknown_error(hass):
"""Test we report an unknown error during 2fa setup."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -6,7 +6,7 @@ from unittest.mock import Mock, patch
from aiohttp import ClientConnectionError, ClientResponseError
from homeassistant import config_entries, core, setup
from homeassistant import config_entries, core
from homeassistant.components.bond.const import DOMAIN
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_HOST
@ -24,7 +24,7 @@ from tests.common import MockConfigEntry
async def test_user_form(hass: core.HomeAssistant):
"""Test we get the user initiated form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -53,7 +53,7 @@ async def test_user_form(hass: core.HomeAssistant):
async def test_user_form_with_non_bridge(hass: core.HomeAssistant):
"""Test setup a smart by bond fan."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -170,8 +170,6 @@ async def test_user_form_one_entry_per_device_allowed(hass: core.HomeAssistant):
data={CONF_HOST: "some host", CONF_ACCESS_TOKEN: "test-token"},
).add_to_hass(hass)
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -193,7 +191,7 @@ async def test_user_form_one_entry_per_device_allowed(hass: core.HomeAssistant):
async def test_zeroconf_form(hass: core.HomeAssistant):
"""Test we get the discovery form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_ZEROCONF},
@ -222,7 +220,7 @@ async def test_zeroconf_form(hass: core.HomeAssistant):
async def test_zeroconf_form_token_unavailable(hass: core.HomeAssistant):
"""Test we get the discovery form and we handle the token being unavailable."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch_bond_version(), patch_bond_token():
result = await hass.config_entries.flow.async_init(
DOMAIN,
@ -251,7 +249,7 @@ async def test_zeroconf_form_token_unavailable(hass: core.HomeAssistant):
async def test_zeroconf_form_with_token_available(hass: core.HomeAssistant):
"""Test we get the discovery form when we can get the token."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch_bond_version(return_value={"bondid": "test-bond-id"}), patch_bond_token(
return_value={"token": "discovered-token"}
), patch_bond_bridge(
@ -284,7 +282,6 @@ async def test_zeroconf_form_with_token_available(hass: core.HomeAssistant):
async def test_zeroconf_already_configured(hass: core.HomeAssistant):
"""Test starting a flow from discovery when already configured."""
await setup.async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN,

View file

@ -9,7 +9,7 @@ from boschshcpy.exceptions import (
)
from boschshcpy.information import SHCInformation
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.bosch_shc.config_flow import write_tls_asset
from homeassistant.components.bosch_shc.const import CONF_SHC_CERT, CONF_SHC_KEY, DOMAIN
@ -30,7 +30,7 @@ DISCOVERY_INFO = {
async def test_form_user(hass, mock_zeroconf):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -376,7 +376,7 @@ async def test_form_validate_exception(hass, mock_zeroconf):
async def test_form_already_configured(hass, mock_zeroconf):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain="bosch_shc", unique_id="test-mac", data={"host": "0.0.0.0"}
)
@ -412,7 +412,6 @@ async def test_form_already_configured(hass, mock_zeroconf):
async def test_zeroconf(hass, mock_zeroconf):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"boschshcpy.session.SHCSession.mdns_info",
@ -481,7 +480,7 @@ async def test_zeroconf(hass, mock_zeroconf):
async def test_zeroconf_already_configured(hass, mock_zeroconf):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain="bosch_shc", unique_id="test-mac", data={"host": "0.0.0.0"}
)
@ -561,7 +560,7 @@ async def test_zeroconf_not_bosch_shc(hass, mock_zeroconf):
async def test_reauth(hass, mock_zeroconf):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
mock_config = MockConfigEntry(
domain=DOMAIN,
unique_id="test-mac",

View file

@ -6,7 +6,7 @@ from unittest.mock import call, patch
import broadlink.exceptions as blke
import pytest
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.broadlink.const import DOMAIN
from homeassistant.components.dhcp import HOSTNAME, IP_ADDRESS, MAC_ADDRESS
from homeassistant.helpers import device_registry
@ -825,7 +825,6 @@ async def test_flow_reauth_valid_host(hass):
async def test_dhcp_can_finish(hass):
"""Test DHCP discovery flow can finish right away."""
await setup.async_setup_component(hass, "persistent_notification", {})
device = get_device("Living Room")
device.host = "1.2.3.4"
@ -864,7 +863,7 @@ async def test_dhcp_can_finish(hass):
async def test_dhcp_fails_to_connect(hass):
"""Test DHCP discovery flow that fails to connect."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(DEVICE_HELLO, side_effect=blke.NetworkTimeoutError()):
result = await hass.config_entries.flow.async_init(
DOMAIN,
@ -883,7 +882,7 @@ async def test_dhcp_fails_to_connect(hass):
async def test_dhcp_unreachable(hass):
"""Test DHCP discovery flow that fails to connect."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(DEVICE_HELLO, side_effect=OSError(errno.ENETUNREACH, None)):
result = await hass.config_entries.flow.async_init(
DOMAIN,
@ -902,7 +901,7 @@ async def test_dhcp_unreachable(hass):
async def test_dhcp_connect_unknown_error(hass):
"""Test DHCP discovery flow that fails to connect with an OSError."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(DEVICE_HELLO, side_effect=OSError()):
result = await hass.config_entries.flow.async_init(
DOMAIN,
@ -921,7 +920,7 @@ async def test_dhcp_connect_unknown_error(hass):
async def test_dhcp_device_not_supported(hass):
"""Test DHCP discovery flow that fails because the device is not supported."""
await setup.async_setup_component(hass, "persistent_notification", {})
device = get_device("Kitchen")
mock_api = device.get_mock_api()
@ -942,7 +941,7 @@ async def test_dhcp_device_not_supported(hass):
async def test_dhcp_already_exists(hass):
"""Test DHCP discovery flow that fails to connect."""
await setup.async_setup_component(hass, "persistent_notification", {})
device = get_device("Living Room")
mock_entry = device.get_mock_entry()
mock_entry.add_to_hass(hass)
@ -967,7 +966,6 @@ async def test_dhcp_already_exists(hass):
async def test_dhcp_updates_host(hass):
"""Test DHCP updates host."""
await setup.async_setup_component(hass, "persistent_notification", {})
device = get_device("Living Room")
device.host = "1.2.3.4"

View file

@ -25,7 +25,6 @@ from tests.common import mock_registry
async def test_alarm_control_panel(hass, canary) -> None:
"""Test the creation and values of the alarm_control_panel for Canary."""
await async_setup_component(hass, "persistent_notification", {})
registry = mock_registry(hass)
online_device_at_home = mock_device(20, "Dining Room", True, "Canary Pro")
@ -109,7 +108,6 @@ async def test_alarm_control_panel(hass, canary) -> None:
async def test_alarm_control_panel_services(hass, canary) -> None:
"""Test the services of the alarm_control_panel for Canary."""
await async_setup_component(hass, "persistent_notification", {})
online_device_at_home = mock_device(20, "Dining Room", True, "Canary Pro")

View file

@ -16,14 +16,12 @@ from homeassistant.data_entry_flow import (
RESULT_TYPE_CREATE_ENTRY,
RESULT_TYPE_FORM,
)
from homeassistant.setup import async_setup_component
from . import USER_INPUT, _patch_async_setup, _patch_async_setup_entry, init_integration
async def test_user_form(hass, canary_config_flow):
"""Test we get the user initiated form."""
await async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}

View file

@ -29,7 +29,6 @@ from tests.common import async_fire_time_changed, mock_device_registry, mock_reg
async def test_sensors_pro(hass, canary) -> None:
"""Test the creation and values of the sensors for Canary Pro."""
await async_setup_component(hass, "persistent_notification", {})
registry = mock_registry(hass)
device_registry = mock_device_registry(hass)
@ -97,7 +96,6 @@ async def test_sensors_pro(hass, canary) -> None:
async def test_sensors_attributes_pro(hass, canary) -> None:
"""Test the creation and values of the sensors attributes for Canary Pro."""
await async_setup_component(hass, "persistent_notification", {})
online_device_at_home = mock_device(20, "Dining Room", True, "Canary Pro")
@ -158,7 +156,6 @@ async def test_sensors_attributes_pro(hass, canary) -> None:
async def test_sensors_flex(hass, canary) -> None:
"""Test the creation and values of the sensors for Canary Flex."""
await async_setup_component(hass, "persistent_notification", {})
registry = mock_registry(hass)
device_registry = mock_device_registry(hass)

View file

@ -13,7 +13,6 @@ from homeassistant.data_entry_flow import (
RESULT_TYPE_CREATE_ENTRY,
RESULT_TYPE_FORM,
)
from homeassistant.setup import async_setup_component
from . import (
ENTRY_CONFIG,
@ -28,7 +27,6 @@ from tests.common import MockConfigEntry
async def test_user_form(hass, cfupdate_flow):
"""Test we get the user initiated form."""
await async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={CONF_SOURCE: SOURCE_USER}

View file

@ -3,7 +3,7 @@ from unittest.mock import patch
import pytest
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.co2signal import DOMAIN, config_flow
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import RESULT_TYPE_CREATE_ENTRY, RESULT_TYPE_FORM
@ -16,7 +16,7 @@ from tests.common import MockConfigEntry
async def test_form_home(hass: HomeAssistant) -> None:
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -46,7 +46,7 @@ async def test_form_home(hass: HomeAssistant) -> None:
async def test_form_coordinates(hass: HomeAssistant) -> None:
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -87,7 +87,7 @@ async def test_form_coordinates(hass: HomeAssistant) -> None:
async def test_form_country(hass: HomeAssistant) -> None:
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -200,7 +200,6 @@ async def test_form_error_unexpected_data(hass: HomeAssistant) -> None:
async def test_import(hass: HomeAssistant) -> None:
"""Test we import correctly."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"CO2Signal.get_latest",
@ -230,7 +229,7 @@ async def test_import(hass: HomeAssistant) -> None:
async def test_import_abort_existing_home(hass: HomeAssistant) -> None:
"""Test we abort if home entry found."""
await setup.async_setup_component(hass, "persistent_notification", {})
MockConfigEntry(domain="co2signal", data={"api_key": "abcd"}).add_to_hass(hass)
with patch(
@ -247,7 +246,7 @@ async def test_import_abort_existing_home(hass: HomeAssistant) -> None:
async def test_import_abort_existing_country(hass: HomeAssistant) -> None:
"""Test we abort if existing country found."""
await setup.async_setup_component(hass, "persistent_notification", {})
MockConfigEntry(
domain="co2signal", data={"api_key": "abcd", "country_code": "nl"}
).add_to_hass(hass)
@ -274,7 +273,7 @@ async def test_import_abort_existing_country(hass: HomeAssistant) -> None:
async def test_import_abort_existing_coordinates(hass: HomeAssistant) -> None:
"""Test we abort if existing coordinates found."""
await setup.async_setup_component(hass, "persistent_notification", {})
MockConfigEntry(
domain="co2signal", data={"api_key": "abcd", "latitude": 1, "longitude": 2}
).add_to_hass(hass)

View file

@ -4,7 +4,7 @@ from unittest.mock import patch
from coinbase.wallet.error import AuthenticationError
from requests.models import Response
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.coinbase.const import (
CONF_CURRENCIES,
CONF_EXCHANGE_RATES,
@ -26,7 +26,7 @@ from tests.common import MockConfigEntry
async def test_form(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -6,7 +6,7 @@ from pyControl4.account import C4Account
from pyControl4.director import C4Director
from pyControl4.error_handling import Unauthorized
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.control4.const import DEFAULT_SCAN_INTERVAL, DOMAIN
from homeassistant.const import (
CONF_HOST,
@ -46,7 +46,7 @@ def _get_mock_c4_director(getAllItemInfo={}):
async def test_form(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -3,14 +3,14 @@ from unittest.mock import MagicMock, patch
from aiohttp import ClientError
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.coronavirus.const import DOMAIN, OPTION_WORLDWIDE
from homeassistant.core import HomeAssistant
async def test_form(hass: HomeAssistant) -> None:
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -39,7 +39,7 @@ async def test_abort_on_connection_error(
mock_get_cases: MagicMock, hass: HomeAssistant
) -> None:
"""Test we abort on connection error."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -169,7 +169,6 @@ async def test_functional_device_trigger(
hass, aioclient_mock, mock_deconz_websocket, automation_calls
):
"""Test proper matching and attachment of device trigger automation."""
await async_setup_component(hass, "persistent_notification", {})
data = {
"sensors": {

View file

@ -3,7 +3,7 @@ from unittest.mock import patch
import pytest
from homeassistant import config_entries, data_entry_flow, setup
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.devolo_home_control.const import DEFAULT_MYDEVOLO, DOMAIN
from .const import (
@ -17,7 +17,7 @@ from tests.common import MockConfigEntry
async def test_form(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -31,7 +31,7 @@ async def test_form(hass):
@pytest.mark.credentials_invalid
async def test_form_invalid_credentials_user(hass):
"""Test if we get the error message on invalid credentials."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -117,7 +117,7 @@ async def test_form_zeroconf(hass):
@pytest.mark.credentials_invalid
async def test_form_invalid_credentials_zeroconf(hass):
"""Test if we get the error message on invalid credentials."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_ZEROCONF},

View file

@ -3,7 +3,7 @@ from unittest.mock import patch
from pydexcom import AccountError, SessionError
from homeassistant import config_entries, data_entry_flow, setup
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.dexcom.const import DOMAIN, MG_DL, MMOL_L
from homeassistant.const import CONF_UNIT_OF_MEASUREMENT, CONF_USERNAME
@ -13,7 +13,7 @@ from tests.components.dexcom import CONFIG
async def test_form(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -4,7 +4,7 @@ from unittest.mock import MagicMock, Mock, patch
import pytest
import requests
from homeassistant import config_entries, data_entry_flow, setup
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.doorbird.const import CONF_EVENTS, DOMAIN
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_USERNAME
@ -38,7 +38,7 @@ def _get_mock_doorbirdapi_side_effects(ready=None, info=None):
async def test_user_form(hass):
"""Test we get the user form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -77,7 +77,6 @@ async def test_user_form(hass):
async def test_form_zeroconf_wrong_oui(hass):
"""Test we abort when we get the wrong OUI via zeroconf."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN,
@ -94,7 +93,6 @@ async def test_form_zeroconf_wrong_oui(hass):
async def test_form_zeroconf_link_local_ignored(hass):
"""Test we abort when we get a link local address via zeroconf."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN,
@ -114,7 +112,6 @@ async def test_form_zeroconf_correct_oui(hass):
doorbirdapi = _get_mock_doorbirdapi_return_values(
ready=[True], info={"WIFI_MAC_ADDR": "macaddr"}
)
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"homeassistant.components.doorbird.config_flow.DoorBird",
@ -174,7 +171,6 @@ async def test_form_zeroconf_correct_oui_wrong_device(hass, doorbell_state_side_
ready=[True], info={"WIFI_MAC_ADDR": "macaddr"}
)
type(doorbirdapi).doorbell_state = MagicMock(side_effect=doorbell_state_side_effect)
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"homeassistant.components.doorbird.config_flow.DoorBird",

View file

@ -7,7 +7,7 @@ from unittest.mock import DEFAULT, AsyncMock, MagicMock, patch, sentinel
import serial
import serial.tools.list_ports
from homeassistant import config_entries, data_entry_flow, setup
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.dsmr import DOMAIN, config_flow
from tests.common import MockConfigEntry
@ -150,8 +150,6 @@ async def test_setup_serial_fail(com_mock, hass, dsmr_connection_send_validate_f
"""Test failed serial connection."""
(connection_factory, transport, protocol) = dsmr_connection_send_validate_fixture
await setup.async_setup_component(hass, "persistent_notification", {})
port = com_port()
result = await hass.config_entries.flow.async_init(
@ -197,8 +195,6 @@ async def test_setup_serial_wrong_telegram(
"""Test failed telegram data."""
(connection_factory, transport, protocol) = dsmr_connection_send_validate_fixture
await setup.async_setup_component(hass, "persistent_notification", {})
port = com_port()
result = await hass.config_entries.flow.async_init(
@ -231,7 +227,6 @@ async def test_setup_serial_wrong_telegram(
async def test_import_usb(hass, dsmr_connection_send_validate_fixture):
"""Test we can import."""
await setup.async_setup_component(hass, "persistent_notification", {})
entry_data = {
"port": "/dev/ttyUSB0",
@ -258,8 +253,6 @@ async def test_import_usb_failed_connection(
"""Test we can import."""
(connection_factory, transport, protocol) = dsmr_connection_send_validate_fixture
await setup.async_setup_component(hass, "persistent_notification", {})
entry_data = {
"port": "/dev/ttyUSB0",
"dsmr_version": "2.2",
@ -293,8 +286,6 @@ async def test_import_usb_no_data(hass, dsmr_connection_send_validate_fixture):
"""Test we can import."""
(connection_factory, transport, protocol) = dsmr_connection_send_validate_fixture
await setup.async_setup_component(hass, "persistent_notification", {})
entry_data = {
"port": "/dev/ttyUSB0",
"dsmr_version": "2.2",
@ -325,8 +316,6 @@ async def test_import_usb_wrong_telegram(hass, dsmr_connection_send_validate_fix
"""Test we can import."""
(connection_factory, transport, protocol) = dsmr_connection_send_validate_fixture
await setup.async_setup_component(hass, "persistent_notification", {})
entry_data = {
"port": "/dev/ttyUSB0",
"dsmr_version": "2.2",
@ -349,7 +338,6 @@ async def test_import_usb_wrong_telegram(hass, dsmr_connection_send_validate_fix
async def test_import_network(hass, dsmr_connection_send_validate_fixture):
"""Test we can import from network."""
await setup.async_setup_component(hass, "persistent_notification", {})
entry_data = {
"host": "localhost",
@ -373,7 +361,6 @@ async def test_import_network(hass, dsmr_connection_send_validate_fixture):
async def test_import_update(hass, dsmr_connection_send_validate_fixture):
"""Test we can import."""
await setup.async_setup_component(hass, "persistent_notification", {})
entry_data = {
"port": "/dev/ttyUSB0",
@ -422,7 +409,6 @@ async def test_import_update(hass, dsmr_connection_send_validate_fixture):
async def test_options_flow(hass):
"""Test options flow."""
await setup.async_setup_component(hass, "persistent_notification", {})
entry_data = {
"port": "/dev/ttyUSB0",
@ -462,7 +448,6 @@ async def test_options_flow(hass):
async def test_import_luxembourg(hass, dsmr_connection_send_validate_fixture):
"""Test we can import."""
await setup.async_setup_component(hass, "persistent_notification", {})
entry_data = {
"port": "/dev/ttyUSB0",
@ -485,7 +470,6 @@ async def test_import_luxembourg(hass, dsmr_connection_send_validate_fixture):
async def test_import_sweden(hass, dsmr_connection_send_validate_fixture):
"""Test we can import."""
await setup.async_setup_component(hass, "persistent_notification", {})
entry_data = {
"port": "/dev/ttyUSB0",

View file

@ -2,7 +2,7 @@
from unittest.mock import MagicMock, patch
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.elkm1.const import DOMAIN
@ -25,7 +25,7 @@ def mock_elk(invalid_auth=None, sync_complete=None):
async def test_form_user_with_secure_elk(hass):
"""Test we can setup a secure elk."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -72,7 +72,7 @@ async def test_form_user_with_secure_elk(hass):
async def test_form_user_with_tls_elk(hass):
"""Test we can setup a secure elk."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -119,7 +119,7 @@ async def test_form_user_with_tls_elk(hass):
async def test_form_user_with_non_secure_elk(hass):
"""Test we can setup a non-secure elk."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -164,7 +164,7 @@ async def test_form_user_with_non_secure_elk(hass):
async def test_form_user_with_serial_elk(hass):
"""Test we can setup a serial elk."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -268,7 +268,6 @@ async def test_form_invalid_auth(hass):
async def test_form_import(hass):
"""Test we get the form with import source."""
await setup.async_setup_component(hass, "persistent_notification", {})
mocked_elk = mock_elk(invalid_auth=False, sync_complete=True)
with patch(

View file

@ -4,7 +4,7 @@ from unittest.mock import MagicMock, patch
from aioemonitor.monitor import EmonitorNetwork, EmonitorStatus
import aiohttp
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.dhcp import HOSTNAME, IP_ADDRESS, MAC_ADDRESS
from homeassistant.components.emonitor.const import DOMAIN
from homeassistant.const import CONF_HOST
@ -20,7 +20,7 @@ def _mock_emonitor():
async def test_form(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -94,7 +94,6 @@ async def test_form_cannot_connect(hass):
async def test_dhcp_can_confirm(hass):
"""Test DHCP discovery flow can confirm right away."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"homeassistant.components.emonitor.config_flow.Emonitor.async_get_status",
@ -138,7 +137,6 @@ async def test_dhcp_can_confirm(hass):
async def test_dhcp_fails_to_connect(hass):
"""Test DHCP discovery flow that fails to connect."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"homeassistant.components.emonitor.config_flow.Emonitor.async_get_status",
@ -161,7 +159,7 @@ async def test_dhcp_fails_to_connect(hass):
async def test_dhcp_already_exists(hass):
"""Test DHCP discovery flow that fails to connect."""
await setup.async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN,
data={CONF_HOST: "1.2.3.4"},
@ -190,7 +188,7 @@ async def test_dhcp_already_exists(hass):
async def test_user_unique_id_already_exists(hass):
"""Test creating an entry where the unique_id already exists."""
await setup.async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN,
data={CONF_HOST: "1.2.3.4"},

View file

@ -3,7 +3,7 @@ from unittest.mock import MagicMock, patch
import httpx
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.enphase_envoy.const import DOMAIN
from homeassistant.core import HomeAssistant
@ -12,7 +12,7 @@ from tests.common import MockConfigEntry
async def test_form(hass: HomeAssistant) -> None:
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -120,7 +120,7 @@ async def test_form_unknown_error(hass: HomeAssistant) -> None:
async def test_import(hass: HomeAssistant) -> None:
"""Test we can import from yaml."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"homeassistant.components.enphase_envoy.config_flow.EnvoyReader.getData",
return_value=True,
@ -153,7 +153,7 @@ async def test_import(hass: HomeAssistant) -> None:
async def test_zeroconf(hass: HomeAssistant) -> None:
"""Test we can setup from zeroconf."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_ZEROCONF},
@ -198,7 +198,6 @@ async def test_zeroconf(hass: HomeAssistant) -> None:
async def test_form_host_already_exists(hass: HomeAssistant) -> None:
"""Test host already exists."""
await setup.async_setup_component(hass, "persistent_notification", {})
config_entry = MockConfigEntry(
domain=DOMAIN,
@ -237,7 +236,7 @@ async def test_form_host_already_exists(hass: HomeAssistant) -> None:
async def test_zeroconf_serial_already_exists(hass: HomeAssistant) -> None:
"""Test serial number already exists from zeroconf."""
await setup.async_setup_component(hass, "persistent_notification", {})
config_entry = MockConfigEntry(
domain=DOMAIN,
data={
@ -266,7 +265,7 @@ async def test_zeroconf_serial_already_exists(hass: HomeAssistant) -> None:
async def test_zeroconf_host_already_exists(hass: HomeAssistant) -> None:
"""Test hosts already exists from zeroconf."""
await setup.async_setup_component(hass, "persistent_notification", {})
config_entry = MockConfigEntry(
domain=DOMAIN,
data={
@ -306,7 +305,7 @@ async def test_zeroconf_host_already_exists(hass: HomeAssistant) -> None:
async def test_reauth(hass: HomeAssistant) -> None:
"""Test we reauth auth."""
await setup.async_setup_component(hass, "persistent_notification", {})
config_entry = MockConfigEntry(
domain=DOMAIN,
data={

View file

@ -3,14 +3,14 @@ from unittest.mock import patch
from epson_projector.const import PWR_OFF_STATE
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.epson.const import DOMAIN
from homeassistant.const import CONF_HOST, CONF_NAME, STATE_UNAVAILABLE
async def test_form(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch("homeassistant.components.epson.Projector.get_power", return_value="01"):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}

View file

@ -34,7 +34,6 @@ from homeassistant.data_entry_flow import (
RESULT_TYPE_CREATE_ENTRY,
RESULT_TYPE_FORM,
)
from homeassistant.setup import async_setup_component
from . import (
DISCOVERY_INFO,
@ -52,7 +51,6 @@ from . import (
async def test_user_form(hass, ezviz_config_flow):
"""Test the user initiated form."""
await async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
@ -115,7 +113,6 @@ async def test_user_custom_url(hass, ezviz_config_flow):
async def test_async_step_import(hass, ezviz_config_flow):
"""Test the config import flow."""
await async_setup_component(hass, "persistent_notification", {})
with _patch_async_setup_entry() as mock_setup_entry:
result = await hass.config_entries.flow.async_init(
@ -129,7 +126,6 @@ async def test_async_step_import(hass, ezviz_config_flow):
async def test_async_step_import_camera(hass, ezviz_config_flow):
"""Test the config import camera flow."""
await async_setup_component(hass, "persistent_notification", {})
with _patch_async_setup_entry() as mock_setup_entry:
result = await hass.config_entries.flow.async_init(
@ -143,7 +139,6 @@ async def test_async_step_import_camera(hass, ezviz_config_flow):
async def test_async_step_import_2nd_form_returns_camera(hass, ezviz_config_flow):
"""Test we get the user initiated form."""
await async_setup_component(hass, "persistent_notification", {})
with _patch_async_setup_entry() as mock_setup_entry:
result = await hass.config_entries.flow.async_init(
@ -168,7 +163,6 @@ async def test_async_step_import_2nd_form_returns_camera(hass, ezviz_config_flow
async def test_async_step_import_abort(hass, ezviz_config_flow):
"""Test the config import flow with invalid data."""
await async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_IMPORT}, data=YAML_INVALID
@ -179,7 +173,6 @@ async def test_async_step_import_abort(hass, ezviz_config_flow):
async def test_step_discovery_abort_if_cloud_account_missing(hass):
"""Test discovery and confirm step, abort if cloud account was removed."""
await async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_DISCOVERY}, data=DISCOVERY_INFO
@ -207,7 +200,6 @@ async def test_async_step_discovery(
"""Test discovery and confirm step."""
with patch("homeassistant.components.ezviz.PLATFORMS", []):
await init_integration(hass)
await async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_DISCOVERY}, data=DISCOVERY_INFO
@ -359,8 +351,6 @@ async def test_discover_exception_step1(
with patch("homeassistant.components.ezviz.PLATFORMS", []):
await init_integration(hass)
await async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_DISCOVERY},
@ -435,7 +425,6 @@ async def test_discover_exception_step3(
"""Test we handle unexpected exception on discovery."""
with patch("homeassistant.components.ezviz.PLATFORMS", []):
await init_integration(hass)
await async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN,

View file

@ -4,7 +4,7 @@ from unittest.mock import patch
from aiohttp import ClientConnectionError
import faadelays
from homeassistant import config_entries, data_entry_flow, setup
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.faa_delays.const import DOMAIN
from homeassistant.const import CONF_ID
from homeassistant.exceptions import HomeAssistantError
@ -19,7 +19,7 @@ async def mock_valid_airport(self, *args, **kwargs):
async def test_form(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -33,7 +33,7 @@ async def test_invalid_path(hass):
config = {"sensor": {"platform": "filesize", CONF_FILE_PATHS: ["invalid_path"]}}
assert await async_setup_component(hass, "sensor", config)
await hass.async_block_till_done()
assert len(hass.states.async_entity_ids()) == 0
assert len(hass.states.async_entity_ids("sensor")) == 0
async def test_valid_path(hass):
@ -43,7 +43,7 @@ async def test_valid_path(hass):
hass.config.allowlist_external_dirs = {TEST_DIR}
assert await async_setup_component(hass, "sensor", config)
await hass.async_block_till_done()
assert len(hass.states.async_entity_ids()) == 1
assert len(hass.states.async_entity_ids("sensor")) == 1
state = hass.states.get("sensor.mock_file_test_filesize_txt")
assert state.state == "0.0"
assert state.attributes.get("bytes") == 4

View file

@ -3,7 +3,7 @@ from unittest.mock import patch
from pymata_express.pymata_express_serial import serial
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.firmata.const import CONF_SERIAL_PORT, DOMAIN
from homeassistant.const import CONF_NAME
from homeassistant.core import HomeAssistant
@ -11,7 +11,6 @@ from homeassistant.core import HomeAssistant
async def test_import_cannot_connect_pymata(hass: HomeAssistant) -> None:
"""Test we fail with an invalid board."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"homeassistant.components.firmata.board.PymataExpress.start_aio",
@ -29,7 +28,6 @@ async def test_import_cannot_connect_pymata(hass: HomeAssistant) -> None:
async def test_import_cannot_connect_serial(hass: HomeAssistant) -> None:
"""Test we fail with an invalid board."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"homeassistant.components.firmata.board.PymataExpress.start_aio",
@ -47,7 +45,6 @@ async def test_import_cannot_connect_serial(hass: HomeAssistant) -> None:
async def test_import_cannot_connect_serial_timeout(hass: HomeAssistant) -> None:
"""Test we fail with an invalid board."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"homeassistant.components.firmata.board.PymataExpress.start_aio",
@ -65,7 +62,6 @@ async def test_import_cannot_connect_serial_timeout(hass: HomeAssistant) -> None
async def test_import(hass: HomeAssistant) -> None:
"""Test we create an entry from config."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"homeassistant.components.firmata.board.PymataExpress", autospec=True

View file

@ -6,7 +6,7 @@ from unittest.mock import patch
from bleak.backends.device import BLEDevice
from pytest import fixture
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.fjaraskupan.const import DOMAIN
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import (
@ -19,7 +19,6 @@ from homeassistant.data_entry_flow import (
@fixture(name="mock_setup_entry", autouse=True)
async def fixture_mock_setup_entry(hass):
"""Fixture for config entry."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"homeassistant.components.fjaraskupan.async_setup_entry", return_value=True

View file

@ -4,7 +4,7 @@ from unittest.mock import patch
from pyflick.authentication import AuthException
from homeassistant import config_entries, data_entry_flow, setup
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.flick_electric.const import DOMAIN
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
@ -23,7 +23,7 @@ async def _flow_submit(hass):
async def test_form(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -4,7 +4,7 @@ from unittest.mock import patch
import pytest
from requests.exceptions import HTTPError, Timeout
from homeassistant import config_entries, data_entry_flow, setup
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.flipr.const import CONF_FLIPR_ID, DOMAIN
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
@ -21,7 +21,7 @@ def mock_setups():
async def test_show_form(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -3,7 +3,7 @@ import json
import time
from unittest.mock import patch
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.flo.const import DOMAIN
from homeassistant.const import CONTENT_TYPE_JSON
@ -12,7 +12,7 @@ from .common import TEST_EMAIL_ADDRESS, TEST_PASSWORD, TEST_TOKEN, TEST_USER_ID
async def test_form(hass, aioclient_mock_fixture):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -3,7 +3,7 @@ from unittest.mock import MagicMock, patch
import requests.exceptions
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.flume.const import DOMAIN
from homeassistant.const import (
CONF_CLIENT_ID,
@ -23,7 +23,7 @@ def _get_mocked_flume_device_list():
async def test_form(hass):
"""Test we get the form and can setup from user input."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -66,7 +66,7 @@ async def test_form(hass):
async def test_form_import(hass):
"""Test we can import the sensor platform config."""
await setup.async_setup_component(hass, "persistent_notification", {})
mock_flume_device_list = _get_mocked_flume_device_list()
with patch(

View file

@ -5,7 +5,7 @@ from unittest.mock import patch
import pytest
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.flux_led.const import (
CONF_CUSTOM_EFFECT_COLORS,
CONF_CUSTOM_EFFECT_SPEED_PCT,
@ -317,7 +317,6 @@ async def test_manual_no_discovery_data(hass: HomeAssistant):
async def test_discovered_by_discovery_and_dhcp(hass):
"""Test we get the form with discovery and abort for dhcp source when we get both."""
await setup.async_setup_component(hass, "persistent_notification", {})
with _patch_discovery(), _patch_wifibulb():
result = await hass.config_entries.flow.async_init(
@ -364,8 +363,6 @@ async def test_discovered_by_discovery_and_dhcp(hass):
async def test_discovered_by_dhcp_or_discovery(hass, source, data):
"""Test we can setup when discovered from dhcp or discovery."""
await setup.async_setup_component(hass, "persistent_notification", {})
with _patch_discovery(), _patch_wifibulb():
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": source}, data=data
@ -402,7 +399,6 @@ async def test_discovered_by_dhcp_or_discovery_adds_missing_unique_id(
"""Test we can setup when discovered from dhcp or discovery."""
config_entry = MockConfigEntry(domain=DOMAIN, data={CONF_HOST: IP_ADDRESS})
config_entry.add_to_hass(hass)
await setup.async_setup_component(hass, "persistent_notification", {})
with _patch_discovery(), _patch_wifibulb():
result = await hass.config_entries.flow.async_init(

View file

@ -28,7 +28,7 @@ async def test_invalid_path(hass):
"""Test that an invalid path is caught."""
config = {"sensor": {"platform": "folder", CONF_FOLDER_PATHS: "invalid_path"}}
assert await async_setup_component(hass, "sensor", config)
assert len(hass.states.async_entity_ids()) == 0
assert len(hass.states.async_entity_ids("sensor")) == 0
async def test_valid_path(hass):

View file

@ -16,18 +16,11 @@ from homeassistant.components.forecast_solar.const import (
)
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE
from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component
from homeassistant.util import dt as dt_util
from tests.common import MockConfigEntry
@pytest.fixture(autouse=True)
async def mock_persistent_notification(hass: HomeAssistant) -> None:
"""Set up component for persistent notifications."""
await async_setup_component(hass, "persistent_notification", {})
@pytest.fixture
def mock_config_entry() -> MockConfigEntry:
"""Return the default mocked config entry."""

View file

@ -8,7 +8,7 @@ from libpyfoscam.foscam import (
ERROR_FOSCAM_UNKNOWN,
)
from homeassistant import config_entries, data_entry_flow, setup
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.foscam import config_flow
from tests.common import MockConfigEntry
@ -76,7 +76,6 @@ def setup_mock_foscam_camera(mock_foscam_camera):
async def test_user_valid(hass):
"""Test valid config from user input."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
@ -108,7 +107,6 @@ async def test_user_valid(hass):
async def test_user_invalid_auth(hass):
"""Test we handle invalid auth from user input."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
@ -137,7 +135,6 @@ async def test_user_invalid_auth(hass):
async def test_user_cannot_connect(hass):
"""Test we handle cannot connect error from user input."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
@ -166,7 +163,6 @@ async def test_user_cannot_connect(hass):
async def test_user_invalid_response(hass):
"""Test we handle invalid response error from user input."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
@ -197,7 +193,6 @@ async def test_user_invalid_response(hass):
async def test_user_already_configured(hass):
"""Test we handle already configured from user input."""
await setup.async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=config_flow.DOMAIN,
@ -229,7 +224,6 @@ async def test_user_already_configured(hass):
async def test_user_unknown_exception(hass):
"""Test we handle unknown exceptions from user input."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
@ -255,7 +249,6 @@ async def test_user_unknown_exception(hass):
async def test_import_user_valid(hass):
"""Test valid config from import."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"homeassistant.components.foscam.config_flow.FoscamCamera",
@ -282,7 +275,6 @@ async def test_import_user_valid(hass):
async def test_import_user_valid_with_name(hass):
"""Test valid config with extra name from import."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"homeassistant.components.foscam.config_flow.FoscamCamera",
@ -313,7 +305,6 @@ async def test_import_user_valid_with_name(hass):
async def test_import_invalid_auth(hass):
"""Test we handle invalid auth from import."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"homeassistant.components.foscam.config_flow.FoscamCamera",
@ -337,7 +328,6 @@ async def test_import_invalid_auth(hass):
async def test_import_cannot_connect(hass):
"""Test we handle cannot connect error from import."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"homeassistant.components.foscam.config_flow.FoscamCamera",
@ -361,7 +351,6 @@ async def test_import_cannot_connect(hass):
async def test_import_invalid_response(hass):
"""Test we handle invalid response error from import."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"homeassistant.components.foscam.config_flow.FoscamCamera",
@ -387,7 +376,6 @@ async def test_import_invalid_response(hass):
async def test_import_already_configured(hass):
"""Test we handle already configured from import."""
await setup.async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=config_flow.DOMAIN,
@ -414,7 +402,6 @@ async def test_import_already_configured(hass):
async def test_import_unknown_exception(hass):
"""Test we handle unknown exceptions from import."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"homeassistant.components.foscam.config_flow.FoscamCamera",

View file

@ -46,7 +46,6 @@ async def test_setup(hass: HomeAssistant, router: Mock):
async def test_setup_import(hass: HomeAssistant, router: Mock):
"""Test setup of integration from import."""
await async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN,

View file

@ -4,7 +4,7 @@ from unittest.mock import patch
from aiohttp import ClientResponseError
import pytest
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.garages_amsterdam.const import DOMAIN
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import (
@ -16,7 +16,6 @@ from homeassistant.data_entry_flow import (
async def test_full_flow(hass: HomeAssistant) -> None:
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
@ -52,7 +51,6 @@ async def test_error_handling(
side_effect: Exception, reason: str, hass: HomeAssistant
) -> None:
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"homeassistant.components.garages_amsterdam.config_flow.garages_amsterdam.get_garages",

View file

@ -96,9 +96,12 @@ async def test_setup(hass, legacy_patchable_time):
hass.bus.async_fire(EVENT_HOMEASSISTANT_START)
await hass.async_block_till_done()
all_states = hass.states.async_all()
# 3 geolocation and 1 sensor entities
assert len(all_states) == 4
assert (
len(hass.states.async_entity_ids("geo_location"))
+ len(hass.states.async_entity_ids("sensor"))
== 4
)
entity_registry = er.async_get(hass)
assert len(entity_registry.entities) == 4
@ -169,8 +172,11 @@ async def test_setup(hass, legacy_patchable_time):
async_fire_time_changed(hass, utcnow + DEFAULT_SCAN_INTERVAL)
await hass.async_block_till_done()
all_states = hass.states.async_all()
assert len(all_states) == 4
assert (
len(hass.states.async_entity_ids("geo_location"))
+ len(hass.states.async_entity_ids("sensor"))
== 4
)
# Simulate an update - empty data, but successful update,
# so no changes to entities.
@ -178,16 +184,22 @@ async def test_setup(hass, legacy_patchable_time):
async_fire_time_changed(hass, utcnow + 2 * DEFAULT_SCAN_INTERVAL)
await hass.async_block_till_done()
all_states = hass.states.async_all()
assert len(all_states) == 4
assert (
len(hass.states.async_entity_ids("geo_location"))
+ len(hass.states.async_entity_ids("sensor"))
== 4
)
# Simulate an update - empty data, removes all entities
mock_feed_update.return_value = "ERROR", None
async_fire_time_changed(hass, utcnow + 3 * DEFAULT_SCAN_INTERVAL)
await hass.async_block_till_done()
all_states = hass.states.async_all()
assert len(all_states) == 1
assert (
len(hass.states.async_entity_ids("geo_location"))
+ len(hass.states.async_entity_ids("sensor"))
== 1
)
assert len(entity_registry.entities) == 1
@ -219,8 +231,11 @@ async def test_setup_imperial(hass, legacy_patchable_time):
hass.bus.async_fire(EVENT_HOMEASSISTANT_START)
await hass.async_block_till_done()
all_states = hass.states.async_all()
assert len(all_states) == 2
assert (
len(hass.states.async_entity_ids("geo_location"))
+ len(hass.states.async_entity_ids("sensor"))
== 2
)
# Test conversion of 200 miles to kilometers.
feeds = hass.data[DOMAIN][FEED]

View file

@ -61,9 +61,12 @@ async def test_setup(hass, legacy_patchable_time):
hass.bus.async_fire(EVENT_HOMEASSISTANT_START)
await hass.async_block_till_done()
all_states = hass.states.async_all()
# 3 geolocation and 1 sensor entities
assert len(all_states) == 4
assert (
len(hass.states.async_entity_ids("geo_location"))
+ len(hass.states.async_entity_ids("sensor"))
== 4
)
state = hass.states.get("sensor.gdacs_32_87336_117_22743")
assert state is not None
@ -83,8 +86,11 @@ async def test_setup(hass, legacy_patchable_time):
async_fire_time_changed(hass, utcnow + DEFAULT_SCAN_INTERVAL)
await hass.async_block_till_done()
all_states = hass.states.async_all()
assert len(all_states) == 4
assert (
len(hass.states.async_entity_ids("geo_location"))
+ len(hass.states.async_entity_ids("sensor"))
== 4
)
state = hass.states.get("sensor.gdacs_32_87336_117_22743")
attributes = state.attributes
@ -98,16 +104,22 @@ async def test_setup(hass, legacy_patchable_time):
async_fire_time_changed(hass, utcnow + 2 * DEFAULT_SCAN_INTERVAL)
await hass.async_block_till_done()
all_states = hass.states.async_all()
assert len(all_states) == 4
assert (
len(hass.states.async_entity_ids("geo_location"))
+ len(hass.states.async_entity_ids("sensor"))
== 4
)
# Simulate an update - empty data, removes all entities
mock_feed_update.return_value = "ERROR", None
async_fire_time_changed(hass, utcnow + 3 * DEFAULT_SCAN_INTERVAL)
await hass.async_block_till_done()
all_states = hass.states.async_all()
assert len(all_states) == 1
assert (
len(hass.states.async_entity_ids("geo_location"))
+ len(hass.states.async_entity_ids("sensor"))
== 1
)
state = hass.states.get("sensor.gdacs_32_87336_117_22743")
attributes = state.attributes

View file

@ -114,13 +114,11 @@ BEACON_EXIT_CAR = {
@pytest.fixture(autouse=True)
def mock_dev_track(mock_device_tracker_conf):
"""Mock device tracker config loading."""
pass
@pytest.fixture
async def geofency_client(loop, hass, hass_client_no_auth):
"""Geofency mock client (unauthenticated)."""
assert await async_setup_component(hass, "persistent_notification", {})
assert await async_setup_component(
hass, DOMAIN, {DOMAIN: {CONF_MOBILE_BEACONS: ["Car 1"]}}

View file

@ -72,9 +72,12 @@ async def test_setup(hass):
hass.bus.async_fire(EVENT_HOMEASSISTANT_START)
await hass.async_block_till_done()
all_states = hass.states.async_all()
# 3 geolocation and 1 sensor entities
assert len(all_states) == 4
assert (
len(hass.states.async_entity_ids("geo_location"))
+ len(hass.states.async_entity_ids("sensor"))
== 4
)
entity_registry = er.async_get(hass)
assert len(entity_registry.entities) == 4
@ -136,25 +139,32 @@ async def test_setup(hass):
async_fire_time_changed(hass, utcnow + DEFAULT_SCAN_INTERVAL)
await hass.async_block_till_done()
all_states = hass.states.async_all()
assert len(all_states) == 4
assert (
len(hass.states.async_entity_ids("geo_location"))
+ len(hass.states.async_entity_ids("sensor"))
== 4
)
# Simulate an update - empty data, but successful update,
# so no changes to entities.
mock_feed_update.return_value = "OK_NO_DATA", None
async_fire_time_changed(hass, utcnow + 2 * DEFAULT_SCAN_INTERVAL)
await hass.async_block_till_done()
all_states = hass.states.async_all()
assert len(all_states) == 4
assert (
len(hass.states.async_entity_ids("geo_location"))
+ len(hass.states.async_entity_ids("sensor"))
== 4
)
# Simulate an update - empty data, removes all entities
mock_feed_update.return_value = "ERROR", None
async_fire_time_changed(hass, utcnow + 3 * DEFAULT_SCAN_INTERVAL)
await hass.async_block_till_done()
all_states = hass.states.async_all()
assert len(all_states) == 1
assert (
len(hass.states.async_entity_ids("geo_location"))
+ len(hass.states.async_entity_ids("sensor"))
== 1
)
assert len(entity_registry.entities) == 1
@ -178,8 +188,11 @@ async def test_setup_imperial(hass):
hass.bus.async_fire(EVENT_HOMEASSISTANT_START)
await hass.async_block_till_done()
all_states = hass.states.async_all()
assert len(all_states) == 2
assert (
len(hass.states.async_entity_ids("geo_location"))
+ len(hass.states.async_entity_ids("sensor"))
== 2
)
# Test conversion of 200 miles to kilometers.
feeds = hass.data[DOMAIN][FEED]

View file

@ -62,9 +62,12 @@ async def test_setup(hass, legacy_patchable_time):
hass.bus.async_fire(EVENT_HOMEASSISTANT_START)
await hass.async_block_till_done()
all_states = hass.states.async_all()
# 3 geolocation and 1 sensor entities
assert len(all_states) == 4
assert (
len(hass.states.async_entity_ids("geo_location"))
+ len(hass.states.async_entity_ids("sensor"))
== 4
)
state = hass.states.get("sensor.geonet_nz_quakes_32_87336_117_22743")
assert state is not None
@ -84,8 +87,11 @@ async def test_setup(hass, legacy_patchable_time):
async_fire_time_changed(hass, utcnow + DEFAULT_SCAN_INTERVAL)
await hass.async_block_till_done()
all_states = hass.states.async_all()
assert len(all_states) == 4
assert (
len(hass.states.async_entity_ids("geo_location"))
+ len(hass.states.async_entity_ids("sensor"))
== 4
)
state = hass.states.get("sensor.geonet_nz_quakes_32_87336_117_22743")
attributes = state.attributes
@ -99,16 +105,22 @@ async def test_setup(hass, legacy_patchable_time):
async_fire_time_changed(hass, utcnow + 2 * DEFAULT_SCAN_INTERVAL)
await hass.async_block_till_done()
all_states = hass.states.async_all()
assert len(all_states) == 4
assert (
len(hass.states.async_entity_ids("geo_location"))
+ len(hass.states.async_entity_ids("sensor"))
== 4
)
# Simulate an update - empty data, removes all entities
mock_feed_update.return_value = "ERROR", None
async_fire_time_changed(hass, utcnow + 3 * DEFAULT_SCAN_INTERVAL)
await hass.async_block_till_done()
all_states = hass.states.async_all()
assert len(all_states) == 1
assert (
len(hass.states.async_entity_ids("geo_location"))
+ len(hass.states.async_entity_ids("sensor"))
== 1
)
state = hass.states.get("sensor.geonet_nz_quakes_32_87336_117_22743")
attributes = state.attributes

View file

@ -57,9 +57,12 @@ async def test_setup(hass, legacy_patchable_time):
hass.bus.async_fire(EVENT_HOMEASSISTANT_START)
await hass.async_block_till_done()
all_states = hass.states.async_all()
# 3 sensor entities
assert len(all_states) == 3
assert (
len(hass.states.async_entity_ids("geo_location"))
+ len(hass.states.async_entity_ids("sensor"))
== 3
)
state = hass.states.get("sensor.volcano_title_1")
assert state is not None
@ -101,8 +104,11 @@ async def test_setup(hass, legacy_patchable_time):
async_fire_time_changed(hass, utcnow + DEFAULT_SCAN_INTERVAL)
await hass.async_block_till_done()
all_states = hass.states.async_all()
assert len(all_states) == 4
assert (
len(hass.states.async_entity_ids("geo_location"))
+ len(hass.states.async_entity_ids("sensor"))
== 4
)
# Simulate an update - empty data, but successful update,
# so no changes to entities.
@ -110,24 +116,33 @@ async def test_setup(hass, legacy_patchable_time):
async_fire_time_changed(hass, utcnow + 2 * DEFAULT_SCAN_INTERVAL)
await hass.async_block_till_done()
all_states = hass.states.async_all()
assert len(all_states) == 4
assert (
len(hass.states.async_entity_ids("geo_location"))
+ len(hass.states.async_entity_ids("sensor"))
== 4
)
# Simulate an update - empty data, keep all entities
mock_feed_update.return_value = "ERROR", None
async_fire_time_changed(hass, utcnow + 3 * DEFAULT_SCAN_INTERVAL)
await hass.async_block_till_done()
all_states = hass.states.async_all()
assert len(all_states) == 4
assert (
len(hass.states.async_entity_ids("geo_location"))
+ len(hass.states.async_entity_ids("sensor"))
== 4
)
# Simulate an update - regular data for 3 entries
mock_feed_update.return_value = "OK", [mock_entry_1, mock_entry_2, mock_entry_3]
async_fire_time_changed(hass, utcnow + 4 * DEFAULT_SCAN_INTERVAL)
await hass.async_block_till_done()
all_states = hass.states.async_all()
assert len(all_states) == 4
assert (
len(hass.states.async_entity_ids("geo_location"))
+ len(hass.states.async_entity_ids("sensor"))
== 4
)
async def test_setup_imperial(hass):
@ -149,8 +164,11 @@ async def test_setup_imperial(hass):
hass.bus.async_fire(EVENT_HOMEASSISTANT_START)
await hass.async_block_till_done()
all_states = hass.states.async_all()
assert len(all_states) == 1
assert (
len(hass.states.async_entity_ids("geo_location"))
+ len(hass.states.async_entity_ids("sensor"))
== 1
)
# Test conversion of 200 miles to kilometers.
assert mock_feed_init.call_args[1].get("filter_radius") == 321.8688

View file

@ -10,7 +10,6 @@ from homeassistant.data_entry_flow import (
RESULT_TYPE_CREATE_ENTRY,
RESULT_TYPE_FORM,
)
from homeassistant.setup import async_setup_component
from . import (
CONF_CONFIG_FLOW,
@ -120,7 +119,7 @@ async def test_flow_user_unknown_error(hass):
async def test_dhcp_discovery(hass):
"""Test we can process the discovery from dhcp."""
await async_setup_component(hass, "persistent_notification", {})
mocked_yeti = await _create_mocked_yeti()
with _patch_config_flow_yeti(mocked_yeti), _patch_setup():
result = await hass.config_entries.flow.async_init(

View file

@ -5,7 +5,7 @@ from ismartgate import GogoGate2Api, ISmartGateApi
from ismartgate.common import ApiError
from ismartgate.const import GogoGate2ApiErrorCode
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.gogogate2.const import (
DEVICE_TYPE_GOGOGATE2,
DEVICE_TYPE_ISMARTGATE,
@ -102,7 +102,6 @@ async def test_auth_fail(
async def test_form_homekit_unique_id_already_setup(hass):
"""Test that we abort from homekit if gogogate2 is already setup."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN,
@ -134,7 +133,6 @@ async def test_form_homekit_unique_id_already_setup(hass):
async def test_form_homekit_ip_address_already_setup(hass):
"""Test that we abort from homekit if gogogate2 is already setup."""
await setup.async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN,
@ -152,7 +150,6 @@ async def test_form_homekit_ip_address_already_setup(hass):
async def test_form_homekit_ip_address(hass):
"""Test homekit includes the defaults ip address."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN,
@ -181,7 +178,6 @@ async def test_discovered_dhcp(
ismartgateapi_mock.return_value = api
api.reset_mock()
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN,
@ -227,7 +223,6 @@ async def test_discovered_dhcp(
async def test_discovered_by_homekit_and_dhcp(hass):
"""Test we get the form with homekit and abort for dhcp source when we get both."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN,

View file

@ -27,13 +27,11 @@ HOME_LONGITUDE = -115.815811
@pytest.fixture(autouse=True)
def mock_dev_track(mock_device_tracker_conf):
"""Mock device tracker config loading."""
pass
@pytest.fixture
async def gpslogger_client(loop, hass, hass_client_no_auth):
"""Mock client for GPSLogger (unauthenticated)."""
assert await async_setup_component(hass, "persistent_notification", {})
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {}})

View file

@ -3,7 +3,7 @@ from unittest.mock import AsyncMock, MagicMock, patch
from aiohttp import ClientResponseError
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.habitica.const import DEFAULT_URL, DOMAIN
from tests.common import MockConfigEntry
@ -11,7 +11,7 @@ from tests.common import MockConfigEntry
async def test_form(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -1,7 +1,7 @@
"""Test the Logitech Harmony Hub config flow."""
from unittest.mock import AsyncMock, MagicMock, patch
from homeassistant import config_entries, data_entry_flow, setup
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.harmony.config_flow import CannotConnect
from homeassistant.components.harmony.const import DOMAIN, PREVIOUS_ACTIVE_ACTIVITY
from homeassistant.const import CONF_HOST, CONF_NAME
@ -19,7 +19,7 @@ def _get_mock_harmonyapi(connect=None, close=None):
async def test_user_form(hass):
"""Test we get the user form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -48,7 +48,6 @@ async def test_user_form(hass):
async def test_form_ssdp(hass):
"""Test we get the form with ssdp source."""
await setup.async_setup_component(hass, "persistent_notification", {})
harmonyapi = _get_mock_harmonyapi(connect=True)
@ -97,7 +96,7 @@ async def test_form_ssdp(hass):
async def test_form_ssdp_aborts_before_checking_remoteid_if_host_known(hass):
"""Test we abort without connecting if the host is already known."""
await setup.async_setup_component(hass, "persistent_notification", {})
config_entry = MockConfigEntry(
domain=DOMAIN,
data={"host": "2.2.2.2", "name": "any"},

View file

@ -1,13 +1,12 @@
"""Test the Home Assistant Supervisor config flow."""
from unittest.mock import patch
from homeassistant import setup
from homeassistant.components.hassio import DOMAIN
async def test_config_flow(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"homeassistant.components.hassio.async_setup", return_value=True
) as mock_setup, patch(

View file

@ -786,7 +786,6 @@ async def test_location_device_tracker_added_after_update(
await hass.async_block_till_done()
sensor = hass.states.get("sensor.test")
assert len(caplog.records) == 2
assert "Unable to find entity" in caplog.text
caplog.clear()
@ -908,7 +907,6 @@ async def test_pattern_origin(hass, caplog):
}
assert await async_setup_component(hass, DOMAIN, config)
await hass.async_block_till_done()
assert len(caplog.records) == 2
assert "invalid latitude" in caplog.text
@ -928,7 +926,6 @@ async def test_pattern_destination(hass, caplog):
}
assert await async_setup_component(hass, DOMAIN, config)
await hass.async_block_till_done()
assert len(caplog.records) == 2
assert "invalid latitude" in caplog.text
@ -1179,7 +1176,6 @@ async def test_arrival_only_allowed_for_timetable(hass, caplog):
}
assert await async_setup_component(hass, DOMAIN, config)
await hass.async_block_till_done()
assert len(caplog.records) == 2
assert "[arrival] is an invalid option" in caplog.text
@ -1204,5 +1200,4 @@ async def test_exclusive_arrival_and_departure(hass, caplog):
}
assert await async_setup_component(hass, DOMAIN, config)
await hass.async_block_till_done()
assert len(caplog.records) == 2
assert "two or more values in the same group of exclusion" in caplog.text

View file

@ -3,7 +3,7 @@ from unittest.mock import patch
from apyhiveapi.helper import hive_exceptions
from homeassistant import config_entries, data_entry_flow, setup
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.hive.const import CONF_CODE, DOMAIN
from homeassistant.const import CONF_PASSWORD, CONF_SCAN_INTERVAL, CONF_USERNAME
@ -181,7 +181,6 @@ async def test_user_flow_2fa(hass):
async def test_reauth_flow(hass):
"""Test the reauth flow."""
await setup.async_setup_component(hass, "persistent_notification", {})
mock_config = MockConfigEntry(
domain=DOMAIN,
unique_id=USERNAME,

View file

@ -2,7 +2,7 @@
import asyncio
from unittest.mock import patch
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.hlk_sw16.const import DOMAIN
@ -49,7 +49,7 @@ async def create_mock_hlk_sw16_connection(fail):
async def test_form(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -110,7 +110,7 @@ async def test_form(hass):
async def test_import(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_IMPORT}
)

View file

@ -3,7 +3,7 @@ from unittest.mock import patch
import pytest
from homeassistant import config_entries, data_entry_flow, setup
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.homekit.const import DOMAIN, SHORT_BRIDGE_NAME
from homeassistant.config_entries import SOURCE_IGNORE, SOURCE_IMPORT
from homeassistant.const import CONF_NAME, CONF_PORT
@ -35,7 +35,7 @@ def _mock_config_entry_with_options_populated():
async def test_setup_in_bridge_mode(hass, mock_get_source_ip):
"""Test we can setup a new instance in bridge mode."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -85,7 +85,6 @@ async def test_setup_in_bridge_mode(hass, mock_get_source_ip):
async def test_setup_in_bridge_mode_name_taken(hass, mock_get_source_ip):
"""Test we can setup a new instance in bridge mode when the name is taken."""
await setup.async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN,
@ -175,7 +174,6 @@ async def test_setup_creates_entries_for_accessory_mode_devices(
)
accessory_mode_entry.add_to_hass(hass)
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -235,7 +233,6 @@ async def test_setup_creates_entries_for_accessory_mode_devices(
async def test_import(hass, mock_get_source_ip):
"""Test we can import instance."""
await setup.async_setup_component(hass, "persistent_notification", {})
ignored_entry = MockConfigEntry(domain=DOMAIN, data={}, source=SOURCE_IGNORE)
ignored_entry.add_to_hass(hass)
@ -379,7 +376,6 @@ async def test_options_flow_devices(
demo_config_entry = MockConfigEntry(domain="domain")
demo_config_entry.add_to_hass(hass)
assert await async_setup_component(hass, "persistent_notification", {})
assert await async_setup_component(hass, "demo", {"demo": {}})
assert await async_setup_component(hass, "homekit", {"homekit": {}})
@ -460,7 +456,6 @@ async def test_options_flow_devices_preserved_when_advanced_off(
demo_config_entry = MockConfigEntry(domain="domain")
demo_config_entry.add_to_hass(hass)
assert await async_setup_component(hass, "persistent_notification", {})
assert await async_setup_component(hass, "homekit", {"homekit": {}})
hass.states.async_set("climate.old", "off")
@ -1006,7 +1001,7 @@ async def test_options_flow_include_mode_basic_accessory(hass, mock_get_source_i
async def test_converting_bridge_to_accessory_mode(hass, hk_driver, mock_get_source_ip):
"""Test we can convert a bridge to accessory mode."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -147,7 +147,7 @@ def _mock_pyhap_bridge():
async def test_setup_min(hass, mock_zeroconf):
"""Test async_setup with min config options."""
await async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN,
data={CONF_NAME: BRIDGE_NAME, CONF_PORT: DEFAULT_PORT},
@ -186,7 +186,7 @@ async def test_setup_min(hass, mock_zeroconf):
async def test_setup_auto_start_disabled(hass, mock_zeroconf):
"""Test async_setup with auto start disabled and test service calls."""
await async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN,
data={CONF_NAME: "Test Name", CONF_PORT: 11111, CONF_IP_ADDRESS: "172.0.0.0"},
@ -370,7 +370,7 @@ async def test_homekit_setup_advertise_ip(hass, hk_driver, mock_zeroconf):
async def test_homekit_add_accessory(hass, mock_zeroconf):
"""Add accessory if config exists and get_acc returns an accessory."""
await async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN, data={CONF_NAME: "mock_name", CONF_PORT: 12345}
)
@ -408,7 +408,7 @@ async def test_homekit_warn_add_accessory_bridge(
hass, acc_category, mock_zeroconf, caplog
):
"""Test we warn when adding cameras or tvs to a bridge."""
await async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN, data={CONF_NAME: "mock_name", CONF_PORT: 12345}
)
@ -673,7 +673,7 @@ async def test_homekit_stop(hass):
async def test_homekit_reset_accessories(hass, mock_zeroconf):
"""Test resetting HomeKit accessories."""
await async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN, data={CONF_NAME: "mock_name", CONF_PORT: 12345}
)
@ -718,7 +718,7 @@ async def test_homekit_reset_accessories(hass, mock_zeroconf):
async def test_homekit_unpair(hass, device_reg, mock_zeroconf):
"""Test unpairing HomeKit accessories."""
await async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN, data={CONF_NAME: "mock_name", CONF_PORT: 12345}
)
@ -760,7 +760,7 @@ async def test_homekit_unpair(hass, device_reg, mock_zeroconf):
async def test_homekit_unpair_missing_device_id(hass, device_reg, mock_zeroconf):
"""Test unpairing HomeKit accessories with invalid device id."""
await async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN, data={CONF_NAME: "mock_name", CONF_PORT: 12345}
)
@ -798,7 +798,7 @@ async def test_homekit_unpair_missing_device_id(hass, device_reg, mock_zeroconf)
async def test_homekit_unpair_not_homekit_device(hass, device_reg, mock_zeroconf):
"""Test unpairing HomeKit accessories with a non-homekit device id."""
await async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN, data={CONF_NAME: "mock_name", CONF_PORT: 12345}
)
@ -846,7 +846,7 @@ async def test_homekit_unpair_not_homekit_device(hass, device_reg, mock_zeroconf
async def test_homekit_reset_accessories_not_supported(hass, mock_zeroconf):
"""Test resetting HomeKit accessories with an unsupported entity."""
await async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN, data={CONF_NAME: "mock_name", CONF_PORT: 12345}
)
@ -890,7 +890,7 @@ async def test_homekit_reset_accessories_not_supported(hass, mock_zeroconf):
async def test_homekit_reset_accessories_state_missing(hass, mock_zeroconf):
"""Test resetting HomeKit accessories when the state goes missing."""
await async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN, data={CONF_NAME: "mock_name", CONF_PORT: 12345}
)
@ -932,7 +932,7 @@ async def test_homekit_reset_accessories_state_missing(hass, mock_zeroconf):
async def test_homekit_reset_accessories_not_bridged(hass, mock_zeroconf):
"""Test resetting HomeKit accessories when the state is not bridged."""
await async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN, data={CONF_NAME: "mock_name", CONF_PORT: 12345}
)
@ -974,7 +974,7 @@ async def test_homekit_reset_accessories_not_bridged(hass, mock_zeroconf):
async def test_homekit_reset_single_accessory(hass, mock_zeroconf):
"""Test resetting HomeKit single accessory."""
await async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN, data={CONF_NAME: "mock_name", CONF_PORT: 12345}
)
@ -1013,7 +1013,7 @@ async def test_homekit_reset_single_accessory(hass, mock_zeroconf):
async def test_homekit_reset_single_accessory_unsupported(hass, mock_zeroconf):
"""Test resetting HomeKit single accessory with an unsupported entity."""
await async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN, data={CONF_NAME: "mock_name", CONF_PORT: 12345}
)
@ -1050,7 +1050,7 @@ async def test_homekit_reset_single_accessory_unsupported(hass, mock_zeroconf):
async def test_homekit_reset_single_accessory_state_missing(hass, mock_zeroconf):
"""Test resetting HomeKit single accessory when the state goes missing."""
await async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN, data={CONF_NAME: "mock_name", CONF_PORT: 12345}
)
@ -1086,7 +1086,7 @@ async def test_homekit_reset_single_accessory_state_missing(hass, mock_zeroconf)
async def test_homekit_reset_single_accessory_no_match(hass, mock_zeroconf):
"""Test resetting HomeKit single accessory when the entity id does not match."""
await async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN, data={CONF_NAME: "mock_name", CONF_PORT: 12345}
)
@ -1292,7 +1292,7 @@ async def test_homekit_async_get_integration_fails(
async def test_yaml_updates_update_config_entry_for_name(hass, mock_zeroconf):
"""Test async_setup with imported config."""
await async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN,
source=SOURCE_IMPORT,
@ -1369,7 +1369,7 @@ async def test_homekit_ignored_missing_devices(
hass, hk_driver, device_reg, entity_reg, mock_zeroconf
):
"""Test HomeKit handles a device in the entity registry but missing from the device registry."""
await async_setup_component(hass, "persistent_notification", {})
entry = await async_init_integration(hass)
homekit = _mock_homekit(hass, entry, HOMEKIT_MODE_BRIDGE)
@ -1564,7 +1564,7 @@ async def test_homekit_finds_linked_humidity_sensors(
async def test_reload(hass, mock_zeroconf):
"""Test we can reload from yaml."""
await async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN,
source=SOURCE_IMPORT,
@ -1729,7 +1729,7 @@ async def test_homekit_start_in_accessory_mode_missing_entity(
async def test_wait_for_port_to_free(hass, hk_driver, mock_zeroconf, caplog):
"""Test we wait for the port to free before declaring unload success."""
await async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN,
data={CONF_NAME: BRIDGE_NAME, CONF_PORT: DEFAULT_PORT},

View file

@ -39,11 +39,7 @@ from homeassistant.components.homekit.util import (
validate_entity_config as vec,
validate_media_player_features,
)
from homeassistant.components.persistent_notification import (
ATTR_MESSAGE,
ATTR_NOTIFICATION_ID,
DOMAIN as PERSISTENT_NOTIFICATION_DOMAIN,
)
from homeassistant.components.persistent_notification import create, dismiss
from homeassistant.const import (
ATTR_CODE,
ATTR_SUPPORTED_FEATURES,
@ -58,7 +54,7 @@ from homeassistant.core import State
from .util import async_init_integration
from tests.common import MockConfigEntry, async_mock_service
from tests.common import MockConfigEntry
def _mock_socket(failure_attempts: int = 0) -> MagicMock:
@ -242,33 +238,31 @@ async def test_show_setup_msg(hass, hk_driver, mock_get_source_ip):
entry = await async_init_integration(hass)
assert entry
call_create_notification = async_mock_service(
hass, PERSISTENT_NOTIFICATION_DOMAIN, "create"
)
await hass.async_add_executor_job(
show_setup_message, hass, entry.entry_id, "bridge_name", pincode, "X-HM://0"
)
await hass.async_block_till_done()
with patch(
"homeassistant.components.persistent_notification.create", side_effect=create
) as mock_create:
await hass.async_add_executor_job(
show_setup_message, hass, entry.entry_id, "bridge_name", pincode, "X-HM://0"
)
await hass.async_block_till_done()
assert hass.data[DOMAIN][entry.entry_id][HOMEKIT_PAIRING_QR_SECRET]
assert hass.data[DOMAIN][entry.entry_id][HOMEKIT_PAIRING_QR]
assert call_create_notification
assert call_create_notification[0].data[ATTR_NOTIFICATION_ID] == entry.entry_id
assert pincode.decode() in call_create_notification[0].data[ATTR_MESSAGE]
assert len(mock_create.mock_calls) == 1
assert mock_create.mock_calls[0][1][3] == entry.entry_id
assert pincode.decode() in mock_create.mock_calls[0][1][1]
async def test_dismiss_setup_msg(hass):
"""Test dismiss setup message."""
call_dismiss_notification = async_mock_service(
hass, PERSISTENT_NOTIFICATION_DOMAIN, "dismiss"
)
with patch(
"homeassistant.components.persistent_notification.dismiss", side_effect=dismiss
) as mock_dismiss:
await hass.async_add_executor_job(dismiss_setup_message, hass, "entry_id")
await hass.async_block_till_done()
await hass.async_add_executor_job(dismiss_setup_message, hass, "entry_id")
await hass.async_block_till_done()
assert call_dismiss_notification
assert call_dismiss_notification[0].data[ATTR_NOTIFICATION_ID] == "entry_id"
assert len(mock_dismiss.mock_calls) == 1
assert mock_dismiss.mock_calls[0][1][1] == "entry_id"
async def test_port_is_available(hass):

View file

@ -24,8 +24,6 @@ from homeassistant.setup import async_setup_component
from . import mock_real_ip
from tests.common import async_mock_service
SUPERVISOR_IP = "1.2.3.4"
BANNED_IPS = ["200.201.202.203", "100.64.0.2"]
BANNED_IPS_WITH_SUPERVISOR = BANNED_IPS + [SUPERVISOR_IP]
@ -136,8 +134,6 @@ async def test_ban_middleware_loaded_by_default(hass):
async def test_ip_bans_file_creation(hass, aiohttp_client):
"""Testing if banned IP file created."""
notification_calls = async_mock_service(hass, "persistent_notification", "create")
app = web.Application()
app["hass"] = hass
@ -174,9 +170,11 @@ async def test_ip_bans_file_creation(hass, aiohttp_client):
assert resp.status == HTTP_FORBIDDEN
assert m_open.call_count == 1
assert len(notification_calls) == 3
assert (
notification_calls[0].data["message"]
len(notifications := hass.states.async_all("persistent_notification")) == 2
)
assert (
notifications[0].attributes["message"]
== "Login attempt or request with invalid authentication from example.com (200.201.202.204). See the log for details."
)

View file

@ -108,7 +108,7 @@ async def test_fixing_unique_id_other_correct(hass, mock_bridge_setup):
async def test_security_vuln_check(hass):
"""Test that we report security vulnerabilities."""
assert await async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(domain=hue.DOMAIN, data={"host": "0.0.0.0"})
entry.add_to_hass(hass)

View file

@ -1,7 +1,7 @@
"""Test the Huisbaasje config flow."""
from unittest.mock import patch
from homeassistant import config_entries, data_entry_flow, setup
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.huisbaasje.config_flow import (
HuisbaasjeConnectionException,
HuisbaasjeException,
@ -13,7 +13,7 @@ from tests.common import MockConfigEntry
async def test_form(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -5,7 +5,7 @@ from unittest.mock import AsyncMock, MagicMock, patch
import pytest
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.hunterdouglas_powerview.const import DOMAIN
from tests.common import MockConfigEntry, load_fixture
@ -73,7 +73,7 @@ def _get_mock_powerview_fwversion(fwversion=None, get_resources=None):
async def test_user_form(hass):
"""Test we get the user form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -116,7 +116,7 @@ async def test_user_form(hass):
async def test_user_form_legacy(hass):
"""Test we get the user form with a legacy device."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -164,7 +164,6 @@ async def test_user_form_legacy(hass):
@pytest.mark.parametrize("source, discovery_info", DISCOVERY_DATA)
async def test_form_homekit_and_dhcp_cannot_connect(hass, source, discovery_info):
"""Test we get the form with homekit and dhcp source."""
await setup.async_setup_component(hass, "persistent_notification", {})
ignored_config_entry = MockConfigEntry(
domain=DOMAIN, data={}, source=config_entries.SOURCE_IGNORE
@ -191,7 +190,6 @@ async def test_form_homekit_and_dhcp_cannot_connect(hass, source, discovery_info
@pytest.mark.parametrize("source, discovery_info", DISCOVERY_DATA)
async def test_form_homekit_and_dhcp(hass, source, discovery_info):
"""Test we get the form with homekit and dhcp source."""
await setup.async_setup_component(hass, "persistent_notification", {})
ignored_config_entry = MockConfigEntry(
domain=DOMAIN, data={}, source=config_entries.SOURCE_IGNORE
@ -244,7 +242,6 @@ async def test_form_homekit_and_dhcp(hass, source, discovery_info):
async def test_discovered_by_homekit_and_dhcp(hass):
"""Test we get the form with homekit and abort for dhcp source when we get both."""
await setup.async_setup_component(hass, "persistent_notification", {})
mock_powerview_userdata = _get_mock_powerview_userdata()
with patch(

View file

@ -1,7 +1,7 @@
"""Test the Antifurto365 iAlarm config flow."""
from unittest.mock import patch
from homeassistant import config_entries, data_entry_flow, setup
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.ialarm.const import DOMAIN
from homeassistant.const import CONF_HOST, CONF_PORT
@ -14,7 +14,7 @@ TEST_MAC = "00:00:54:12:34:56"
async def test_form(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -2,7 +2,7 @@
from unittest.mock import patch
from homeassistant import config_entries, data_entry_flow, setup
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.insteon.config_flow import (
HUB1,
HUB2,
@ -95,7 +95,7 @@ async def _device_form(hass, flow_id, connection, user_input):
async def test_form_select_modem(hass: HomeAssistant):
"""Test we get a modem form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await _init_form(hass, HUB2)
assert result["step_id"] == STEP_HUB_V2
assert result["type"] == "form"
@ -123,7 +123,7 @@ async def test_fail_on_existing(hass: HomeAssistant):
async def test_form_select_plm(hass: HomeAssistant):
"""Test we set up the PLM correctly."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await _init_form(hass, PLM)
result2, mock_setup, mock_setup_entry = await _device_form(
@ -138,7 +138,7 @@ async def test_form_select_plm(hass: HomeAssistant):
async def test_form_select_hub_v1(hass: HomeAssistant):
"""Test we set up the Hub v1 correctly."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await _init_form(hass, HUB1)
result2, mock_setup, mock_setup_entry = await _device_form(
@ -156,7 +156,7 @@ async def test_form_select_hub_v1(hass: HomeAssistant):
async def test_form_select_hub_v2(hass: HomeAssistant):
"""Test we set up the Hub v2 correctly."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await _init_form(hass, HUB2)
result2, mock_setup, mock_setup_entry = await _device_form(
@ -174,7 +174,7 @@ async def test_form_select_hub_v2(hass: HomeAssistant):
async def test_failed_connection_plm(hass: HomeAssistant):
"""Test a failed connection with the PLM."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await _init_form(hass, PLM)
result2, _, _ = await _device_form(
@ -186,7 +186,7 @@ async def test_failed_connection_plm(hass: HomeAssistant):
async def test_failed_connection_hub(hass: HomeAssistant):
"""Test a failed connection with a Hub."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await _init_form(hass, HUB2)
result2, _, _ = await _device_form(
@ -208,7 +208,6 @@ async def _import_config(hass, config):
async def test_import_plm(hass: HomeAssistant):
"""Test importing a minimum PLM config from yaml."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await _import_config(hass, MOCK_IMPORT_CONFIG_PLM)
@ -235,7 +234,6 @@ async def _options_init_form(hass, entry_id, step):
async def test_import_min_hub_v2(hass: HomeAssistant):
"""Test importing a minimum Hub v2 config from yaml."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await _import_config(
hass, {**MOCK_IMPORT_MINIMUM_HUB_V2, CONF_PORT: 25105, CONF_HUB_VERSION: 2}
@ -253,7 +251,6 @@ async def test_import_min_hub_v2(hass: HomeAssistant):
async def test_import_min_hub_v1(hass: HomeAssistant):
"""Test importing a minimum Hub v1 config from yaml."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await _import_config(
hass, {**MOCK_IMPORT_MINIMUM_HUB_V1, CONF_PORT: 9761, CONF_HUB_VERSION: 1}
@ -287,7 +284,6 @@ async def test_import_existing(hass: HomeAssistant):
async def test_import_failed_connection(hass: HomeAssistant):
"""Test a failed connection on import."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(PATCH_CONNECTION, new=mock_failed_connection,), patch(
PATCH_ASYNC_SETUP, return_value=True

View file

@ -3,7 +3,7 @@ from unittest.mock import patch
import httpx
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.iotawatt.const import DOMAIN
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import RESULT_TYPE_CREATE_ENTRY, RESULT_TYPE_FORM
@ -11,7 +11,7 @@ from homeassistant.data_entry_flow import RESULT_TYPE_CREATE_ENTRY, RESULT_TYPE_
async def test_form(hass: HomeAssistant) -> None:
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -43,7 +43,6 @@ async def test_form(hass: HomeAssistant) -> None:
async def test_form_auth(hass: HomeAssistant) -> None:
"""Test we handle auth."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -4,7 +4,7 @@ from unittest.mock import patch
from pyisy import ISYConnectionError, ISYInvalidAuthError
from homeassistant import config_entries, data_entry_flow, setup
from homeassistant import config_entries, data_entry_flow
from homeassistant.components import dhcp, ssdp
from homeassistant.components.isy994.const import (
CONF_IGNORE_STRING,
@ -92,7 +92,7 @@ PATCH_ASYNC_SETUP_ENTRY = f"{INTEGRATION}.async_setup_entry"
async def test_form(hass: HomeAssistant):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -233,7 +233,7 @@ async def test_form_no_name_in_response(hass: HomeAssistant):
async def test_form_existing_config_entry(hass: HomeAssistant):
"""Test if config entry already exists."""
MockConfigEntry(domain=DOMAIN, unique_id=MOCK_UUID).add_to_hass(hass)
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -316,7 +316,6 @@ async def test_import_flow_all_fields(hass: HomeAssistant) -> None:
async def test_form_ssdp_already_configured(hass: HomeAssistant) -> None:
"""Test ssdp abort when the serial number is already configured."""
await setup.async_setup_component(hass, "persistent_notification", {})
MockConfigEntry(
domain=DOMAIN,
@ -338,7 +337,6 @@ async def test_form_ssdp_already_configured(hass: HomeAssistant) -> None:
async def test_form_ssdp(hass: HomeAssistant):
"""Test we can setup from ssdp."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN,
@ -375,7 +373,7 @@ async def test_form_ssdp(hass: HomeAssistant):
async def test_form_ssdp_existing_entry(hass: HomeAssistant):
"""Test we update the ip of an existing entry from ssdp."""
await setup.async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN,
data={CONF_HOST: f"http://{MOCK_HOSTNAME}{ISY_URL_POSTFIX}"},
@ -402,7 +400,7 @@ async def test_form_ssdp_existing_entry(hass: HomeAssistant):
async def test_form_ssdp_existing_entry_with_no_port(hass: HomeAssistant):
"""Test we update the ip of an existing entry from ssdp with no port."""
await setup.async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN,
data={CONF_HOST: f"http://{MOCK_HOSTNAME}:1443/{ISY_URL_POSTFIX}"},
@ -429,7 +427,7 @@ async def test_form_ssdp_existing_entry_with_no_port(hass: HomeAssistant):
async def test_form_ssdp_existing_entry_with_alternate_port(hass: HomeAssistant):
"""Test we update the ip of an existing entry from ssdp with an alternate port."""
await setup.async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN,
data={CONF_HOST: f"http://{MOCK_HOSTNAME}:1443/{ISY_URL_POSTFIX}"},
@ -456,7 +454,7 @@ async def test_form_ssdp_existing_entry_with_alternate_port(hass: HomeAssistant)
async def test_form_ssdp_existing_entry_no_port_https(hass: HomeAssistant):
"""Test we update the ip of an existing entry from ssdp with no port and https."""
await setup.async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN,
data={CONF_HOST: f"https://{MOCK_HOSTNAME}/{ISY_URL_POSTFIX}"},
@ -483,7 +481,6 @@ async def test_form_ssdp_existing_entry_no_port_https(hass: HomeAssistant):
async def test_form_dhcp(hass: HomeAssistant):
"""Test we can setup from dhcp."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN,
@ -520,7 +517,7 @@ async def test_form_dhcp(hass: HomeAssistant):
async def test_form_dhcp_existing_entry(hass: HomeAssistant):
"""Test we update the ip of an existing entry from dhcp."""
await setup.async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN,
data={CONF_HOST: f"http://{MOCK_HOSTNAME}{ISY_URL_POSTFIX}"},
@ -547,7 +544,7 @@ async def test_form_dhcp_existing_entry(hass: HomeAssistant):
async def test_form_dhcp_existing_entry_preserves_port(hass: HomeAssistant):
"""Test we update the ip of an existing entry from dhcp preserves port."""
await setup.async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN,
data={

View file

@ -4,7 +4,7 @@ from unittest.mock import MagicMock, patch
import aiohttp
from pyjuicenet import TokenError
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.juicenet.const import DOMAIN
from homeassistant.const import CONF_ACCESS_TOKEN
@ -17,7 +17,7 @@ def _mock_juicenet_return_value(get_devices=None):
async def test_form(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -3,7 +3,7 @@ from unittest.mock import Mock, patch
from aiohttp import ClientConnectorError, ClientResponseError
from homeassistant import config_entries, data_entry_flow, setup
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.kmtronic.const import CONF_REVERSE, DOMAIN
from homeassistant.config_entries import ConfigEntryState
@ -12,7 +12,7 @@ from tests.common import MockConfigEntry
async def test_form(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -4,7 +4,7 @@ from unittest.mock import ANY, AsyncMock, MagicMock, patch
from kostal.plenticore import PlenticoreAuthenticationException
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.kostal_plenticore.const import DOMAIN
from tests.common import MockConfigEntry
@ -12,7 +12,7 @@ from tests.common import MockConfigEntry
async def test_formx(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -3,13 +3,13 @@ from unittest.mock import MagicMock, patch
import pykulersky
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.kulersky.config_flow import DOMAIN
async def test_flow_success(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -41,7 +41,7 @@ async def test_flow_success(hass):
async def test_flow_no_devices_found(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -68,7 +68,7 @@ async def test_flow_no_devices_found(hass):
async def test_flow_exceptions_caught(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -5,7 +5,6 @@ import pykulersky
import pytest
from pytest import approx
from homeassistant import setup
from homeassistant.components.kulersky.const import (
DATA_ADDRESSES,
DATA_DISCOVERY_SUBSCRIPTION,
@ -44,7 +43,6 @@ async def mock_entry(hass):
@pytest.fixture
async def mock_light(hass, mock_entry):
"""Create a mock light entity."""
await setup.async_setup_component(hass, "persistent_notification", {})
light = MagicMock(spec=pykulersky.Light)
light.address = "AA:BB:CC:11:22:33"
@ -102,7 +100,6 @@ async def test_remove_entry_exceptions_caught(hass, mock_light, mock_entry):
async def test_update_exception(hass, mock_light):
"""Test platform setup."""
await setup.async_setup_component(hass, "persistent_notification", {})
mock_light.get_color.side_effect = pykulersky.PykulerskyException
await hass.helpers.entity_component.async_update_entity("light.bedroom")

View file

@ -4,7 +4,7 @@ from unittest.mock import patch
from pypck.connection import PchkAuthenticationError, PchkLicenseError
import pytest
from homeassistant import config_entries, data_entry_flow, setup
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.lcn.const import CONF_DIM_MODE, CONF_SK_NUM_TRIES, DOMAIN
from homeassistant.const import (
CONF_HOST,
@ -29,7 +29,7 @@ IMPORT_DATA = {
async def test_step_import(hass):
"""Test for import step."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch("pypck.connection.PchkConnectionManager.async_connect"), patch(
"homeassistant.components.lcn.async_setup", return_value=True
), patch("homeassistant.components.lcn.async_setup_entry", return_value=True):
@ -46,7 +46,7 @@ async def test_step_import(hass):
async def test_step_import_existing_host(hass):
"""Test for update of config_entry if imported host already exists."""
await setup.async_setup_component(hass, "persistent_notification", {})
# Create config entry and add it to hass
mock_data = IMPORT_DATA.copy()
mock_data.update({CONF_SK_NUM_TRIES: 3, CONF_DIM_MODE: 50})
@ -77,7 +77,7 @@ async def test_step_import_existing_host(hass):
)
async def test_step_import_error(hass, error, reason):
"""Test for authentication error is handled correctly."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"pypck.connection.PchkConnectionManager.async_connect", side_effect=error
):

View file

@ -11,7 +11,6 @@ from homeassistant import config_entries
from homeassistant.components.lcn.const import DOMAIN
from homeassistant.config_entries import ConfigEntryState
from homeassistant.helpers import entity_registry as er
from homeassistant.setup import async_setup_component
from .conftest import MockPchkConnectionManager, init_integration, setup_component
@ -98,7 +97,6 @@ async def test_async_setup_entry_raises_timeout_error(hass, entry):
@patch("pypck.connection.PchkConnectionManager", MockPchkConnectionManager)
async def test_async_setup_from_configuration_yaml(hass):
"""Test a successful setup using data from configuration.yaml."""
await async_setup_component(hass, "persistent_notification", {})
with patch("homeassistant.components.lcn.async_setup_entry") as async_setup_entry:
await setup_component(hass)

View file

@ -3,7 +3,7 @@ from unittest.mock import patch
from pylitterbot.exceptions import LitterRobotException, LitterRobotLoginException
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components import litterrobot
from .common import CONF_USERNAME, CONFIG, DOMAIN
@ -13,7 +13,7 @@ from tests.common import MockConfigEntry
async def test_form(hass, mock_account):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -7,7 +7,7 @@ from pylutron_caseta.pairing import PAIR_CA, PAIR_CERT, PAIR_KEY
from pylutron_caseta.smartbridge import Smartbridge
import pytest
from homeassistant import config_entries, data_entry_flow, setup
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.lutron_caseta import DOMAIN
import homeassistant.components.lutron_caseta.config_flow as CasetaConfigFlow
from homeassistant.components.lutron_caseta.const import (
@ -195,7 +195,6 @@ async def test_duplicate_bridge_import(hass):
async def test_already_configured_with_ignored(hass):
"""Test ignored entries do not break checking for existing entries."""
await setup.async_setup_component(hass, "persistent_notification", {})
config_entry = MockConfigEntry(
domain=DOMAIN, data={}, source=config_entries.SOURCE_IGNORE
@ -217,7 +216,7 @@ async def test_already_configured_with_ignored(hass):
async def test_form_user(hass, tmpdir):
"""Test we get the form and can pair."""
await setup.async_setup_component(hass, "persistent_notification", {})
hass.config.config_dir = await hass.async_add_executor_job(
tmpdir.mkdir, "tls_assets"
)
@ -268,7 +267,7 @@ async def test_form_user(hass, tmpdir):
async def test_form_user_pairing_fails(hass, tmpdir):
"""Test we get the form and we handle pairing failure."""
await setup.async_setup_component(hass, "persistent_notification", {})
hass.config.config_dir = await hass.async_add_executor_job(
tmpdir.mkdir, "tls_assets"
)
@ -313,7 +312,7 @@ async def test_form_user_pairing_fails(hass, tmpdir):
async def test_form_user_reuses_existing_assets_when_pairing_again(hass, tmpdir):
"""Test the tls assets saved on disk are reused when pairing again."""
await setup.async_setup_component(hass, "persistent_notification", {})
hass.config.config_dir = await hass.async_add_executor_job(
tmpdir.mkdir, "tls_assets"
)
@ -413,7 +412,7 @@ async def test_form_user_reuses_existing_assets_when_pairing_again(hass, tmpdir)
async def test_zeroconf_host_already_configured(hass, tmpdir):
"""Test starting a flow from discovery when the host is already configured."""
await setup.async_setup_component(hass, "persistent_notification", {})
hass.config.config_dir = await hass.async_add_executor_job(
tmpdir.mkdir, "tls_assets"
)
@ -438,7 +437,6 @@ async def test_zeroconf_host_already_configured(hass, tmpdir):
async def test_zeroconf_lutron_id_already_configured(hass):
"""Test starting a flow from discovery when lutron id already configured."""
await setup.async_setup_component(hass, "persistent_notification", {})
config_entry = MockConfigEntry(
domain=DOMAIN, data={CONF_HOST: "4.5.6.7"}, unique_id="abc"
@ -463,7 +461,6 @@ async def test_zeroconf_lutron_id_already_configured(hass):
async def test_zeroconf_not_lutron_device(hass):
"""Test starting a flow from discovery when it is not a lutron device."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN,
@ -484,7 +481,7 @@ async def test_zeroconf_not_lutron_device(hass):
)
async def test_zeroconf(hass, source, tmpdir):
"""Test starting a flow from discovery."""
await setup.async_setup_component(hass, "persistent_notification", {})
hass.config.config_dir = await hass.async_add_executor_job(
tmpdir.mkdir, "tls_assets"
)

View file

@ -1,7 +1,6 @@
"""The tests for Lutron Caséta device triggers."""
import pytest
from homeassistant import setup
from homeassistant.components import automation
from homeassistant.components.device_automation.exceptions import (
InvalidDeviceAutomationConfig,
@ -186,7 +185,7 @@ async def test_get_triggers_for_invalid_device_id(hass, device_reg):
async def test_if_fires_on_button_event(hass, calls, device_reg):
"""Test for press trigger firing."""
await setup.async_setup_component(hass, "persistent_notification", {})
config_entry_id = await _async_setup_lutron_with_picos(hass, device_reg)
dr_button_devices = hass.data[DOMAIN][config_entry_id][BUTTON_DEVICES]
device_id = list(dr_button_devices)[0]
@ -230,7 +229,6 @@ async def test_if_fires_on_button_event(hass, calls, device_reg):
async def test_validate_trigger_config_no_device(hass, calls, device_reg):
"""Test for no press with no device."""
await setup.async_setup_component(hass, "persistent_notification", {})
assert await async_setup_component(
hass,
@ -269,7 +267,7 @@ async def test_validate_trigger_config_no_device(hass, calls, device_reg):
async def test_validate_trigger_config_unknown_device(hass, calls, device_reg):
"""Test for no press with an unknown device."""
await setup.async_setup_component(hass, "persistent_notification", {})
config_entry_id = await _async_setup_lutron_with_picos(hass, device_reg)
dr_button_devices = hass.data[DOMAIN][config_entry_id][BUTTON_DEVICES]
device_id = list(dr_button_devices)[0]
@ -313,7 +311,6 @@ async def test_validate_trigger_config_unknown_device(hass, calls, device_reg):
async def test_validate_trigger_invalid_triggers(hass, device_reg):
"""Test for click_event with invalid triggers."""
notification_calls = async_mock_service(hass, "persistent_notification", "create")
config_entry_id = await _async_setup_lutron_with_picos(hass, device_reg)
dr_button_devices = hass.data[DOMAIN][config_entry_id][BUTTON_DEVICES]
device_id = list(dr_button_devices)[0]
@ -339,8 +336,10 @@ async def test_validate_trigger_invalid_triggers(hass, device_reg):
},
)
assert len(notification_calls) == 1
assert (
len(entity_ids := hass.states.async_entity_ids("persistent_notification")) == 1
)
assert (
"The following integrations and platforms could not be set up"
in notification_calls[0].data["message"]
in hass.states.get(entity_ids[0]).attributes["message"]
)

View file

@ -3,7 +3,7 @@ from unittest.mock import patch
import aiohttp
from homeassistant import config_entries, data_entry_flow, setup
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.mazda.config_flow import (
MazdaAccountLockedException,
MazdaAuthenticationException,
@ -179,7 +179,7 @@ async def test_form_unknown_error(hass):
async def test_reauth_flow(hass: HomeAssistant) -> None:
"""Test reauth works."""
await setup.async_setup_component(hass, "persistent_notification", {})
mock_config = MockConfigEntry(
domain=DOMAIN,
unique_id=FIXTURE_USER_INPUT[CONF_EMAIL],

View file

@ -2,7 +2,7 @@
import json
from unittest.mock import patch
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.metoffice.const import DOMAIN
from .const import (
@ -26,7 +26,6 @@ async def test_form(hass, requests_mock):
all_sites = json.dumps(mock_json["all_sites"])
requests_mock.get("/public/data/val/wxfcs/all/json/sitelist/", text=all_sites)
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -3,7 +3,7 @@ from unittest.mock import patch
from serial import SerialException
from homeassistant import config_entries, data_entry_flow, setup
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.monoprice.const import (
CONF_SOURCE_1,
CONF_SOURCE_4,
@ -25,7 +25,7 @@ CONFIG = {
async def test_form(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -8,7 +8,7 @@ from motioneye_client.client import (
MotionEyeClientRequestError,
)
from homeassistant import config_entries, data_entry_flow, setup
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.motioneye.const import (
CONF_ADMIN_PASSWORD,
CONF_ADMIN_USERNAME,
@ -30,7 +30,7 @@ _LOGGER = logging.getLogger(__name__)
async def test_user_success(hass: HomeAssistant) -> None:
"""Test successful user flow."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -73,7 +73,7 @@ async def test_user_success(hass: HomeAssistant) -> None:
async def test_hassio_success(hass: HomeAssistant) -> None:
"""Test successful Supervisor flow."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN,
data={"addon": "motionEye", "url": TEST_URL},
@ -157,7 +157,7 @@ async def test_user_invalid_auth(hass: HomeAssistant) -> None:
async def test_user_invalid_url(hass: HomeAssistant) -> None:
"""Test invalid url is handled correctly."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -254,7 +254,6 @@ async def test_reauth(hass: HomeAssistant) -> None:
config_entry = create_mock_motioneye_config_entry(hass, data=config_data)
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={
@ -312,7 +311,6 @@ async def test_duplicate(hass: HomeAssistant) -> None:
# Now do the usual config entry process, and verify it is rejected.
create_mock_motioneye_config_entry(hass, data=config_data)
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -393,7 +391,6 @@ async def test_hassio_abort_if_already_in_progress(hass: HomeAssistant) -> None:
async def test_hassio_clean_up_on_user_flow(hass: HomeAssistant) -> None:
"""Test Supervisor discovered flow is clean up when doing user flow."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN,

View file

@ -3396,7 +3396,7 @@ async def test_reloadable(hass, mqtt_mock):
await hass.async_block_till_done()
assert hass.states.get("light.test")
assert len(hass.states.async_all()) == 1
assert len(hass.states.async_all("light")) == 1
yaml_path = path.join(
_get_fixtures_base_path(),
@ -3412,7 +3412,7 @@ async def test_reloadable(hass, mqtt_mock):
)
await hass.async_block_till_done()
assert len(hass.states.async_all()) == 1
assert len(hass.states.async_all("light")) == 1
assert hass.states.get("light.test") is None
assert hass.states.get("light.reload")

View file

@ -41,7 +41,7 @@ async def test_form_user(hass):
async def test_form_user_only_once(hass):
"""Test we can setup by the user only once."""
MockConfigEntry(domain=DOMAIN).add_to_hass(hass)
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -5,14 +5,14 @@ from unittest.mock import patch
import aiohttp
import pytest
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.mutesync.const import DOMAIN
from homeassistant.core import HomeAssistant
async def test_form(hass: HomeAssistant) -> None:
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -3,7 +3,7 @@ from unittest.mock import patch
from pymyq.errors import InvalidCredentialsError, MyQError
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.myq.const import DOMAIN
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
@ -12,7 +12,7 @@ from tests.common import MockConfigEntry
async def test_form_user(hass):
"""Test we get the user form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -6,7 +6,7 @@ from unittest.mock import patch
import pytest
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.mysensors.const import (
CONF_BAUD_RATE,
CONF_DEVICE,
@ -34,7 +34,7 @@ async def get_form(
hass: HomeAssistant, gatway_type: ConfGatewayType, expected_step_id: str
) -> FlowResult:
"""Get a form for the given gateway type."""
await setup.async_setup_component(hass, "persistent_notification", {})
stepuser = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -92,7 +92,7 @@ async def test_config_mqtt(hass: HomeAssistant, mqtt: None) -> None:
async def test_missing_mqtt(hass: HomeAssistant) -> None:
"""Test configuring a mqtt gateway without mqtt integration setup."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -442,7 +442,6 @@ async def test_config_invalid(
)
async def test_import(hass: HomeAssistant, mqtt: None, user_input: dict) -> None:
"""Test importing a gateway."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch("sys.platform", "win32"), patch(
"homeassistant.components.mysensors.config_flow.try_connect", return_value=True
@ -738,7 +737,6 @@ async def test_duplicate(
expected_result: tuple[str, str] | None,
) -> None:
"""Test duplicate detection."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch("sys.platform", "win32"), patch(
"homeassistant.components.mysensors.config_flow.try_connect", return_value=True

View file

@ -324,7 +324,7 @@ async def test_import(
expected_config_entry_data: list[dict[str, Any]],
) -> None:
"""Test importing a gateway."""
await async_setup_component(hass, "persistent_notification", {})
with patch("sys.platform", "win32"), patch(
"homeassistant.components.mysensors.config_flow.try_connect", return_value=True
), patch(

View file

@ -5,7 +5,7 @@ from nexia.const import BRAND_ASAIR, BRAND_NEXIA
import pytest
from requests.exceptions import ConnectTimeout, HTTPError
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.nexia.const import CONF_BRAND, DOMAIN
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
@ -13,7 +13,7 @@ from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
@pytest.mark.parametrize("brand", [BRAND_ASAIR, BRAND_NEXIA])
async def test_form(hass, brand):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -3,7 +3,7 @@ from unittest.mock import patch
from aiohttp import ClientConnectionError, ClientResponseError
from homeassistant import config_entries, data_entry_flow, setup
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.nightscout.const import DOMAIN
from homeassistant.components.nightscout.utils import hash_from_url
from homeassistant.const import CONF_URL
@ -20,7 +20,7 @@ CONFIG = {CONF_URL: "https://some.url:1234"}
async def test_form(hass):
"""Test we get the user initiated form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -3,7 +3,7 @@ from unittest.mock import patch
import pytest
from homeassistant import config_entries, data_entry_flow, setup
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.device_tracker.const import (
CONF_CONSIDER_HOME,
CONF_SCAN_INTERVAL,
@ -25,7 +25,7 @@ from tests.common import MockConfigEntry
)
async def test_form(hass: HomeAssistant, hosts: str, mock_get_source_ip) -> None:
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -64,7 +64,7 @@ async def test_form(hass: HomeAssistant, hosts: str, mock_get_source_ip) -> None
async def test_form_range(hass: HomeAssistant, mock_get_source_ip) -> None:
"""Test we get the form and can take an ip range."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -100,7 +100,7 @@ async def test_form_range(hass: HomeAssistant, mock_get_source_ip) -> None:
async def test_form_invalid_hosts(hass: HomeAssistant, mock_get_source_ip) -> None:
"""Test invalid hosts passed in."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -124,7 +124,7 @@ async def test_form_invalid_hosts(hass: HomeAssistant, mock_get_source_ip) -> No
async def test_form_already_configured(hass: HomeAssistant, mock_get_source_ip) -> None:
"""Test duplicate host list."""
await setup.async_setup_component(hass, "persistent_notification", {})
config_entry = MockConfigEntry(
domain=DOMAIN,
data={},
@ -159,7 +159,7 @@ async def test_form_already_configured(hass: HomeAssistant, mock_get_source_ip)
async def test_form_invalid_excludes(hass: HomeAssistant, mock_get_source_ip) -> None:
"""Test invalid excludes passed in."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -245,7 +245,7 @@ async def test_options_flow(hass: HomeAssistant, mock_get_source_ip) -> None:
async def test_import(hass: HomeAssistant, mock_get_source_ip) -> None:
"""Test we can import from yaml."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"homeassistant.components.nmap_tracker.async_setup_entry",
return_value=True,
@ -293,7 +293,6 @@ async def test_import_aborts_if_matching(
},
)
config_entry.add_to_hass(hass)
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN,

View file

@ -87,7 +87,6 @@ class NotificationService(notify.BaseNotificationService):
async def test_warn_template(hass, caplog):
"""Test warning when template used."""
assert await async_setup_component(hass, "notify", {})
assert await async_setup_component(hass, "persistent_notification", {})
await hass.services.async_call(
"notify",

View file

@ -3,7 +3,7 @@ from unittest.mock import MagicMock, patch
import requests
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.nuheat.const import CONF_SERIAL_NUMBER, DOMAIN
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, HTTP_INTERNAL_SERVER_ERROR
@ -12,7 +12,7 @@ from .mocks import _get_mock_thermostat_run
async def test_form_user(hass):
"""Test we get the form with user source."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -1,5 +1,4 @@
"""Mockup Nuki device."""
from homeassistant import setup
from tests.common import MockConfigEntry
@ -14,7 +13,7 @@ MOCK_INFO = {"ids": {"hardwareId": HW_ID}}
async def setup_nuki_integration(hass):
"""Create the Nuki device."""
await setup.async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain="nuki",
unique_id=HW_ID,

View file

@ -4,7 +4,7 @@ from unittest.mock import patch
from pynuki.bridge import InvalidCredentialsException
from requests.exceptions import RequestException
from homeassistant import config_entries, data_entry_flow, setup
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.dhcp import HOSTNAME, IP_ADDRESS, MAC_ADDRESS
from homeassistant.components.nuki.const import DOMAIN
from homeassistant.const import CONF_TOKEN
@ -14,7 +14,7 @@ from .mock import HOST, MAC, MOCK_INFO, NAME, setup_nuki_integration
async def test_form(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -53,7 +53,6 @@ async def test_form(hass):
async def test_import(hass):
"""Test that the import works."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"homeassistant.components.nuki.config_flow.NukiBridge.info",

View file

@ -2,7 +2,7 @@
from unittest.mock import patch
from homeassistant import config_entries, data_entry_flow, setup
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.nut.const import DOMAIN
from homeassistant.const import CONF_RESOURCES, CONF_SCAN_INTERVAL
@ -73,7 +73,7 @@ async def test_form_zeroconf(hass):
async def test_form_user_one_ups(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
@ -128,7 +128,6 @@ async def test_form_user_one_ups(hass):
async def test_form_user_multiple_ups(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
config_entry = MockConfigEntry(
domain=DOMAIN,
@ -210,7 +209,6 @@ async def test_form_user_one_ups_with_ignored_entry(hass):
)
ignored_entry.add_to_hass(hass)
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -3,7 +3,7 @@ from unittest.mock import patch
import aiohttp
from homeassistant import config_entries, setup
from homeassistant import config_entries
from homeassistant.components.nws.const import DOMAIN
@ -12,7 +12,6 @@ async def test_form(hass, mock_simple_nws_config):
hass.config.latitude = 35
hass.config.longitude = -90
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)

View file

@ -11,7 +11,6 @@ from homeassistant.data_entry_flow import (
RESULT_TYPE_CREATE_ENTRY,
RESULT_TYPE_FORM,
)
from homeassistant.setup import async_setup_component
from . import (
ENTRY_CONFIG,
@ -28,7 +27,6 @@ from tests.common import MockConfigEntry
async def test_user_form(hass):
"""Test we get the user initiated form."""
await async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
@ -53,7 +51,6 @@ async def test_user_form(hass):
async def test_user_form_show_advanced_options(hass):
"""Test we get the user initiated form with advanced options shown."""
await async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER, "show_advanced_options": True}

Some files were not shown because too many files have changed in this diff Show more