Add type hints to integration tests (m-p) (#87705)
parent
6551eb168d
commit
3abf7ea18a
|
@ -5,12 +5,13 @@ from mullvad_api import MullvadAPIError
|
|||
|
||||
from homeassistant import config_entries, setup
|
||||
from homeassistant.components.mullvad.const import DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_form_user(hass):
|
||||
async def test_form_user(hass: HomeAssistant) -> None:
|
||||
"""Test we can setup by the user."""
|
||||
await setup.async_setup_component(hass, DOMAIN, {})
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -38,7 +39,7 @@ async def test_form_user(hass):
|
|||
assert len(mock_mullvad_api.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_form_user_only_once(hass):
|
||||
async def test_form_user_only_once(hass: HomeAssistant) -> None:
|
||||
"""Test we can setup by the user only once."""
|
||||
MockConfigEntry(domain=DOMAIN).add_to_hass(hass)
|
||||
|
||||
|
@ -49,7 +50,7 @@ async def test_form_user_only_once(hass):
|
|||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_connection_error(hass):
|
||||
async def test_connection_error(hass: HomeAssistant) -> None:
|
||||
"""Test we show an error when we have trouble connecting."""
|
||||
await setup.async_setup_component(hass, DOMAIN, {})
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -70,7 +71,7 @@ async def test_connection_error(hass):
|
|||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
async def test_unknown_error(hass):
|
||||
async def test_unknown_error(hass: HomeAssistant) -> None:
|
||||
"""Test we show an error when an unknown error occurs."""
|
||||
await setup.async_setup_component(hass, DOMAIN, {})
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
"""Test the my init."""
|
||||
|
||||
from unittest import mock
|
||||
|
||||
from homeassistant.components.my import URL_PATH
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
|
||||
async def test_setup(hass):
|
||||
async def test_setup(hass: HomeAssistant) -> None:
|
||||
"""Test setup."""
|
||||
with mock.patch(
|
||||
"homeassistant.components.frontend.async_register_built_in_panel"
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
"""The scene tests for the myq platform."""
|
||||
|
||||
from homeassistant.const import STATE_ON
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .util import async_init_integration
|
||||
|
||||
|
||||
async def test_create_binary_sensors(hass):
|
||||
async def test_create_binary_sensors(hass: HomeAssistant) -> None:
|
||||
"""Test creation of binary_sensors."""
|
||||
|
||||
await async_init_integration(hass)
|
||||
|
|
|
@ -6,11 +6,12 @@ from pymyq.errors import InvalidCredentialsError, MyQError
|
|||
from homeassistant import config_entries
|
||||
from homeassistant.components.myq.const import DOMAIN
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_form_user(hass):
|
||||
async def test_form_user(hass: HomeAssistant) -> None:
|
||||
"""Test we get the user form."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -41,7 +42,7 @@ async def test_form_user(hass):
|
|||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_form_invalid_auth(hass):
|
||||
async def test_form_invalid_auth(hass: HomeAssistant) -> None:
|
||||
"""Test we handle invalid auth."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -60,7 +61,7 @@ async def test_form_invalid_auth(hass):
|
|||
assert result2["errors"] == {"password": "invalid_auth"}
|
||||
|
||||
|
||||
async def test_form_cannot_connect(hass):
|
||||
async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
"""Test we handle cannot connect error."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -79,7 +80,7 @@ async def test_form_cannot_connect(hass):
|
|||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
async def test_form_unknown_exception(hass):
|
||||
async def test_form_unknown_exception(hass: HomeAssistant) -> None:
|
||||
"""Test we handle unknown exceptions."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -98,7 +99,7 @@ async def test_form_unknown_exception(hass):
|
|||
assert result2["errors"] == {"base": "unknown"}
|
||||
|
||||
|
||||
async def test_reauth(hass):
|
||||
async def test_reauth(hass: HomeAssistant) -> None:
|
||||
"""Test we can reauth."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
"""The scene tests for the myq platform."""
|
||||
|
||||
from homeassistant.const import STATE_CLOSED
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .util import async_init_integration
|
||||
|
||||
|
||||
async def test_create_covers(hass):
|
||||
async def test_create_covers(hass: HomeAssistant) -> None:
|
||||
"""Test creation of covers."""
|
||||
|
||||
await async_init_integration(hass)
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
"""The scene tests for the myq platform."""
|
||||
from homeassistant.components.light import ColorMode
|
||||
from homeassistant.const import STATE_OFF, STATE_ON
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .util import async_init_integration
|
||||
|
||||
|
||||
async def test_create_lights(hass):
|
||||
async def test_create_lights(hass: HomeAssistant) -> None:
|
||||
"""Test creation of lights."""
|
||||
|
||||
await async_init_integration(hass)
|
||||
|
|
|
@ -3,6 +3,7 @@ import logging
|
|||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.components import mythicbeastsdns
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -20,7 +21,7 @@ async def mbddns_update_mock(domain, password, host, ttl=60, session=None):
|
|||
|
||||
|
||||
@patch("mbddns.update", new=mbddns_update_mock)
|
||||
async def test_update(hass):
|
||||
async def test_update(hass: HomeAssistant) -> None:
|
||||
"""Run with correct values and check true is returned."""
|
||||
result = await async_setup_component(
|
||||
hass,
|
||||
|
@ -37,7 +38,7 @@ async def test_update(hass):
|
|||
|
||||
|
||||
@patch("mbddns.update", new=mbddns_update_mock)
|
||||
async def test_update_fails_if_wrong_token(hass):
|
||||
async def test_update_fails_if_wrong_token(hass: HomeAssistant) -> None:
|
||||
"""Run with incorrect token and check false is returned."""
|
||||
result = await async_setup_component(
|
||||
hass,
|
||||
|
@ -54,7 +55,7 @@ async def test_update_fails_if_wrong_token(hass):
|
|||
|
||||
|
||||
@patch("mbddns.update", new=mbddns_update_mock)
|
||||
async def test_update_fails_if_invalid_host(hass):
|
||||
async def test_update_fails_if_invalid_host(hass: HomeAssistant) -> None:
|
||||
"""Run with invalid characters in host and check false is returned."""
|
||||
result = await async_setup_component(
|
||||
hass,
|
||||
|
|
|
@ -3,13 +3,14 @@ from unittest.mock import patch
|
|||
|
||||
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, ButtonDeviceClass
|
||||
from homeassistant.const import ATTR_DEVICE_CLASS, ATTR_ENTITY_ID, STATE_UNKNOWN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
from . import init_integration
|
||||
|
||||
|
||||
async def test_button(hass):
|
||||
async def test_button(hass: HomeAssistant) -> None:
|
||||
"""Test states of the button."""
|
||||
registry = er.async_get(hass)
|
||||
|
||||
|
@ -25,7 +26,7 @@ async def test_button(hass):
|
|||
assert entry.unique_id == "aa:bb:cc:dd:ee:ff-restart"
|
||||
|
||||
|
||||
async def test_button_press(hass):
|
||||
async def test_button_press(hass: HomeAssistant) -> None:
|
||||
"""Test button press."""
|
||||
await init_integration(hass)
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ from homeassistant import data_entry_flow
|
|||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.nam.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER, SOURCE_ZEROCONF
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
@ -27,7 +28,7 @@ DEVICE_CONFIG = {"www_basicauth_enabled": False}
|
|||
DEVICE_CONFIG_AUTH = {"www_basicauth_enabled": True}
|
||||
|
||||
|
||||
async def test_form_create_entry_without_auth(hass):
|
||||
async def test_form_create_entry_without_auth(hass: HomeAssistant) -> None:
|
||||
"""Test that the user step without auth works."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
|
@ -57,7 +58,7 @@ async def test_form_create_entry_without_auth(hass):
|
|||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_form_create_entry_with_auth(hass):
|
||||
async def test_form_create_entry_with_auth(hass: HomeAssistant) -> None:
|
||||
"""Test that the user step with auth works."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
|
@ -97,7 +98,7 @@ async def test_form_create_entry_with_auth(hass):
|
|||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_reauth_successful(hass):
|
||||
async def test_reauth_successful(hass: HomeAssistant) -> None:
|
||||
"""Test starting a reauthentication flow."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -132,7 +133,7 @@ async def test_reauth_successful(hass):
|
|||
assert result["reason"] == "reauth_successful"
|
||||
|
||||
|
||||
async def test_reauth_unsuccessful(hass):
|
||||
async def test_reauth_unsuccessful(hass: HomeAssistant) -> None:
|
||||
"""Test starting a reauthentication flow."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -228,7 +229,7 @@ async def test_form_errors(hass, error):
|
|||
assert result["errors"] == {"base": base_error}
|
||||
|
||||
|
||||
async def test_form_abort(hass):
|
||||
async def test_form_abort(hass: HomeAssistant) -> None:
|
||||
"""Test we handle abort after error."""
|
||||
with patch(
|
||||
"homeassistant.components.nam.NettigoAirMonitor.async_check_credentials",
|
||||
|
@ -247,7 +248,7 @@ async def test_form_abort(hass):
|
|||
assert result["reason"] == "device_unsupported"
|
||||
|
||||
|
||||
async def test_form_already_configured(hass):
|
||||
async def test_form_already_configured(hass: HomeAssistant) -> None:
|
||||
"""Test that errors are shown when duplicates are added."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN, unique_id="aa:bb:cc:dd:ee:ff", data=VALID_CONFIG
|
||||
|
@ -277,7 +278,7 @@ async def test_form_already_configured(hass):
|
|||
assert entry.data["host"] == "1.1.1.1"
|
||||
|
||||
|
||||
async def test_zeroconf(hass):
|
||||
async def test_zeroconf(hass: HomeAssistant) -> None:
|
||||
"""Test we get the form."""
|
||||
with patch(
|
||||
"homeassistant.components.nam.NettigoAirMonitor.async_check_credentials",
|
||||
|
@ -318,7 +319,7 @@ async def test_zeroconf(hass):
|
|||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_zeroconf_with_auth(hass):
|
||||
async def test_zeroconf_with_auth(hass: HomeAssistant) -> None:
|
||||
"""Test that the zeroconf step with auth works."""
|
||||
with patch(
|
||||
"homeassistant.components.nam.NettigoAirMonitor.async_check_credentials",
|
||||
|
@ -366,7 +367,7 @@ async def test_zeroconf_with_auth(hass):
|
|||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_zeroconf_host_already_configured(hass):
|
||||
async def test_zeroconf_host_already_configured(hass: HomeAssistant) -> None:
|
||||
"""Test that errors are shown when host is already configured."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN, unique_id="aa:bb:cc:dd:ee:ff", data=VALID_CONFIG
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
"""Test NAM diagnostics."""
|
||||
import json
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import init_integration
|
||||
|
||||
from tests.common import load_fixture
|
||||
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||
from tests.typing import ClientSessionGenerator
|
||||
|
||||
|
||||
async def test_entry_diagnostics(hass, hass_client):
|
||||
async def test_entry_diagnostics(
|
||||
hass: HomeAssistant, hass_client: ClientSessionGenerator
|
||||
) -> None:
|
||||
"""Test config entry diagnostics."""
|
||||
entry = await init_integration(hass)
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ from homeassistant.components.air_quality import DOMAIN as AIR_QUALITY_PLATFORM
|
|||
from homeassistant.components.nam.const import DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import STATE_UNAVAILABLE
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from . import init_integration
|
||||
|
@ -14,7 +15,7 @@ from . import init_integration
|
|||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_async_setup_entry(hass):
|
||||
async def test_async_setup_entry(hass: HomeAssistant) -> None:
|
||||
"""Test a successful setup entry."""
|
||||
await init_integration(hass)
|
||||
|
||||
|
@ -24,7 +25,7 @@ async def test_async_setup_entry(hass):
|
|||
assert state.state == "11.0"
|
||||
|
||||
|
||||
async def test_config_not_ready(hass):
|
||||
async def test_config_not_ready(hass: HomeAssistant) -> None:
|
||||
"""Test for setup failure if the connection to the device fails."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -42,7 +43,7 @@ async def test_config_not_ready(hass):
|
|||
assert entry.state is ConfigEntryState.SETUP_RETRY
|
||||
|
||||
|
||||
async def test_config_not_ready_while_checking_credentials(hass):
|
||||
async def test_config_not_ready_while_checking_credentials(hass: HomeAssistant) -> None:
|
||||
"""Test for setup failure if the connection fails while checking credentials."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -60,7 +61,7 @@ async def test_config_not_ready_while_checking_credentials(hass):
|
|||
assert entry.state is ConfigEntryState.SETUP_RETRY
|
||||
|
||||
|
||||
async def test_config_auth_failed(hass):
|
||||
async def test_config_auth_failed(hass: HomeAssistant) -> None:
|
||||
"""Test for setup failure if the auth fails."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -78,7 +79,7 @@ async def test_config_auth_failed(hass):
|
|||
assert entry.state is ConfigEntryState.SETUP_ERROR
|
||||
|
||||
|
||||
async def test_unload_entry(hass):
|
||||
async def test_unload_entry(hass: HomeAssistant) -> None:
|
||||
"""Test successful unload of entry."""
|
||||
entry = await init_integration(hass)
|
||||
|
||||
|
@ -92,7 +93,7 @@ async def test_unload_entry(hass):
|
|||
assert not hass.data.get(DOMAIN)
|
||||
|
||||
|
||||
async def test_remove_air_quality_entities(hass):
|
||||
async def test_remove_air_quality_entities(hass: HomeAssistant) -> None:
|
||||
"""Test remove air_quality entities from registry."""
|
||||
registry = er.async_get(hass)
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ from homeassistant.const import (
|
|||
UnitOfPressure,
|
||||
UnitOfTemperature,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util.dt import utcnow
|
||||
|
@ -34,7 +35,7 @@ from . import INCOMPLETE_NAM_DATA, init_integration, nam_data
|
|||
from tests.common import async_fire_time_changed
|
||||
|
||||
|
||||
async def test_sensor(hass):
|
||||
async def test_sensor(hass: HomeAssistant) -> None:
|
||||
"""Test states of the air_quality."""
|
||||
registry = er.async_get(hass)
|
||||
|
||||
|
@ -466,7 +467,7 @@ async def test_sensor(hass):
|
|||
assert entry.unique_id == "aa:bb:cc:dd:ee:ff-mhz14a_carbon_dioxide"
|
||||
|
||||
|
||||
async def test_sensor_disabled(hass):
|
||||
async def test_sensor_disabled(hass: HomeAssistant) -> None:
|
||||
"""Test sensor disabled by default."""
|
||||
await init_integration(hass)
|
||||
registry = er.async_get(hass)
|
||||
|
@ -486,7 +487,7 @@ async def test_sensor_disabled(hass):
|
|||
assert updated_entry.disabled is False
|
||||
|
||||
|
||||
async def test_incompleta_data_after_device_restart(hass):
|
||||
async def test_incompleta_data_after_device_restart(hass: HomeAssistant) -> None:
|
||||
"""Test states of the air_quality after device restart."""
|
||||
await init_integration(hass)
|
||||
|
||||
|
@ -510,7 +511,7 @@ async def test_incompleta_data_after_device_restart(hass):
|
|||
assert state.state == STATE_UNAVAILABLE
|
||||
|
||||
|
||||
async def test_availability(hass):
|
||||
async def test_availability(hass: HomeAssistant) -> None:
|
||||
"""Ensure that we mark the entities unavailable correctly when device causes an error."""
|
||||
await init_integration(hass)
|
||||
|
||||
|
@ -546,7 +547,7 @@ async def test_availability(hass):
|
|||
assert state.state == "7.6"
|
||||
|
||||
|
||||
async def test_manual_update_entity(hass):
|
||||
async def test_manual_update_entity(hass: HomeAssistant) -> None:
|
||||
"""Test manual update entity via service homeasasistant/update_entity."""
|
||||
await init_integration(hass)
|
||||
|
||||
|
@ -567,7 +568,7 @@ async def test_manual_update_entity(hass):
|
|||
assert mock_get_data.call_count == 1
|
||||
|
||||
|
||||
async def test_unique_id_migration(hass):
|
||||
async def test_unique_id_migration(hass: HomeAssistant) -> None:
|
||||
"""Test states of the unique_id migration."""
|
||||
registry = er.async_get(hass)
|
||||
|
||||
|
|
|
@ -4,10 +4,12 @@ from datetime import timedelta
|
|||
import pytest
|
||||
|
||||
from homeassistant.components import namecheapdns
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util.dt import utcnow
|
||||
|
||||
from tests.common import async_fire_time_changed
|
||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||
|
||||
HOST = "test"
|
||||
DOMAIN = "bla"
|
||||
|
@ -32,7 +34,7 @@ def setup_namecheapdns(hass, aioclient_mock):
|
|||
)
|
||||
|
||||
|
||||
async def test_setup(hass, aioclient_mock):
|
||||
async def test_setup(hass: HomeAssistant, aioclient_mock: AiohttpClientMocker) -> None:
|
||||
"""Test setup works if update passes."""
|
||||
aioclient_mock.get(
|
||||
namecheapdns.UPDATE_URL,
|
||||
|
@ -53,7 +55,9 @@ async def test_setup(hass, aioclient_mock):
|
|||
assert aioclient_mock.call_count == 2
|
||||
|
||||
|
||||
async def test_setup_fails_if_update_fails(hass, aioclient_mock):
|
||||
async def test_setup_fails_if_update_fails(
|
||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||
) -> None:
|
||||
"""Test setup fails if first update fails."""
|
||||
aioclient_mock.get(
|
||||
namecheapdns.UPDATE_URL,
|
||||
|
|
|
@ -7,7 +7,6 @@ for token refresh and for testing:
|
|||
|
||||
The tests below exercise both cases during integration setup.
|
||||
"""
|
||||
|
||||
import time
|
||||
from unittest.mock import patch
|
||||
|
||||
|
@ -15,6 +14,7 @@ import pytest
|
|||
|
||||
from homeassistant.components.nest import DOMAIN
|
||||
from homeassistant.components.nest.const import API_URL, OAUTH2_TOKEN, SDM_SCOPES
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util import dt
|
||||
|
||||
|
@ -29,6 +29,8 @@ from .common import (
|
|||
create_config_entry,
|
||||
)
|
||||
|
||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||
|
||||
FAKE_UPDATED_TOKEN = "fake-updated-token"
|
||||
|
||||
|
||||
|
@ -39,7 +41,7 @@ async def async_setup_sdm(hass):
|
|||
|
||||
|
||||
@pytest.mark.parametrize("nest_test_config", [TEST_CONFIGFLOW_YAML_ONLY])
|
||||
async def test_auth(hass, aioclient_mock):
|
||||
async def test_auth(hass: HomeAssistant, aioclient_mock: AiohttpClientMocker) -> None:
|
||||
"""Exercise authentication library creates valid credentials."""
|
||||
|
||||
expiration_time = time.time() + 86400
|
||||
|
@ -91,7 +93,9 @@ async def test_auth(hass, aioclient_mock):
|
|||
|
||||
|
||||
@pytest.mark.parametrize("nest_test_config", [TEST_CONFIGFLOW_YAML_ONLY])
|
||||
async def test_auth_expired_token(hass, aioclient_mock):
|
||||
async def test_auth_expired_token(
|
||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||
) -> None:
|
||||
"""Verify behavior of an expired token."""
|
||||
|
||||
expiration_time = time.time() - 86400
|
||||
|
|
|
@ -4,6 +4,7 @@ from unittest.mock import patch
|
|||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant.components.nest import DOMAIN, config_flow
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from .common import TEST_CONFIG_LEGACY
|
||||
|
@ -13,7 +14,7 @@ from tests.common import MockConfigEntry
|
|||
CONFIG = TEST_CONFIG_LEGACY.config
|
||||
|
||||
|
||||
async def test_abort_if_single_instance_allowed(hass):
|
||||
async def test_abort_if_single_instance_allowed(hass: HomeAssistant) -> None:
|
||||
"""Test we abort if Nest is already setup."""
|
||||
existing_entry = MockConfigEntry(domain=DOMAIN, data={})
|
||||
existing_entry.add_to_hass(hass)
|
||||
|
@ -28,7 +29,7 @@ async def test_abort_if_single_instance_allowed(hass):
|
|||
assert result["reason"] == "single_instance_allowed"
|
||||
|
||||
|
||||
async def test_full_flow_implementation(hass):
|
||||
async def test_full_flow_implementation(hass: HomeAssistant) -> None:
|
||||
"""Test registering an implementation and finishing flow works."""
|
||||
assert await async_setup_component(hass, DOMAIN, CONFIG)
|
||||
await hass.async_block_till_done()
|
||||
|
@ -75,7 +76,7 @@ async def test_full_flow_implementation(hass):
|
|||
assert result["title"] == "Nest (via configuration.yaml)"
|
||||
|
||||
|
||||
async def test_not_pick_implementation_if_only_one(hass):
|
||||
async def test_not_pick_implementation_if_only_one(hass: HomeAssistant) -> None:
|
||||
"""Test we pick the default implementation when registered."""
|
||||
assert await async_setup_component(hass, DOMAIN, CONFIG)
|
||||
await hass.async_block_till_done()
|
||||
|
@ -87,7 +88,7 @@ async def test_not_pick_implementation_if_only_one(hass):
|
|||
assert result["step_id"] == "link"
|
||||
|
||||
|
||||
async def test_abort_if_timeout_generating_auth_url(hass):
|
||||
async def test_abort_if_timeout_generating_auth_url(hass: HomeAssistant) -> None:
|
||||
"""Test we abort if generating authorize url fails."""
|
||||
with patch(
|
||||
"homeassistant.components.nest.legacy.local_auth.generate_auth_url",
|
||||
|
@ -103,7 +104,7 @@ async def test_abort_if_timeout_generating_auth_url(hass):
|
|||
assert result["reason"] == "authorize_url_timeout"
|
||||
|
||||
|
||||
async def test_abort_if_exception_generating_auth_url(hass):
|
||||
async def test_abort_if_exception_generating_auth_url(hass: HomeAssistant) -> None:
|
||||
"""Test we abort if generating authorize url blows up."""
|
||||
with patch(
|
||||
"homeassistant.components.nest.legacy.local_auth.generate_auth_url",
|
||||
|
@ -119,7 +120,7 @@ async def test_abort_if_exception_generating_auth_url(hass):
|
|||
assert result["reason"] == "unknown_authorize_url_generation"
|
||||
|
||||
|
||||
async def test_verify_code_timeout(hass):
|
||||
async def test_verify_code_timeout(hass: HomeAssistant) -> None:
|
||||
"""Test verify code timing out."""
|
||||
assert await async_setup_component(hass, DOMAIN, CONFIG)
|
||||
await hass.async_block_till_done()
|
||||
|
@ -142,7 +143,7 @@ async def test_verify_code_timeout(hass):
|
|||
assert result["errors"] == {"code": "timeout"}
|
||||
|
||||
|
||||
async def test_verify_code_invalid(hass):
|
||||
async def test_verify_code_invalid(hass: HomeAssistant) -> None:
|
||||
"""Test verify code invalid."""
|
||||
assert await async_setup_component(hass, DOMAIN, CONFIG)
|
||||
await hass.async_block_till_done()
|
||||
|
@ -165,7 +166,7 @@ async def test_verify_code_invalid(hass):
|
|||
assert result["errors"] == {"code": "invalid_pin"}
|
||||
|
||||
|
||||
async def test_verify_code_unknown_error(hass):
|
||||
async def test_verify_code_unknown_error(hass: HomeAssistant) -> None:
|
||||
"""Test verify code unknown error."""
|
||||
assert await async_setup_component(hass, DOMAIN, CONFIG)
|
||||
await hass.async_block_till_done()
|
||||
|
@ -188,7 +189,7 @@ async def test_verify_code_unknown_error(hass):
|
|||
assert result["errors"] == {"code": "unknown"}
|
||||
|
||||
|
||||
async def test_verify_code_exception(hass):
|
||||
async def test_verify_code_exception(hass: HomeAssistant) -> None:
|
||||
"""Test verify code blows up."""
|
||||
assert await async_setup_component(hass, DOMAIN, CONFIG)
|
||||
await hass.async_block_till_done()
|
||||
|
@ -211,7 +212,7 @@ async def test_verify_code_exception(hass):
|
|||
assert result["errors"] == {"code": "internal_error"}
|
||||
|
||||
|
||||
async def test_step_import(hass):
|
||||
async def test_step_import(hass: HomeAssistant) -> None:
|
||||
"""Test that we trigger import when configuring with client."""
|
||||
with patch("os.path.isfile", return_value=False):
|
||||
assert await async_setup_component(hass, DOMAIN, CONFIG)
|
||||
|
@ -224,7 +225,7 @@ async def test_step_import(hass):
|
|||
assert result["step_id"] == "link"
|
||||
|
||||
|
||||
async def test_step_import_with_token_cache(hass):
|
||||
async def test_step_import_with_token_cache(hass: HomeAssistant) -> None:
|
||||
"""Test that we import existing token cache."""
|
||||
with patch("os.path.isfile", return_value=True), patch(
|
||||
"homeassistant.components.nest.config_flow.load_json",
|
||||
|
|
|
@ -14,6 +14,7 @@ from homeassistant.components.netatmo.const import (
|
|||
OAUTH2_TOKEN,
|
||||
)
|
||||
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import config_entry_oauth2_flow
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
@ -24,7 +25,7 @@ CLIENT_SECRET = "5678"
|
|||
VALID_CONFIG = {}
|
||||
|
||||
|
||||
async def test_abort_if_existing_entry(hass):
|
||||
async def test_abort_if_existing_entry(hass: HomeAssistant) -> None:
|
||||
"""Check flow abort when an entry already exist."""
|
||||
MockConfigEntry(domain=DOMAIN).add_to_hass(hass)
|
||||
|
||||
|
@ -110,7 +111,7 @@ async def test_full_flow(
|
|||
assert len(mock_setup.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_option_flow(hass):
|
||||
async def test_option_flow(hass: HomeAssistant) -> None:
|
||||
"""Test config flow options."""
|
||||
valid_option = {
|
||||
"lat_ne": 32.91336,
|
||||
|
@ -168,7 +169,7 @@ async def test_option_flow(hass):
|
|||
assert config_entry.options[CONF_WEATHER_AREAS]["Home"][k] == v
|
||||
|
||||
|
||||
async def test_option_flow_wrong_coordinates(hass):
|
||||
async def test_option_flow_wrong_coordinates(hass: HomeAssistant) -> None:
|
||||
"""Test config flow options with mixed up coordinates."""
|
||||
valid_option = {
|
||||
"lat_ne": 32.1234567,
|
||||
|
|
|
@ -9,7 +9,7 @@ from pyatmo.const import ALL_SCOPES
|
|||
from homeassistant import config_entries
|
||||
from homeassistant.components.netatmo import DOMAIN
|
||||
from homeassistant.const import CONF_WEBHOOK_ID
|
||||
from homeassistant.core import CoreState
|
||||
from homeassistant.core import CoreState, HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util import dt
|
||||
|
||||
|
@ -222,7 +222,7 @@ async def test_setup_with_cloud(hass, config_entry):
|
|||
assert not hass.config_entries.async_entries(DOMAIN)
|
||||
|
||||
|
||||
async def test_setup_with_cloudhook(hass):
|
||||
async def test_setup_with_cloudhook(hass: HomeAssistant) -> None:
|
||||
"""Test if set up with active cloud subscription and cloud hook."""
|
||||
config_entry = MockConfigEntry(
|
||||
domain="netatmo",
|
||||
|
@ -341,7 +341,7 @@ async def test_setup_component_with_delay(hass, config_entry):
|
|||
mock_dropwebhook.assert_called_once()
|
||||
|
||||
|
||||
async def test_setup_component_invalid_token_scope(hass):
|
||||
async def test_setup_component_invalid_token_scope(hass: HomeAssistant) -> None:
|
||||
"""Test handling of invalid token scope."""
|
||||
config_entry = MockConfigEntry(
|
||||
domain="netatmo",
|
||||
|
|
|
@ -12,12 +12,13 @@ from homeassistant.components.media_source import (
|
|||
async_resolve_media,
|
||||
)
|
||||
from homeassistant.components.netatmo import DATA_CAMERAS, DATA_EVENTS, DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import load_fixture
|
||||
|
||||
|
||||
async def test_async_browse_media(hass):
|
||||
async def test_async_browse_media(hass: HomeAssistant) -> None:
|
||||
"""Test browse media."""
|
||||
assert await async_setup_component(hass, DOMAIN, {})
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ from homeassistant.const import (
|
|||
CONF_SSL,
|
||||
CONF_USERNAME,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
@ -209,7 +210,7 @@ async def test_abort_if_already_setup(hass, service):
|
|||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_ssdp_already_configured(hass):
|
||||
async def test_ssdp_already_configured(hass: HomeAssistant) -> None:
|
||||
"""Test ssdp abort when the router is already configured."""
|
||||
MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -235,7 +236,7 @@ async def test_ssdp_already_configured(hass):
|
|||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_ssdp_ipv6(hass):
|
||||
async def test_ssdp_ipv6(hass: HomeAssistant) -> None:
|
||||
"""Test ssdp abort when using a ipv6 address."""
|
||||
MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
"""The binary_sensor tests for the nexia platform."""
|
||||
|
||||
from homeassistant.const import STATE_OFF, STATE_ON
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .util import async_init_integration
|
||||
|
||||
|
||||
async def test_create_binary_sensors(hass):
|
||||
async def test_create_binary_sensors(hass: HomeAssistant) -> None:
|
||||
"""Test creation of binary sensors."""
|
||||
|
||||
await async_init_integration(hass)
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
"""The lock tests for the august platform."""
|
||||
from homeassistant.components.climate import HVACMode
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .util import async_init_integration
|
||||
|
||||
|
||||
async def test_climate_zones(hass):
|
||||
async def test_climate_zones(hass: HomeAssistant) -> None:
|
||||
"""Test creation climate zones."""
|
||||
|
||||
await async_init_integration(hass)
|
||||
|
|
|
@ -9,6 +9,7 @@ import pytest
|
|||
from homeassistant import config_entries
|
||||
from homeassistant.components.nexia.const import CONF_BRAND, DOMAIN
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
|
||||
@pytest.mark.parametrize("brand", [BRAND_ASAIR, BRAND_NEXIA])
|
||||
|
@ -47,7 +48,7 @@ async def test_form(hass, brand):
|
|||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_form_invalid_auth(hass):
|
||||
async def test_form_invalid_auth(hass: HomeAssistant) -> None:
|
||||
"""Test we handle invalid auth."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -72,7 +73,7 @@ async def test_form_invalid_auth(hass):
|
|||
assert result2["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
async def test_form_cannot_connect(hass):
|
||||
async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
"""Test we handle cannot connect error."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -95,7 +96,7 @@ async def test_form_cannot_connect(hass):
|
|||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
async def test_form_invalid_auth_http_401(hass):
|
||||
async def test_form_invalid_auth_http_401(hass: HomeAssistant) -> None:
|
||||
"""Test we handle invalid auth error from http 401."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -120,7 +121,7 @@ async def test_form_invalid_auth_http_401(hass):
|
|||
assert result2["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
async def test_form_cannot_connect_not_found(hass):
|
||||
async def test_form_cannot_connect_not_found(hass: HomeAssistant) -> None:
|
||||
"""Test we handle cannot connect from an http not found error."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -145,7 +146,7 @@ async def test_form_cannot_connect_not_found(hass):
|
|||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
async def test_form_broad_exception(hass):
|
||||
async def test_form_broad_exception(hass: HomeAssistant) -> None:
|
||||
"""Test we handle invalid auth error."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
"""Test august diagnostics."""
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .util import async_init_integration
|
||||
|
||||
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||
from tests.typing import ClientSessionGenerator
|
||||
|
||||
|
||||
async def test_diagnostics(hass, hass_client):
|
||||
async def test_diagnostics(
|
||||
hass: HomeAssistant, hass_client: ClientSessionGenerator
|
||||
) -> None:
|
||||
"""Test generating diagnostics for a config entry."""
|
||||
entry = await async_init_integration(hass)
|
||||
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
"""The init tests for the nexia platform."""
|
||||
|
||||
|
||||
from homeassistant.components.nexia.const import DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
from homeassistant.helpers.entity_registry import EntityRegistry
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from .util import async_init_integration
|
||||
|
||||
from tests.typing import WebSocketGenerator
|
||||
|
||||
|
||||
async def remove_device(ws_client, device_id, config_entry_id):
|
||||
"""Remove config entry from a device."""
|
||||
|
@ -23,7 +24,9 @@ async def remove_device(ws_client, device_id, config_entry_id):
|
|||
return response["success"]
|
||||
|
||||
|
||||
async def test_device_remove_devices(hass, hass_ws_client):
|
||||
async def test_device_remove_devices(
|
||||
hass: HomeAssistant, hass_ws_client: WebSocketGenerator
|
||||
) -> None:
|
||||
"""Test we can only remove a device that no longer exists."""
|
||||
await async_setup_component(hass, "config", {})
|
||||
config_entry = await async_init_integration(hass)
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
"""The scene tests for the nexia platform."""
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .util import async_init_integration
|
||||
|
||||
|
||||
async def test_automation_scenes(hass):
|
||||
async def test_automation_scenes(hass: HomeAssistant) -> None:
|
||||
"""Test creation automation scenes."""
|
||||
|
||||
await async_init_integration(hass)
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
"""The sensor tests for the nexia platform."""
|
||||
|
||||
from homeassistant.const import PERCENTAGE, UnitOfTemperature
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .util import async_init_integration
|
||||
|
||||
|
||||
async def test_create_sensors(hass):
|
||||
async def test_create_sensors(hass: HomeAssistant) -> None:
|
||||
"""Test creation of sensors."""
|
||||
|
||||
await async_init_integration(hass)
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
"""The switch tests for the nexia platform."""
|
||||
|
||||
from homeassistant.const import STATE_ON
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .util import async_init_integration
|
||||
|
||||
|
||||
async def test_hold_switch(hass):
|
||||
async def test_hold_switch(hass: HomeAssistant) -> None:
|
||||
"""Test creation of the hold switch."""
|
||||
await async_init_integration(hass)
|
||||
assert hass.states.get("switch.nick_office_hold").state == STATE_ON
|
||||
|
|
|
@ -5,6 +5,7 @@ from notifications_android_tv.notifications import ConnectError
|
|||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant.components.nfandroidtv.const import DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import (
|
||||
CONF_CONFIG_FLOW,
|
||||
|
@ -25,7 +26,7 @@ def _patch_setup():
|
|||
)
|
||||
|
||||
|
||||
async def test_flow_user(hass):
|
||||
async def test_flow_user(hass: HomeAssistant) -> None:
|
||||
"""Test user initialized flow."""
|
||||
mocked_tv = await _create_mocked_tv()
|
||||
with _patch_config_flow_tv(mocked_tv), _patch_setup():
|
||||
|
@ -42,7 +43,7 @@ async def test_flow_user(hass):
|
|||
assert result["data"] == CONF_DATA
|
||||
|
||||
|
||||
async def test_flow_user_already_configured(hass):
|
||||
async def test_flow_user_already_configured(hass: HomeAssistant) -> None:
|
||||
"""Test user initialized flow with duplicate server."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -66,7 +67,7 @@ async def test_flow_user_already_configured(hass):
|
|||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_flow_user_cannot_connect(hass):
|
||||
async def test_flow_user_cannot_connect(hass: HomeAssistant) -> None:
|
||||
"""Test user initialized flow with unreachable server."""
|
||||
mocked_tv = await _create_mocked_tv(True)
|
||||
with _patch_config_flow_tv(mocked_tv) as tvmock:
|
||||
|
@ -81,7 +82,7 @@ async def test_flow_user_cannot_connect(hass):
|
|||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
async def test_flow_user_unknown_error(hass):
|
||||
async def test_flow_user_unknown_error(hass: HomeAssistant) -> None:
|
||||
"""Test user initialized flow with unreachable server."""
|
||||
mocked_tv = await _create_mocked_tv(True)
|
||||
with _patch_config_flow_tv(mocked_tv) as tvmock:
|
||||
|
|
|
@ -8,6 +8,7 @@ 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
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import GLUCOSE_READINGS, SERVER_STATUS, SERVER_STATUS_STATUS_ONLY
|
||||
|
||||
|
@ -16,7 +17,7 @@ from tests.common import MockConfigEntry
|
|||
CONFIG = {CONF_URL: "https://some.url:1234"}
|
||||
|
||||
|
||||
async def test_form(hass):
|
||||
async def test_form(hass: HomeAssistant) -> None:
|
||||
"""Test we get the user initiated form."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -38,7 +39,7 @@ async def test_form(hass):
|
|||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_user_form_cannot_connect(hass):
|
||||
async def test_user_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
"""Test we handle cannot connect error."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -57,7 +58,7 @@ async def test_user_form_cannot_connect(hass):
|
|||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
async def test_user_form_api_key_required(hass):
|
||||
async def test_user_form_api_key_required(hass: HomeAssistant) -> None:
|
||||
"""Test we handle an unauthorized error."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -79,7 +80,7 @@ async def test_user_form_api_key_required(hass):
|
|||
assert result2["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
async def test_user_form_unexpected_exception(hass):
|
||||
async def test_user_form_unexpected_exception(hass: HomeAssistant) -> None:
|
||||
"""Test we handle unexpected exception."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -98,7 +99,7 @@ async def test_user_form_unexpected_exception(hass):
|
|||
assert result2["errors"] == {"base": "unknown"}
|
||||
|
||||
|
||||
async def test_user_form_duplicate(hass):
|
||||
async def test_user_form_duplicate(hass: HomeAssistant) -> None:
|
||||
"""Test duplicate entries."""
|
||||
with _patch_glucose_readings(), _patch_server_status():
|
||||
unique_id = hash_from_url(CONFIG[CONF_URL])
|
||||
|
|
|
@ -6,13 +6,14 @@ from aiohttp import ClientError
|
|||
from homeassistant.components.nightscout.const import DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import CONF_URL
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import init_integration
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_unload_entry(hass):
|
||||
async def test_unload_entry(hass: HomeAssistant) -> None:
|
||||
"""Test successful unload of entry."""
|
||||
entry = await init_integration(hass)
|
||||
|
||||
|
@ -26,7 +27,7 @@ async def test_unload_entry(hass):
|
|||
assert not hass.data.get(DOMAIN)
|
||||
|
||||
|
||||
async def test_async_setup_raises_entry_not_ready(hass):
|
||||
async def test_async_setup_raises_entry_not_ready(hass: HomeAssistant) -> None:
|
||||
"""Test that it throws ConfigEntryNotReady when exception occurs during setup."""
|
||||
config_entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
"""The sensor tests for the Nightscout platform."""
|
||||
|
||||
from homeassistant.components.nightscout.const import (
|
||||
ATTR_DELTA,
|
||||
ATTR_DEVICE,
|
||||
ATTR_DIRECTION,
|
||||
)
|
||||
from homeassistant.const import ATTR_DATE, ATTR_ICON, STATE_UNAVAILABLE
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import (
|
||||
GLUCOSE_READINGS,
|
||||
|
@ -15,7 +15,7 @@ from . import (
|
|||
)
|
||||
|
||||
|
||||
async def test_sensor_state(hass):
|
||||
async def test_sensor_state(hass: HomeAssistant) -> None:
|
||||
"""Test sensor state data."""
|
||||
await init_integration(hass)
|
||||
|
||||
|
@ -25,7 +25,7 @@ async def test_sensor_state(hass):
|
|||
)
|
||||
|
||||
|
||||
async def test_sensor_error(hass):
|
||||
async def test_sensor_error(hass: HomeAssistant) -> None:
|
||||
"""Test sensor state data."""
|
||||
await init_integration_unavailable(hass)
|
||||
|
||||
|
@ -33,7 +33,7 @@ async def test_sensor_error(hass):
|
|||
assert test_glucose_sensor.state == STATE_UNAVAILABLE
|
||||
|
||||
|
||||
async def test_sensor_empty_response(hass):
|
||||
async def test_sensor_empty_response(hass: HomeAssistant) -> None:
|
||||
"""Test sensor state data."""
|
||||
await init_integration_empty_response(hass)
|
||||
|
||||
|
@ -41,7 +41,7 @@ async def test_sensor_empty_response(hass):
|
|||
assert test_glucose_sensor.state == STATE_UNAVAILABLE
|
||||
|
||||
|
||||
async def test_sensor_attributes(hass):
|
||||
async def test_sensor_attributes(hass: HomeAssistant) -> None:
|
||||
"""Test sensor attributes."""
|
||||
await init_integration(hass)
|
||||
|
||||
|
|
|
@ -4,10 +4,12 @@ from datetime import timedelta
|
|||
import pytest
|
||||
|
||||
from homeassistant.components import no_ip
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util.dt import utcnow
|
||||
|
||||
from tests.common import async_fire_time_changed
|
||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||
|
||||
DOMAIN = "test.example.com"
|
||||
|
||||
|
@ -38,7 +40,7 @@ def setup_no_ip(hass, aioclient_mock):
|
|||
)
|
||||
|
||||
|
||||
async def test_setup(hass, aioclient_mock):
|
||||
async def test_setup(hass: HomeAssistant, aioclient_mock: AiohttpClientMocker) -> None:
|
||||
"""Test setup works if update passes."""
|
||||
aioclient_mock.get(UPDATE_URL, params={"hostname": DOMAIN}, text="nochg 0.0.0.0")
|
||||
|
||||
|
@ -55,7 +57,9 @@ async def test_setup(hass, aioclient_mock):
|
|||
assert aioclient_mock.call_count == 2
|
||||
|
||||
|
||||
async def test_setup_fails_if_update_fails(hass, aioclient_mock):
|
||||
async def test_setup_fails_if_update_fails(
|
||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||
) -> None:
|
||||
"""Test setup fails if first update fails."""
|
||||
aioclient_mock.get(UPDATE_URL, params={"hostname": DOMAIN}, text="nohost")
|
||||
|
||||
|
@ -68,7 +72,9 @@ async def test_setup_fails_if_update_fails(hass, aioclient_mock):
|
|||
assert aioclient_mock.call_count == 1
|
||||
|
||||
|
||||
async def test_setup_fails_if_wrong_auth(hass, aioclient_mock):
|
||||
async def test_setup_fails_if_wrong_auth(
|
||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||
) -> None:
|
||||
"""Test setup fails if first update fails through wrong authentication."""
|
||||
aioclient_mock.get(UPDATE_URL, params={"hostname": DOMAIN}, text="badauth")
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
"""The tests for notify services that change targets."""
|
||||
|
||||
import asyncio
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
import pytest
|
||||
import yaml
|
||||
|
||||
from homeassistant import config as hass_config
|
||||
|
@ -124,7 +124,9 @@ class NotificationService(notify.BaseNotificationService):
|
|||
return self.target_list
|
||||
|
||||
|
||||
async def test_warn_template(hass, caplog):
|
||||
async def test_warn_template(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Test warning when template used."""
|
||||
assert await async_setup_component(hass, "notify", {})
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
"""The tests for notify_events."""
|
||||
from homeassistant.components.notify_events.const import DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
|
||||
async def test_setup(hass):
|
||||
async def test_setup(hass: HomeAssistant) -> None:
|
||||
"""Test setup of the integration."""
|
||||
config = {"notify_events": {"token": "ABC"}}
|
||||
assert await async_setup_component(hass, DOMAIN, config)
|
||||
|
|
|
@ -5,11 +5,12 @@ from homeassistant.components.notify_events.notify import (
|
|||
ATTR_PRIORITY,
|
||||
ATTR_TOKEN,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import async_mock_service
|
||||
|
||||
|
||||
async def test_send_msg(hass):
|
||||
async def test_send_msg(hass: HomeAssistant) -> None:
|
||||
"""Test notify.events service."""
|
||||
notify_calls = async_mock_service(hass, DOMAIN, "events")
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ from homeassistant.const import (
|
|||
EVENT_HOMEASSISTANT_STOP,
|
||||
UnitOfLength,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
|
@ -89,7 +90,7 @@ def _generate_mock_feed_entry(
|
|||
return feed_entry
|
||||
|
||||
|
||||
async def test_setup(hass):
|
||||
async def test_setup(hass: HomeAssistant) -> None:
|
||||
"""Test the general setup of the platform."""
|
||||
# Set up some mock feed entries for this test.
|
||||
mock_entry_1 = _generate_mock_feed_entry(
|
||||
|
@ -226,7 +227,7 @@ async def test_setup(hass):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
async def test_setup_with_custom_location(hass):
|
||||
async def test_setup_with_custom_location(hass: HomeAssistant) -> None:
|
||||
"""Test the setup with a custom location."""
|
||||
# Set up some mock feed entries for this test.
|
||||
mock_entry_1 = _generate_mock_feed_entry("1234", "Title 1", 20.5, (-31.1, 150.1))
|
||||
|
|
|
@ -4,6 +4,7 @@ from unittest.mock import patch
|
|||
|
||||
from homeassistant.components.nuheat.const import DOMAIN
|
||||
from homeassistant.const import ATTR_ENTITY_ID
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from .mocks import (
|
||||
|
@ -18,7 +19,7 @@ from .mocks import (
|
|||
from tests.common import MockConfigEntry, async_fire_time_changed
|
||||
|
||||
|
||||
async def test_climate_thermostat_run(hass):
|
||||
async def test_climate_thermostat_run(hass: HomeAssistant) -> None:
|
||||
"""Test a thermostat with the schedule running."""
|
||||
mock_thermostat = _get_mock_thermostat_run()
|
||||
mock_nuheat = _get_mock_nuheat(get_thermostat=mock_thermostat)
|
||||
|
@ -51,7 +52,9 @@ async def test_climate_thermostat_run(hass):
|
|||
assert all(item in state.attributes.items() for item in expected_attributes.items())
|
||||
|
||||
|
||||
async def test_climate_thermostat_schedule_hold_unavailable(hass):
|
||||
async def test_climate_thermostat_schedule_hold_unavailable(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test a thermostat with the schedule hold that is offline."""
|
||||
mock_thermostat = _get_mock_thermostat_schedule_hold_unavailable()
|
||||
mock_nuheat = _get_mock_nuheat(get_thermostat=mock_thermostat)
|
||||
|
@ -81,7 +84,7 @@ async def test_climate_thermostat_schedule_hold_unavailable(hass):
|
|||
assert all(item in state.attributes.items() for item in expected_attributes.items())
|
||||
|
||||
|
||||
async def test_climate_thermostat_schedule_hold_available(hass):
|
||||
async def test_climate_thermostat_schedule_hold_available(hass: HomeAssistant) -> None:
|
||||
"""Test a thermostat with the schedule hold that is online."""
|
||||
mock_thermostat = _get_mock_thermostat_schedule_hold_available()
|
||||
mock_nuheat = _get_mock_nuheat(get_thermostat=mock_thermostat)
|
||||
|
@ -115,7 +118,7 @@ async def test_climate_thermostat_schedule_hold_available(hass):
|
|||
assert all(item in state.attributes.items() for item in expected_attributes.items())
|
||||
|
||||
|
||||
async def test_climate_thermostat_schedule_temporary_hold(hass):
|
||||
async def test_climate_thermostat_schedule_temporary_hold(hass: HomeAssistant) -> None:
|
||||
"""Test a thermostat with the temporary schedule hold that is online."""
|
||||
mock_thermostat = _get_mock_thermostat_schedule_temporary_hold()
|
||||
mock_nuheat = _get_mock_nuheat(get_thermostat=mock_thermostat)
|
||||
|
|
|
@ -7,11 +7,12 @@ import requests
|
|||
from homeassistant import config_entries
|
||||
from homeassistant.components.nuheat.const import CONF_SERIAL_NUMBER, DOMAIN
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .mocks import _get_mock_thermostat_run
|
||||
|
||||
|
||||
async def test_form_user(hass):
|
||||
async def test_form_user(hass: HomeAssistant) -> None:
|
||||
"""Test we get the form with user source."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -51,7 +52,7 @@ async def test_form_user(hass):
|
|||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_form_invalid_auth(hass):
|
||||
async def test_form_invalid_auth(hass: HomeAssistant) -> None:
|
||||
"""Test we handle invalid auth."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -92,7 +93,7 @@ async def test_form_invalid_auth(hass):
|
|||
assert result2["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
async def test_form_invalid_thermostat(hass):
|
||||
async def test_form_invalid_thermostat(hass: HomeAssistant) -> None:
|
||||
"""Test we handle invalid thermostats."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -121,7 +122,7 @@ async def test_form_invalid_thermostat(hass):
|
|||
assert result2["errors"] == {"base": "invalid_thermostat"}
|
||||
|
||||
|
||||
async def test_form_cannot_connect(hass):
|
||||
async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
"""Test we handle cannot connect error."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.components.nuheat.const import DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .mocks import MOCK_CONFIG_ENTRY, _get_mock_nuheat
|
||||
|
||||
|
@ -13,7 +14,7 @@ VALID_CONFIG = {
|
|||
INVALID_CONFIG = {"nuheat": {"username": "warm", "password": "feet"}}
|
||||
|
||||
|
||||
async def test_init_success(hass):
|
||||
async def test_init_success(hass: HomeAssistant) -> None:
|
||||
"""Test that we can setup with valid config."""
|
||||
mock_nuheat = _get_mock_nuheat()
|
||||
|
||||
|
|
|
@ -8,11 +8,12 @@ from homeassistant import config_entries, data_entry_flow
|
|||
from homeassistant.components import dhcp
|
||||
from homeassistant.components.nuki.const import DOMAIN
|
||||
from homeassistant.const import CONF_TOKEN
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .mock import HOST, MAC, MOCK_INFO, NAME, setup_nuki_integration
|
||||
|
||||
|
||||
async def test_form(hass):
|
||||
async def test_form(hass: HomeAssistant) -> None:
|
||||
"""Test we get the form."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -48,7 +49,7 @@ async def test_form(hass):
|
|||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_form_invalid_auth(hass):
|
||||
async def test_form_invalid_auth(hass: HomeAssistant) -> None:
|
||||
"""Test we handle invalid auth."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -71,7 +72,7 @@ async def test_form_invalid_auth(hass):
|
|||
assert result2["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
async def test_form_cannot_connect(hass):
|
||||
async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
"""Test we handle cannot connect error."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -94,7 +95,7 @@ async def test_form_cannot_connect(hass):
|
|||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
async def test_form_unknown_exception(hass):
|
||||
async def test_form_unknown_exception(hass: HomeAssistant) -> None:
|
||||
"""Test we handle unknown exceptions."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -117,7 +118,7 @@ async def test_form_unknown_exception(hass):
|
|||
assert result2["errors"] == {"base": "unknown"}
|
||||
|
||||
|
||||
async def test_form_already_configured(hass):
|
||||
async def test_form_already_configured(hass: HomeAssistant) -> None:
|
||||
"""Test we get the form."""
|
||||
await setup_nuki_integration(hass)
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -141,7 +142,7 @@ async def test_form_already_configured(hass):
|
|||
assert result2["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_dhcp_flow(hass):
|
||||
async def test_dhcp_flow(hass: HomeAssistant) -> None:
|
||||
"""Test that DHCP discovery for new bridge works."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
|
@ -180,7 +181,7 @@ async def test_dhcp_flow(hass):
|
|||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_dhcp_flow_already_configured(hass):
|
||||
async def test_dhcp_flow_already_configured(hass: HomeAssistant) -> None:
|
||||
"""Test that DHCP doesn't setup already configured devices."""
|
||||
await setup_nuki_integration(hass)
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -193,7 +194,7 @@ async def test_dhcp_flow_already_configured(hass):
|
|||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_reauth_success(hass):
|
||||
async def test_reauth_success(hass: HomeAssistant) -> None:
|
||||
"""Test starting a reauthentication flow."""
|
||||
entry = await setup_nuki_integration(hass)
|
||||
|
||||
|
@ -221,7 +222,7 @@ async def test_reauth_success(hass):
|
|||
assert entry.data[CONF_TOKEN] == "new-token"
|
||||
|
||||
|
||||
async def test_reauth_invalid_auth(hass):
|
||||
async def test_reauth_invalid_auth(hass: HomeAssistant) -> None:
|
||||
"""Test starting a reauthentication flow with invalid auth."""
|
||||
entry = await setup_nuki_integration(hass)
|
||||
|
||||
|
@ -245,7 +246,7 @@ async def test_reauth_invalid_auth(hass):
|
|||
assert result2["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
async def test_reauth_cannot_connect(hass):
|
||||
async def test_reauth_cannot_connect(hass: HomeAssistant) -> None:
|
||||
"""Test starting a reauthentication flow with cannot connect."""
|
||||
entry = await setup_nuki_integration(hass)
|
||||
|
||||
|
@ -269,7 +270,7 @@ async def test_reauth_cannot_connect(hass):
|
|||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
async def test_reauth_unknown_exception(hass):
|
||||
async def test_reauth_unknown_exception(hass: HomeAssistant) -> None:
|
||||
"""Test starting a reauthentication flow with an unknown exception."""
|
||||
entry = await setup_nuki_integration(hass)
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import voluptuous_serialize
|
|||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.number import DOMAIN, device_action
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import config_validation as cv, device_registry
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.helpers.entity_registry import RegistryEntryHider
|
||||
|
@ -130,7 +131,7 @@ async def test_get_action_no_state(hass, device_reg, entity_reg):
|
|||
assert_lists_same(actions, expected_actions)
|
||||
|
||||
|
||||
async def test_action(hass):
|
||||
async def test_action(hass: HomeAssistant) -> None:
|
||||
"""Test for actions."""
|
||||
hass.states.async_set("number.entity", 0.5, {"min_value": 0.0, "max_value": 1.0})
|
||||
|
||||
|
@ -166,7 +167,7 @@ async def test_action(hass):
|
|||
assert len(calls) == 1
|
||||
|
||||
|
||||
async def test_capabilities(hass):
|
||||
async def test_capabilities(hass: HomeAssistant) -> None:
|
||||
"""Test getting capabilities."""
|
||||
capabilities = await device_action.async_get_action_capabilities(
|
||||
hass,
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
"""Test reproduce state for Number entities."""
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.number.const import (
|
||||
ATTR_MAX,
|
||||
ATTR_MIN,
|
||||
DOMAIN,
|
||||
SERVICE_SET_VALUE,
|
||||
)
|
||||
from homeassistant.core import State
|
||||
from homeassistant.core import HomeAssistant, State
|
||||
from homeassistant.helpers.state import async_reproduce_state
|
||||
|
||||
from tests.common import async_mock_service
|
||||
|
@ -14,7 +16,9 @@ VALID_NUMBER1 = "19.0"
|
|||
VALID_NUMBER2 = "99.9"
|
||||
|
||||
|
||||
async def test_reproducing_states(hass, caplog):
|
||||
async def test_reproducing_states(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Test reproducing Number states."""
|
||||
|
||||
hass.states.async_set(
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
"""Test the Network UPS Tools (NUT) config flow."""
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
from pynut2.nut2 import PyNUTError
|
||||
|
@ -17,6 +16,7 @@ from homeassistant.const import (
|
|||
CONF_SCAN_INTERVAL,
|
||||
CONF_USERNAME,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .util import _get_mock_pynutclient
|
||||
|
||||
|
@ -30,7 +30,7 @@ VALID_CONFIG = {
|
|||
}
|
||||
|
||||
|
||||
async def test_form_zeroconf(hass):
|
||||
async def test_form_zeroconf(hass: HomeAssistant) -> None:
|
||||
"""Test we can setup from zeroconf."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
|
@ -78,7 +78,7 @@ async def test_form_zeroconf(hass):
|
|||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_form_user_one_ups(hass):
|
||||
async def test_form_user_one_ups(hass: HomeAssistant) -> None:
|
||||
"""Test we get the form."""
|
||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -120,7 +120,7 @@ async def test_form_user_one_ups(hass):
|
|||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_form_user_multiple_ups(hass):
|
||||
async def test_form_user_multiple_ups(hass: HomeAssistant) -> None:
|
||||
"""Test we get the form."""
|
||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||
|
||||
|
@ -183,7 +183,7 @@ async def test_form_user_multiple_ups(hass):
|
|||
assert len(mock_setup_entry.mock_calls) == 2
|
||||
|
||||
|
||||
async def test_form_user_one_ups_with_ignored_entry(hass):
|
||||
async def test_form_user_one_ups_with_ignored_entry(hass: HomeAssistant) -> None:
|
||||
"""Test we can setup a new one when there is an ignored one."""
|
||||
ignored_entry = MockConfigEntry(
|
||||
domain=DOMAIN, data={}, source=config_entries.SOURCE_IGNORE
|
||||
|
@ -230,7 +230,7 @@ async def test_form_user_one_ups_with_ignored_entry(hass):
|
|||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_form_cannot_connect(hass):
|
||||
async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
"""Test we handle cannot connect error."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -296,7 +296,7 @@ async def test_form_cannot_connect(hass):
|
|||
assert result2["errors"] == {"base": "unknown"}
|
||||
|
||||
|
||||
async def test_abort_if_already_setup(hass):
|
||||
async def test_abort_if_already_setup(hass: HomeAssistant) -> None:
|
||||
"""Test we abort if component is already setup."""
|
||||
config_entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -333,7 +333,7 @@ async def test_abort_if_already_setup(hass):
|
|||
assert result2["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_abort_if_already_setup_alias(hass):
|
||||
async def test_abort_if_already_setup_alias(hass: HomeAssistant) -> None:
|
||||
"""Test we abort if component is already setup with same alias."""
|
||||
config_entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -383,7 +383,7 @@ async def test_abort_if_already_setup_alias(hass):
|
|||
assert result3["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_options_flow(hass):
|
||||
async def test_options_flow(hass: HomeAssistant) -> None:
|
||||
"""Test config flow options."""
|
||||
|
||||
config_entry = MockConfigEntry(
|
||||
|
|
|
@ -4,13 +4,14 @@ from unittest.mock import patch
|
|||
from homeassistant.components.nut.const import DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import CONF_HOST, CONF_PORT, STATE_UNAVAILABLE
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .util import _get_mock_pynutclient
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_async_setup_entry(hass):
|
||||
async def test_async_setup_entry(hass: HomeAssistant) -> None:
|
||||
"""Test a successful setup entry."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -44,7 +45,7 @@ async def test_async_setup_entry(hass):
|
|||
assert not hass.data.get(DOMAIN)
|
||||
|
||||
|
||||
async def test_config_not_ready(hass):
|
||||
async def test_config_not_ready(hass: HomeAssistant) -> None:
|
||||
"""Test for setup failure if connection to broker is missing."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
"""The sensor tests for the nut platform."""
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.components.nut.const import DOMAIN
|
||||
|
@ -10,6 +9,7 @@ from homeassistant.const import (
|
|||
PERCENTAGE,
|
||||
STATE_UNKNOWN,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from .util import _get_mock_pynutclient, async_init_integration
|
||||
|
@ -17,7 +17,7 @@ from .util import _get_mock_pynutclient, async_init_integration
|
|||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_pr3000rt2u(hass):
|
||||
async def test_pr3000rt2u(hass: HomeAssistant) -> None:
|
||||
"""Test creation of PR3000RT2U sensors."""
|
||||
|
||||
await async_init_integration(hass, "PR3000RT2U")
|
||||
|
@ -41,7 +41,7 @@ async def test_pr3000rt2u(hass):
|
|||
)
|
||||
|
||||
|
||||
async def test_cp1350c(hass):
|
||||
async def test_cp1350c(hass: HomeAssistant) -> None:
|
||||
"""Test creation of CP1350C sensors."""
|
||||
|
||||
config_entry = await async_init_integration(hass, "CP1350C")
|
||||
|
@ -66,7 +66,7 @@ async def test_cp1350c(hass):
|
|||
)
|
||||
|
||||
|
||||
async def test_5e850i(hass):
|
||||
async def test_5e850i(hass: HomeAssistant) -> None:
|
||||
"""Test creation of 5E850I sensors."""
|
||||
|
||||
config_entry = await async_init_integration(hass, "5E850I")
|
||||
|
@ -90,7 +90,7 @@ async def test_5e850i(hass):
|
|||
)
|
||||
|
||||
|
||||
async def test_5e650i(hass):
|
||||
async def test_5e650i(hass: HomeAssistant) -> None:
|
||||
"""Test creation of 5E650I sensors."""
|
||||
|
||||
config_entry = await async_init_integration(hass, "5E650I")
|
||||
|
@ -114,7 +114,7 @@ async def test_5e650i(hass):
|
|||
)
|
||||
|
||||
|
||||
async def test_backupsses600m1(hass):
|
||||
async def test_backupsses600m1(hass: HomeAssistant) -> None:
|
||||
"""Test creation of BACKUPSES600M1 sensors."""
|
||||
|
||||
await async_init_integration(hass, "BACKUPSES600M1")
|
||||
|
@ -141,7 +141,7 @@ async def test_backupsses600m1(hass):
|
|||
)
|
||||
|
||||
|
||||
async def test_cp1500pfclcd(hass):
|
||||
async def test_cp1500pfclcd(hass: HomeAssistant) -> None:
|
||||
"""Test creation of CP1500PFCLCD sensors."""
|
||||
|
||||
config_entry = await async_init_integration(hass, "CP1500PFCLCD")
|
||||
|
@ -165,7 +165,7 @@ async def test_cp1500pfclcd(hass):
|
|||
)
|
||||
|
||||
|
||||
async def test_dl650elcd(hass):
|
||||
async def test_dl650elcd(hass: HomeAssistant) -> None:
|
||||
"""Test creation of DL650ELCD sensors."""
|
||||
|
||||
config_entry = await async_init_integration(hass, "DL650ELCD")
|
||||
|
@ -189,7 +189,7 @@ async def test_dl650elcd(hass):
|
|||
)
|
||||
|
||||
|
||||
async def test_eaton5p1550(hass):
|
||||
async def test_eaton5p1550(hass: HomeAssistant) -> None:
|
||||
"""Test creation of EATON5P1550 sensors."""
|
||||
|
||||
config_entry = await async_init_integration(hass, "EATON5P1550")
|
||||
|
@ -213,7 +213,7 @@ async def test_eaton5p1550(hass):
|
|||
)
|
||||
|
||||
|
||||
async def test_blazer_usb(hass):
|
||||
async def test_blazer_usb(hass: HomeAssistant) -> None:
|
||||
"""Test creation of blazer_usb sensors."""
|
||||
|
||||
config_entry = await async_init_integration(hass, "blazer_usb")
|
||||
|
@ -237,7 +237,7 @@ async def test_blazer_usb(hass):
|
|||
)
|
||||
|
||||
|
||||
async def test_state_sensors(hass):
|
||||
async def test_state_sensors(hass: HomeAssistant) -> None:
|
||||
"""Test creation of status display sensors."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -262,7 +262,7 @@ async def test_state_sensors(hass):
|
|||
assert state2.state == "OL"
|
||||
|
||||
|
||||
async def test_unknown_state_sensors(hass):
|
||||
async def test_unknown_state_sensors(hass: HomeAssistant) -> None:
|
||||
"""Test creation of unknown status display sensors."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -287,7 +287,7 @@ async def test_unknown_state_sensors(hass):
|
|||
assert state2.state == "OQ"
|
||||
|
||||
|
||||
async def test_stale_options(hass):
|
||||
async def test_stale_options(hass: HomeAssistant) -> None:
|
||||
"""Test creation of sensors with stale options to remove."""
|
||||
config_entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
|
|
@ -127,7 +127,7 @@ async def test_nx584_sensor_setup_with_exceptions(hass, exception_type):
|
|||
|
||||
|
||||
@pytest.mark.usefixtures("client")
|
||||
async def test_nx584_sensor_setup_version_too_old(hass):
|
||||
async def test_nx584_sensor_setup_version_too_old(hass: HomeAssistant) -> None:
|
||||
"""Test if version is too old."""
|
||||
nx584_client.Client.return_value.get_version.return_value = "1.0"
|
||||
await _test_assert_graceful_fail(hass, {})
|
||||
|
|
|
@ -6,6 +6,7 @@ from pynzbgetapi import NZBGetAPIException
|
|||
from homeassistant.components.nzbget.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_USER
|
||||
from homeassistant.const import CONF_SCAN_INTERVAL, CONF_VERIFY_SSL
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from . import (
|
||||
|
@ -20,7 +21,7 @@ from . import (
|
|||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_user_form(hass):
|
||||
async def test_user_form(hass: HomeAssistant) -> None:
|
||||
"""Test we get the user initiated form."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -43,7 +44,7 @@ async def test_user_form(hass):
|
|||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_user_form_show_advanced_options(hass):
|
||||
async def test_user_form_show_advanced_options(hass: HomeAssistant) -> None:
|
||||
"""Test we get the user initiated form with advanced options shown."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -71,7 +72,7 @@ async def test_user_form_show_advanced_options(hass):
|
|||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_user_form_cannot_connect(hass):
|
||||
async def test_user_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
"""Test we handle cannot connect error."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
|
@ -90,7 +91,7 @@ async def test_user_form_cannot_connect(hass):
|
|||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
async def test_user_form_unexpected_exception(hass):
|
||||
async def test_user_form_unexpected_exception(hass: HomeAssistant) -> None:
|
||||
"""Test we handle unexpected exception."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
|
@ -109,7 +110,7 @@ async def test_user_form_unexpected_exception(hass):
|
|||
assert result["reason"] == "unknown"
|
||||
|
||||
|
||||
async def test_user_form_single_instance_allowed(hass):
|
||||
async def test_user_form_single_instance_allowed(hass: HomeAssistant) -> None:
|
||||
"""Test that configuring more than one instance is rejected."""
|
||||
entry = MockConfigEntry(domain=DOMAIN, data=ENTRY_CONFIG)
|
||||
entry.add_to_hass(hass)
|
||||
|
|
|
@ -5,6 +5,7 @@ from pynzbgetapi import NZBGetAPIException
|
|||
|
||||
from homeassistant.components.nzbget.const import DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import ENTRY_CONFIG, _patch_version, init_integration
|
||||
|
||||
|
@ -25,7 +26,7 @@ async def test_unload_entry(hass, nzbget_api):
|
|||
assert not hass.data.get(DOMAIN)
|
||||
|
||||
|
||||
async def test_async_setup_raises_entry_not_ready(hass):
|
||||
async def test_async_setup_raises_entry_not_ready(hass: HomeAssistant) -> None:
|
||||
"""Test that it throws ConfigEntryNotReady when exception occurs during setup."""
|
||||
config_entry = MockConfigEntry(domain=DOMAIN, data=ENTRY_CONFIG)
|
||||
config_entry.add_to_hass(hass)
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
"""The tests for Octoptint binary sensor module."""
|
||||
|
||||
from homeassistant.const import STATE_OFF, STATE_ON, STATE_UNAVAILABLE
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from . import init_integration
|
||||
|
||||
|
||||
async def test_sensors(hass):
|
||||
async def test_sensors(hass: HomeAssistant) -> None:
|
||||
"""Test the underlying sensors."""
|
||||
printer = {
|
||||
"state": {
|
||||
|
@ -34,7 +34,7 @@ async def test_sensors(hass):
|
|||
assert entry.unique_id == "Printing Error-uuid"
|
||||
|
||||
|
||||
async def test_sensors_printer_offline(hass):
|
||||
async def test_sensors_printer_offline(hass: HomeAssistant) -> None:
|
||||
"""Test the underlying sensors when the printer is offline."""
|
||||
await init_integration(hass, "binary_sensor", printer=None)
|
||||
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
"""The tests for Octoptint camera module."""
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
from pyoctoprintapi import WebcamSettings
|
||||
|
||||
from homeassistant.components.camera import DOMAIN as CAMERA_DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from . import init_integration
|
||||
|
||||
|
||||
async def test_camera(hass):
|
||||
async def test_camera(hass: HomeAssistant) -> None:
|
||||
"""Test the underlying camera."""
|
||||
with patch(
|
||||
"pyoctoprintapi.OctoprintClient.get_webcam_info",
|
||||
|
@ -32,7 +32,7 @@ async def test_camera(hass):
|
|||
assert entry.unique_id == "uuid"
|
||||
|
||||
|
||||
async def test_camera_disabled(hass):
|
||||
async def test_camera_disabled(hass: HomeAssistant) -> None:
|
||||
"""Test that the camera does not load if there is not one configured."""
|
||||
with patch(
|
||||
"pyoctoprintapi.OctoprintClient.get_webcam_info",
|
||||
|
@ -53,7 +53,7 @@ async def test_camera_disabled(hass):
|
|||
assert entry is None
|
||||
|
||||
|
||||
async def test_no_supported_camera(hass):
|
||||
async def test_no_supported_camera(hass: HomeAssistant) -> None:
|
||||
"""Test that the camera does not load if there is not one configured."""
|
||||
with patch(
|
||||
"pyoctoprintapi.OctoprintClient.get_webcam_info",
|
||||
|
|
|
@ -11,7 +11,7 @@ from homeassistant.core import HomeAssistant
|
|||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_form(hass):
|
||||
async def test_form(hass: HomeAssistant) -> None:
|
||||
"""Test we get the form."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -69,7 +69,7 @@ async def test_form(hass):
|
|||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_form_cannot_connect(hass):
|
||||
async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
"""Test we handle cannot connect error."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -118,7 +118,7 @@ async def test_form_cannot_connect(hass):
|
|||
assert result["errors"]["base"] == "cannot_connect"
|
||||
|
||||
|
||||
async def test_form_unknown_exception(hass):
|
||||
async def test_form_unknown_exception(hass: HomeAssistant) -> None:
|
||||
"""Test we handle a random error."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -428,7 +428,7 @@ async def test_failed_auth_unexpected_error(hass: HomeAssistant) -> None:
|
|||
assert result["reason"] == "auth_failed"
|
||||
|
||||
|
||||
async def test_user_duplicate_entry(hass):
|
||||
async def test_user_duplicate_entry(hass: HomeAssistant) -> None:
|
||||
"""Test that duplicate entries abort."""
|
||||
MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -535,7 +535,7 @@ async def test_duplicate_ssdp_ignored(hass: HomeAssistant) -> None:
|
|||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_reauth_form(hass):
|
||||
async def test_reauth_form(hass: HomeAssistant) -> None:
|
||||
"""Test we get the form."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
|
|
@ -2,12 +2,13 @@
|
|||
from datetime import datetime, timezone
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from . import init_integration
|
||||
|
||||
|
||||
async def test_sensors(hass):
|
||||
async def test_sensors(hass: HomeAssistant) -> None:
|
||||
"""Test the underlying sensors."""
|
||||
printer = {
|
||||
"state": {
|
||||
|
@ -79,7 +80,7 @@ async def test_sensors(hass):
|
|||
assert entry.unique_id == "Estimated Finish Time-uuid"
|
||||
|
||||
|
||||
async def test_sensors_no_target_temp(hass):
|
||||
async def test_sensors_no_target_temp(hass: HomeAssistant) -> None:
|
||||
"""Test the underlying sensors."""
|
||||
printer = {
|
||||
"state": {
|
||||
|
@ -110,7 +111,7 @@ async def test_sensors_no_target_temp(hass):
|
|||
assert entry.unique_id == "target tool1 temp-uuid"
|
||||
|
||||
|
||||
async def test_sensors_paused(hass):
|
||||
async def test_sensors_paused(hass: HomeAssistant) -> None:
|
||||
"""Test the underlying sensors."""
|
||||
printer = {
|
||||
"state": {
|
||||
|
@ -146,7 +147,7 @@ async def test_sensors_paused(hass):
|
|||
assert entry.unique_id == "Estimated Finish Time-uuid"
|
||||
|
||||
|
||||
async def test_sensors_printer_disconnected(hass):
|
||||
async def test_sensors_printer_disconnected(hass: HomeAssistant) -> None:
|
||||
"""Test the underlying sensors."""
|
||||
job = {
|
||||
"job": {},
|
||||
|
|
|
@ -5,13 +5,14 @@ from omnilogic import LoginException, OmniLogicException
|
|||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant.components.omnilogic.const import DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
DATA = {"username": "test-username", "password": "test-password"}
|
||||
|
||||
|
||||
async def test_form(hass):
|
||||
async def test_form(hass: HomeAssistant) -> None:
|
||||
"""Test we get the form."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -39,7 +40,7 @@ async def test_form(hass):
|
|||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_already_configured(hass):
|
||||
async def test_already_configured(hass: HomeAssistant) -> None:
|
||||
"""Test config flow when Omnilogic component is already setup."""
|
||||
MockConfigEntry(domain="omnilogic", data=DATA).add_to_hass(hass)
|
||||
|
||||
|
@ -51,7 +52,7 @@ async def test_already_configured(hass):
|
|||
assert result["reason"] == "single_instance_allowed"
|
||||
|
||||
|
||||
async def test_with_invalid_credentials(hass):
|
||||
async def test_with_invalid_credentials(hass: HomeAssistant) -> None:
|
||||
"""Test with invalid credentials."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -72,7 +73,7 @@ async def test_with_invalid_credentials(hass):
|
|||
assert result["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
async def test_form_cannot_connect(hass):
|
||||
async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
"""Test if invalid response or no connection returned from Hayward."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -93,7 +94,7 @@ async def test_form_cannot_connect(hass):
|
|||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
async def test_with_unknown_error(hass):
|
||||
async def test_with_unknown_error(hass: HomeAssistant) -> None:
|
||||
"""Test with unknown error response from Hayward."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -114,7 +115,7 @@ async def test_with_unknown_error(hass):
|
|||
assert result["errors"] == {"base": "unknown"}
|
||||
|
||||
|
||||
async def test_option_flow(hass):
|
||||
async def test_option_flow(hass: HomeAssistant) -> None:
|
||||
"""Test option flow."""
|
||||
entry = MockConfigEntry(domain=DOMAIN, data=DATA)
|
||||
entry.add_to_hass(hass)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
from unittest.mock import Mock, patch
|
||||
|
||||
from homeassistant.components import onboarding
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from . import mock_storage
|
||||
|
@ -23,7 +24,7 @@ async def test_not_setup_views_if_onboarded(hass, hass_storage):
|
|||
assert onboarding.async_is_onboarded(hass)
|
||||
|
||||
|
||||
async def test_setup_views_if_not_onboarded(hass):
|
||||
async def test_setup_views_if_not_onboarded(hass: HomeAssistant) -> None:
|
||||
"""Test if onboarding is not done, we setup views."""
|
||||
with patch(
|
||||
"homeassistant.components.onboarding.views.async_setup",
|
||||
|
|
|
@ -10,6 +10,7 @@ from homeassistant.components.ondilo_ico.const import (
|
|||
OAUTH2_TOKEN,
|
||||
)
|
||||
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import config_entry_oauth2_flow
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
@ -18,7 +19,7 @@ CLIENT_ID = OAUTH2_CLIENTID
|
|||
CLIENT_SECRET = OAUTH2_CLIENTSECRET
|
||||
|
||||
|
||||
async def test_abort_if_existing_entry(hass):
|
||||
async def test_abort_if_existing_entry(hass: HomeAssistant) -> None:
|
||||
"""Check flow abort when an entry already exist."""
|
||||
MockConfigEntry(domain=DOMAIN).add_to_hass(hass)
|
||||
|
||||
|
|
|
@ -3,12 +3,13 @@ from unittest.mock import AsyncMock
|
|||
|
||||
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, ButtonDeviceClass
|
||||
from homeassistant.const import ATTR_DEVICE_CLASS, ATTR_ENTITY_ID, STATE_UNKNOWN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from . import MAC, setup_onvif_integration
|
||||
|
||||
|
||||
async def test_reboot_button(hass):
|
||||
async def test_reboot_button(hass: HomeAssistant) -> None:
|
||||
"""Test states of the Reboot button."""
|
||||
await setup_onvif_integration(hass)
|
||||
|
||||
|
@ -23,7 +24,7 @@ async def test_reboot_button(hass):
|
|||
assert entry.unique_id == f"{MAC}_reboot"
|
||||
|
||||
|
||||
async def test_reboot_button_press(hass):
|
||||
async def test_reboot_button_press(hass: HomeAssistant) -> None:
|
||||
"""Test Reboot button press."""
|
||||
_, camera, _ = await setup_onvif_integration(hass)
|
||||
devicemgmt = camera.create_devicemgmt_service()
|
||||
|
@ -40,7 +41,7 @@ async def test_reboot_button_press(hass):
|
|||
devicemgmt.SystemReboot.assert_called_once()
|
||||
|
||||
|
||||
async def test_set_dateandtime_button(hass):
|
||||
async def test_set_dateandtime_button(hass: HomeAssistant) -> None:
|
||||
"""Test states of the SetDateAndTime button."""
|
||||
await setup_onvif_integration(hass)
|
||||
|
||||
|
@ -54,7 +55,7 @@ async def test_set_dateandtime_button(hass):
|
|||
assert entry.unique_id == f"{MAC}_setsystemdatetime"
|
||||
|
||||
|
||||
async def test_set_dateandtime_button_press(hass):
|
||||
async def test_set_dateandtime_button_press(hass: HomeAssistant) -> None:
|
||||
"""Test SetDateAndTime button press."""
|
||||
_, camera, device = await setup_onvif_integration(hass)
|
||||
device.async_manually_set_date_and_time = AsyncMock(return_value=True)
|
||||
|
|
|
@ -3,6 +3,7 @@ from unittest.mock import MagicMock, patch
|
|||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant.components.onvif import config_flow
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import (
|
||||
HOST,
|
||||
|
@ -66,7 +67,7 @@ def setup_mock_discovery(
|
|||
mock_discovery.return_value = services
|
||||
|
||||
|
||||
async def test_flow_discovered_devices(hass):
|
||||
async def test_flow_discovered_devices(hass: HomeAssistant) -> None:
|
||||
"""Test that config flow works for discovered devices."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -127,7 +128,9 @@ async def test_flow_discovered_devices(hass):
|
|||
}
|
||||
|
||||
|
||||
async def test_flow_discovered_devices_ignore_configured_manual_input(hass):
|
||||
async def test_flow_discovered_devices_ignore_configured_manual_input(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test that config flow discovery ignores configured devices."""
|
||||
await setup_onvif_integration(hass)
|
||||
|
||||
|
@ -166,7 +169,7 @@ async def test_flow_discovered_devices_ignore_configured_manual_input(hass):
|
|||
assert result["step_id"] == "configure"
|
||||
|
||||
|
||||
async def test_flow_discovered_no_device(hass):
|
||||
async def test_flow_discovered_no_device(hass: HomeAssistant) -> None:
|
||||
"""Test that config flow discovery no device."""
|
||||
await setup_onvif_integration(hass)
|
||||
|
||||
|
@ -196,7 +199,7 @@ async def test_flow_discovered_no_device(hass):
|
|||
assert result["step_id"] == "configure"
|
||||
|
||||
|
||||
async def test_flow_discovery_ignore_existing_and_abort(hass):
|
||||
async def test_flow_discovery_ignore_existing_and_abort(hass: HomeAssistant) -> None:
|
||||
"""Test that config flow discovery ignores setup devices."""
|
||||
await setup_onvif_integration(hass)
|
||||
await setup_onvif_integration(
|
||||
|
@ -253,7 +256,7 @@ async def test_flow_discovery_ignore_existing_and_abort(hass):
|
|||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
|
||||
|
||||
async def test_flow_manual_entry(hass):
|
||||
async def test_flow_manual_entry(hass: HomeAssistant) -> None:
|
||||
"""Test that config flow works for discovered devices."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -310,7 +313,7 @@ async def test_flow_manual_entry(hass):
|
|||
}
|
||||
|
||||
|
||||
async def test_option_flow(hass):
|
||||
async def test_option_flow(hass: HomeAssistant) -> None:
|
||||
"""Test config flow options."""
|
||||
entry, _, _ = await setup_onvif_integration(hass)
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""Test ONVIF diagnostics."""
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import (
|
||||
FIRMWARE_VERSION,
|
||||
|
@ -10,9 +11,12 @@ from . import (
|
|||
)
|
||||
|
||||
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||
from tests.typing import ClientSessionGenerator
|
||||
|
||||
|
||||
async def test_diagnostics(hass, hass_client):
|
||||
async def test_diagnostics(
|
||||
hass: HomeAssistant, hass_client: ClientSessionGenerator
|
||||
) -> None:
|
||||
"""Test generating diagnostics for a config entry."""
|
||||
|
||||
entry, _, _ = await setup_onvif_integration(hass)
|
||||
|
|
|
@ -3,12 +3,13 @@ from unittest.mock import AsyncMock
|
|||
|
||||
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
||||
from homeassistant.const import ATTR_ENTITY_ID, STATE_OFF, STATE_ON, STATE_UNKNOWN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from . import MAC, setup_onvif_integration
|
||||
|
||||
|
||||
async def test_wiper_switch(hass):
|
||||
async def test_wiper_switch(hass: HomeAssistant) -> None:
|
||||
"""Test states of the Wiper switch."""
|
||||
_config, _camera, device = await setup_onvif_integration(hass)
|
||||
device.profiles = device.async_get_profiles()
|
||||
|
@ -23,7 +24,7 @@ async def test_wiper_switch(hass):
|
|||
assert entry.unique_id == f"{MAC}_wiper"
|
||||
|
||||
|
||||
async def test_turn_wiper_switch_on(hass):
|
||||
async def test_turn_wiper_switch_on(hass: HomeAssistant) -> None:
|
||||
"""Test Wiper switch turn on."""
|
||||
_, _camera, device = await setup_onvif_integration(hass)
|
||||
device.async_run_aux_command = AsyncMock(return_value=True)
|
||||
|
@ -41,7 +42,7 @@ async def test_turn_wiper_switch_on(hass):
|
|||
assert state.state == STATE_ON
|
||||
|
||||
|
||||
async def test_turn_wiper_switch_off(hass):
|
||||
async def test_turn_wiper_switch_off(hass: HomeAssistant) -> None:
|
||||
"""Test Wiper switch turn off."""
|
||||
_, _camera, device = await setup_onvif_integration(hass)
|
||||
device.async_run_aux_command = AsyncMock(return_value=True)
|
||||
|
@ -59,7 +60,7 @@ async def test_turn_wiper_switch_off(hass):
|
|||
assert state.state == STATE_OFF
|
||||
|
||||
|
||||
async def test_autofocus_switch(hass):
|
||||
async def test_autofocus_switch(hass: HomeAssistant) -> None:
|
||||
"""Test states of the autofocus switch."""
|
||||
_config, _camera, device = await setup_onvif_integration(hass)
|
||||
device.profiles = device.async_get_profiles()
|
||||
|
@ -74,7 +75,7 @@ async def test_autofocus_switch(hass):
|
|||
assert entry.unique_id == f"{MAC}_autofocus"
|
||||
|
||||
|
||||
async def test_turn_autofocus_switch_on(hass):
|
||||
async def test_turn_autofocus_switch_on(hass: HomeAssistant) -> None:
|
||||
"""Test autofocus switch turn on."""
|
||||
_, _camera, device = await setup_onvif_integration(hass)
|
||||
device.async_set_imaging_settings = AsyncMock(return_value=True)
|
||||
|
@ -92,7 +93,7 @@ async def test_turn_autofocus_switch_on(hass):
|
|||
assert state.state == STATE_ON
|
||||
|
||||
|
||||
async def test_turn_autofocus_switch_off(hass):
|
||||
async def test_turn_autofocus_switch_off(hass: HomeAssistant) -> None:
|
||||
"""Test autofocus switch turn off."""
|
||||
_, _camera, device = await setup_onvif_integration(hass)
|
||||
device.async_set_imaging_settings = AsyncMock(return_value=True)
|
||||
|
@ -110,7 +111,7 @@ async def test_turn_autofocus_switch_off(hass):
|
|||
assert state.state == STATE_OFF
|
||||
|
||||
|
||||
async def test_infrared_switch(hass):
|
||||
async def test_infrared_switch(hass: HomeAssistant) -> None:
|
||||
"""Test states of the autofocus switch."""
|
||||
_config, _camera, device = await setup_onvif_integration(hass)
|
||||
device.profiles = device.async_get_profiles()
|
||||
|
@ -125,7 +126,7 @@ async def test_infrared_switch(hass):
|
|||
assert entry.unique_id == f"{MAC}_ir_lamp"
|
||||
|
||||
|
||||
async def test_turn_infrared_switch_on(hass):
|
||||
async def test_turn_infrared_switch_on(hass: HomeAssistant) -> None:
|
||||
"""Test infrared switch turn on."""
|
||||
_, _camera, device = await setup_onvif_integration(hass)
|
||||
device.async_set_imaging_settings = AsyncMock(return_value=True)
|
||||
|
@ -143,7 +144,7 @@ async def test_turn_infrared_switch_on(hass):
|
|||
assert state.state == STATE_ON
|
||||
|
||||
|
||||
async def test_turn_infrared_switch_off(hass):
|
||||
async def test_turn_infrared_switch_off(hass: HomeAssistant) -> None:
|
||||
"""Test infrared switch turn off."""
|
||||
_, _camera, device = await setup_onvif_integration(hass)
|
||||
device.async_set_imaging_settings = AsyncMock(return_value=True)
|
||||
|
|
|
@ -6,6 +6,7 @@ import pytest
|
|||
|
||||
from homeassistant.components import camera, image_processing as ip
|
||||
from homeassistant.components.openalpr_cloud.image_processing import OPENALPR_API_URL
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import assert_setup_component, async_capture_events, load_fixture
|
||||
|
@ -48,7 +49,7 @@ PARAMS = {
|
|||
}
|
||||
|
||||
|
||||
async def test_setup_platform(hass):
|
||||
async def test_setup_platform(hass: HomeAssistant) -> None:
|
||||
"""Set up platform with one entity."""
|
||||
config = {
|
||||
ip.DOMAIN: {
|
||||
|
@ -67,7 +68,7 @@ async def test_setup_platform(hass):
|
|||
assert hass.states.get("image_processing.openalpr_demo_camera")
|
||||
|
||||
|
||||
async def test_setup_platform_name(hass):
|
||||
async def test_setup_platform_name(hass: HomeAssistant) -> None:
|
||||
"""Set up platform with one entity and set name."""
|
||||
config = {
|
||||
ip.DOMAIN: {
|
||||
|
@ -86,7 +87,7 @@ async def test_setup_platform_name(hass):
|
|||
assert hass.states.get("image_processing.test_local")
|
||||
|
||||
|
||||
async def test_setup_platform_without_api_key(hass):
|
||||
async def test_setup_platform_without_api_key(hass: HomeAssistant) -> None:
|
||||
"""Set up platform with one entity without api_key."""
|
||||
config = {
|
||||
ip.DOMAIN: {
|
||||
|
@ -101,7 +102,7 @@ async def test_setup_platform_without_api_key(hass):
|
|||
await async_setup_component(hass, ip.DOMAIN, config)
|
||||
|
||||
|
||||
async def test_setup_platform_without_region(hass):
|
||||
async def test_setup_platform_without_region(hass: HomeAssistant) -> None:
|
||||
"""Set up platform with one entity without region."""
|
||||
config = {
|
||||
ip.DOMAIN: {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
MOCK_CONFIG = {
|
||||
|
@ -14,7 +15,7 @@ MOCK_CONFIG = {
|
|||
}
|
||||
|
||||
|
||||
async def test_sensor_state(hass):
|
||||
async def test_sensor_state(hass: HomeAssistant) -> None:
|
||||
"""Test whether default waste type set properly."""
|
||||
with patch(
|
||||
"homeassistant.components.openerz.sensor.OpenERZConnector"
|
||||
|
|
|
@ -21,13 +21,14 @@ from homeassistant.const import (
|
|||
PRECISION_HALVES,
|
||||
PRECISION_TENTHS,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
MINIMAL_STATUS = {OTGW: {OTGW_ABOUT: "OpenTherm Gateway 4.2.5"}}
|
||||
|
||||
|
||||
async def test_form_user(hass):
|
||||
async def test_form_user(hass: HomeAssistant) -> None:
|
||||
"""Test we get the form."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -67,7 +68,7 @@ async def test_form_user(hass):
|
|||
assert len(mock_pyotgw_disconnect.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_form_import(hass):
|
||||
async def test_form_import(hass: HomeAssistant) -> None:
|
||||
"""Test import from existing config."""
|
||||
|
||||
with patch(
|
||||
|
@ -102,7 +103,7 @@ async def test_form_import(hass):
|
|||
assert len(mock_pyotgw_disconnect.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_form_duplicate_entries(hass):
|
||||
async def test_form_duplicate_entries(hass: HomeAssistant) -> None:
|
||||
"""Test duplicate device or id errors."""
|
||||
flow1 = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -147,7 +148,7 @@ async def test_form_duplicate_entries(hass):
|
|||
assert len(mock_pyotgw_disconnect.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_form_connection_timeout(hass):
|
||||
async def test_form_connection_timeout(hass: HomeAssistant) -> None:
|
||||
"""Test we handle connection timeout."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -168,7 +169,7 @@ async def test_form_connection_timeout(hass):
|
|||
assert len(mock_connect.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_form_connection_error(hass):
|
||||
async def test_form_connection_error(hass: HomeAssistant) -> None:
|
||||
"""Test we handle serial connection error."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -188,7 +189,7 @@ async def test_form_connection_error(hass):
|
|||
assert len(mock_connect.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_options_migration(hass):
|
||||
async def test_options_migration(hass: HomeAssistant) -> None:
|
||||
"""Test migration of precision option after update."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -234,7 +235,7 @@ async def test_options_migration(hass):
|
|||
assert result["data"][CONF_FLOOR_TEMP] is True
|
||||
|
||||
|
||||
async def test_options_form(hass):
|
||||
async def test_options_form(hass: HomeAssistant) -> None:
|
||||
"""Test the options form."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
|
|
@ -6,6 +6,7 @@ from pyotgw.vars import OTGW, OTGW_ABOUT
|
|||
from homeassistant import setup
|
||||
from homeassistant.components.opentherm_gw.const import DOMAIN
|
||||
from homeassistant.const import CONF_DEVICE, CONF_ID, CONF_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
|
||||
from tests.common import MockConfigEntry, mock_device_registry
|
||||
|
@ -27,7 +28,7 @@ MOCK_CONFIG_ENTRY = MockConfigEntry(
|
|||
)
|
||||
|
||||
|
||||
async def test_device_registry_insert(hass):
|
||||
async def test_device_registry_insert(hass: HomeAssistant) -> None:
|
||||
"""Test that the device registry is initialized correctly."""
|
||||
MOCK_CONFIG_ENTRY.add_to_hass(hass)
|
||||
|
||||
|
@ -45,7 +46,7 @@ async def test_device_registry_insert(hass):
|
|||
assert gw_dev.sw_version == VERSION_OLD
|
||||
|
||||
|
||||
async def test_device_registry_update(hass):
|
||||
async def test_device_registry_update(hass: HomeAssistant) -> None:
|
||||
"""Test that the device registry is updated correctly."""
|
||||
MOCK_CONFIG_ENTRY.add_to_hass(hass)
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ from homeassistant.const import (
|
|||
CONF_MODE,
|
||||
CONF_NAME,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
@ -33,7 +34,7 @@ CONFIG = {
|
|||
VALID_YAML_CONFIG = {CONF_API_KEY: "foo"}
|
||||
|
||||
|
||||
async def test_form(hass):
|
||||
async def test_form(hass: HomeAssistant) -> None:
|
||||
"""Test that the form is served with valid input."""
|
||||
mocked_owm = _create_mocked_owm(True)
|
||||
|
||||
|
@ -70,7 +71,7 @@ async def test_form(hass):
|
|||
assert result["data"][CONF_API_KEY] == CONFIG[CONF_API_KEY]
|
||||
|
||||
|
||||
async def test_form_options(hass):
|
||||
async def test_form_options(hass: HomeAssistant) -> None:
|
||||
"""Test that the options form."""
|
||||
mocked_owm = _create_mocked_owm(True)
|
||||
|
||||
|
@ -127,7 +128,7 @@ async def test_form_options(hass):
|
|||
assert config_entry.state == ConfigEntryState.LOADED
|
||||
|
||||
|
||||
async def test_form_invalid_api_key(hass):
|
||||
async def test_form_invalid_api_key(hass: HomeAssistant) -> None:
|
||||
"""Test that the form is served with no input."""
|
||||
mocked_owm = _create_mocked_owm(True)
|
||||
|
||||
|
@ -143,7 +144,7 @@ async def test_form_invalid_api_key(hass):
|
|||
assert result["errors"] == {"base": "invalid_api_key"}
|
||||
|
||||
|
||||
async def test_form_api_call_error(hass):
|
||||
async def test_form_api_call_error(hass: HomeAssistant) -> None:
|
||||
"""Test setting up with api call error."""
|
||||
mocked_owm = _create_mocked_owm(True)
|
||||
|
||||
|
@ -159,7 +160,7 @@ async def test_form_api_call_error(hass):
|
|||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
async def test_form_api_offline(hass):
|
||||
async def test_form_api_offline(hass: HomeAssistant) -> None:
|
||||
"""Test setting up with api call error."""
|
||||
mocked_owm = _create_mocked_owm(False)
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
"""Test the OralB config flow."""
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.oralb.const import DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from . import NOT_ORALB_SERVICE_INFO, ORALB_IO_SERIES_4_SERVICE_INFO, ORALB_SERVICE_INFO
|
||||
|
@ -11,7 +11,7 @@ from . import NOT_ORALB_SERVICE_INFO, ORALB_IO_SERIES_4_SERVICE_INFO, ORALB_SERV
|
|||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_async_step_bluetooth_valid_device(hass):
|
||||
async def test_async_step_bluetooth_valid_device(hass: HomeAssistant) -> None:
|
||||
"""Test discovery via bluetooth with a valid device."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
|
@ -30,7 +30,9 @@ async def test_async_step_bluetooth_valid_device(hass):
|
|||
assert result2["result"].unique_id == "78:DB:2F:C2:48:BE"
|
||||
|
||||
|
||||
async def test_async_step_bluetooth_valid_io_series4_device(hass):
|
||||
async def test_async_step_bluetooth_valid_io_series4_device(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test discovery via bluetooth with a valid device."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
|
@ -49,7 +51,7 @@ async def test_async_step_bluetooth_valid_io_series4_device(hass):
|
|||
assert result2["result"].unique_id == "78:DB:2F:C2:48:BE"
|
||||
|
||||
|
||||
async def test_async_step_bluetooth_not_oralb(hass):
|
||||
async def test_async_step_bluetooth_not_oralb(hass: HomeAssistant) -> None:
|
||||
"""Test discovery via bluetooth not oralb."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
|
@ -60,7 +62,7 @@ async def test_async_step_bluetooth_not_oralb(hass):
|
|||
assert result["reason"] == "not_supported"
|
||||
|
||||
|
||||
async def test_async_step_user_no_devices_found(hass):
|
||||
async def test_async_step_user_no_devices_found(hass: HomeAssistant) -> None:
|
||||
"""Test setup from service info cache with no devices found."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
|
@ -70,7 +72,7 @@ async def test_async_step_user_no_devices_found(hass):
|
|||
assert result["reason"] == "no_devices_found"
|
||||
|
||||
|
||||
async def test_async_step_user_with_found_devices(hass):
|
||||
async def test_async_step_user_with_found_devices(hass: HomeAssistant) -> None:
|
||||
"""Test setup from service info cache with devices found."""
|
||||
with patch(
|
||||
"homeassistant.components.oralb.config_flow.async_discovered_service_info",
|
||||
|
@ -93,7 +95,7 @@ async def test_async_step_user_with_found_devices(hass):
|
|||
assert result2["result"].unique_id == "78:DB:2F:C2:48:BE"
|
||||
|
||||
|
||||
async def test_async_step_user_device_added_between_steps(hass):
|
||||
async def test_async_step_user_device_added_between_steps(hass: HomeAssistant) -> None:
|
||||
"""Test the device gets added via another flow between steps."""
|
||||
with patch(
|
||||
"homeassistant.components.oralb.config_flow.async_discovered_service_info",
|
||||
|
@ -121,7 +123,9 @@ async def test_async_step_user_device_added_between_steps(hass):
|
|||
assert result2["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_async_step_user_with_found_devices_already_setup(hass):
|
||||
async def test_async_step_user_with_found_devices_already_setup(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test setup from service info cache with devices found."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -141,7 +145,7 @@ async def test_async_step_user_with_found_devices_already_setup(hass):
|
|||
assert result["reason"] == "no_devices_found"
|
||||
|
||||
|
||||
async def test_async_step_bluetooth_devices_already_setup(hass):
|
||||
async def test_async_step_bluetooth_devices_already_setup(hass: HomeAssistant) -> None:
|
||||
"""Test we can't start a flow if there is already a config entry."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -158,7 +162,7 @@ async def test_async_step_bluetooth_devices_already_setup(hass):
|
|||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_async_step_bluetooth_already_in_progress(hass):
|
||||
async def test_async_step_bluetooth_already_in_progress(hass: HomeAssistant) -> None:
|
||||
"""Test we can't start a flow for the same device twice."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
|
@ -177,7 +181,9 @@ async def test_async_step_bluetooth_already_in_progress(hass):
|
|||
assert result["reason"] == "already_in_progress"
|
||||
|
||||
|
||||
async def test_async_step_user_takes_precedence_over_discovery(hass):
|
||||
async def test_async_step_user_takes_precedence_over_discovery(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test manual setup takes precedence over discovery."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
"""Test the OralB sensors."""
|
||||
|
||||
|
||||
from homeassistant.components.oralb.const import DOMAIN
|
||||
from homeassistant.const import ATTR_FRIENDLY_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import (
|
||||
ORALB_IO_SERIES_4_SERVICE_INFO,
|
||||
|
@ -72,7 +71,7 @@ async def test_sensors_io_series_4(hass, entity_registry_enabled_by_default):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
async def test_sensors_battery(hass):
|
||||
async def test_sensors_battery(hass: HomeAssistant) -> None:
|
||||
"""Test receiving battery percentage."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
|
|
@ -256,7 +256,7 @@ async def test_dhcp_flow_already_configured(hass: HomeAssistant) -> None:
|
|||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_zeroconf_flow(hass):
|
||||
async def test_zeroconf_flow(hass: HomeAssistant) -> None:
|
||||
"""Test that zeroconf discovery for new bridge works."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
|
@ -288,7 +288,7 @@ async def test_zeroconf_flow(hass):
|
|||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_zeroconf_flow_already_configured(hass):
|
||||
async def test_zeroconf_flow_already_configured(hass: HomeAssistant) -> None:
|
||||
"""Test that zeroconf doesn't setup already configured gateways."""
|
||||
config_entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -307,7 +307,7 @@ async def test_zeroconf_flow_already_configured(hass):
|
|||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_reauth_success(hass):
|
||||
async def test_reauth_success(hass: HomeAssistant) -> None:
|
||||
"""Test reauthentication flow."""
|
||||
|
||||
mock_entry = MockConfigEntry(
|
||||
|
@ -349,7 +349,7 @@ async def test_reauth_success(hass):
|
|||
assert mock_entry.data["password"] == TEST_PASSWORD2
|
||||
|
||||
|
||||
async def test_reauth_wrong_account(hass):
|
||||
async def test_reauth_wrong_account(hass: HomeAssistant) -> None:
|
||||
"""Test reauthentication flow."""
|
||||
|
||||
mock_entry = MockConfigEntry(
|
||||
|
|
|
@ -9,6 +9,7 @@ from homeassistant.components.owntracks.config_flow import CONF_CLOUDHOOK, CONF_
|
|||
from homeassistant.components.owntracks.const import DOMAIN
|
||||
from homeassistant.config import async_process_ha_core_config
|
||||
from homeassistant.const import CONF_WEBHOOK_ID
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
@ -76,7 +77,7 @@ async def test_user(hass, webhook_id, secret):
|
|||
assert result["description_placeholders"][CONF_WEBHOOK_URL] == WEBHOOK_URL
|
||||
|
||||
|
||||
async def test_import_setup(hass):
|
||||
async def test_import_setup(hass: HomeAssistant) -> None:
|
||||
"""Test that we don't automatically create a config entry."""
|
||||
await async_process_ha_core_config(
|
||||
hass,
|
||||
|
@ -89,7 +90,7 @@ async def test_import_setup(hass):
|
|||
assert not hass.config_entries.async_entries(DOMAIN)
|
||||
|
||||
|
||||
async def test_abort_if_already_setup(hass):
|
||||
async def test_abort_if_already_setup(hass: HomeAssistant) -> None:
|
||||
"""Test that we can't add more than one instance."""
|
||||
flow = await init_config_flow(hass)
|
||||
|
||||
|
@ -114,7 +115,7 @@ async def test_user_not_supports_encryption(hass, not_supports_encryption):
|
|||
)
|
||||
|
||||
|
||||
async def test_unload(hass):
|
||||
async def test_unload(hass: HomeAssistant) -> None:
|
||||
"""Test unloading a config flow."""
|
||||
await async_process_ha_core_config(
|
||||
hass,
|
||||
|
@ -147,7 +148,7 @@ async def test_unload(hass):
|
|||
assert entry.data["webhook_id"] not in hass.data["webhook"]
|
||||
|
||||
|
||||
async def test_with_cloud_sub(hass):
|
||||
async def test_with_cloud_sub(hass: HomeAssistant) -> None:
|
||||
"""Test creating a config flow while subscribed."""
|
||||
assert await async_setup_component(hass, "cloud", {})
|
||||
|
||||
|
@ -174,7 +175,7 @@ async def test_with_cloud_sub(hass):
|
|||
)
|
||||
|
||||
|
||||
async def test_with_cloud_sub_not_connected(hass):
|
||||
async def test_with_cloud_sub_not_connected(hass: HomeAssistant) -> None:
|
||||
"""Test creating a config flow while subscribed."""
|
||||
assert await async_setup_component(hass, "cloud", {})
|
||||
|
||||
|
|
|
@ -6,9 +6,11 @@ import pytest
|
|||
|
||||
from homeassistant.components import owntracks
|
||||
from homeassistant.const import STATE_NOT_HOME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import MockConfigEntry, async_fire_mqtt_message, mock_coro
|
||||
from tests.typing import ClientSessionGenerator
|
||||
|
||||
USER = "greg"
|
||||
DEVICE = "phone"
|
||||
|
@ -1519,7 +1521,9 @@ async def test_region_mapping(hass, setup_comp):
|
|||
assert_location_state(hass, "inner")
|
||||
|
||||
|
||||
async def test_restore_state(hass, hass_client):
|
||||
async def test_restore_state(
|
||||
hass: HomeAssistant, hass_client: ClientSessionGenerator
|
||||
) -> None:
|
||||
"""Test that we can restore state."""
|
||||
entry = MockConfigEntry(
|
||||
domain="owntracks", data={"webhook_id": "owntracks_test", "secret": "abcd"}
|
||||
|
@ -1557,7 +1561,9 @@ async def test_restore_state(hass, hass_client):
|
|||
assert state_1.attributes["source_type"] == state_2.attributes["source_type"]
|
||||
|
||||
|
||||
async def test_returns_empty_friends(hass, hass_client):
|
||||
async def test_returns_empty_friends(
|
||||
hass: HomeAssistant, hass_client: ClientSessionGenerator
|
||||
) -> None:
|
||||
"""Test that an empty list of persons' locations is returned."""
|
||||
entry = MockConfigEntry(
|
||||
domain="owntracks", data={"webhook_id": "owntracks_test", "secret": "abcd"}
|
||||
|
@ -1578,7 +1584,9 @@ async def test_returns_empty_friends(hass, hass_client):
|
|||
assert await resp.text() == "[]"
|
||||
|
||||
|
||||
async def test_returns_array_friends(hass, hass_client):
|
||||
async def test_returns_array_friends(
|
||||
hass: HomeAssistant, hass_client: ClientSessionGenerator
|
||||
) -> None:
|
||||
"""Test that a list of persons' current locations is returned."""
|
||||
otracks = MockConfigEntry(
|
||||
domain="owntracks", data={"webhook_id": "owntracks_test", "secret": "abcd"}
|
||||
|
|
|
@ -11,6 +11,7 @@ from homeassistant.components.panasonic_viera.const import (
|
|||
ERROR_INVALID_PIN_CODE,
|
||||
)
|
||||
from homeassistant.const import CONF_PIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .conftest import (
|
||||
MOCK_BASIC_DATA,
|
||||
|
@ -23,7 +24,7 @@ from .conftest import (
|
|||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_flow_non_encrypted(hass):
|
||||
async def test_flow_non_encrypted(hass: HomeAssistant) -> None:
|
||||
"""Test flow without encryption."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -49,7 +50,7 @@ async def test_flow_non_encrypted(hass):
|
|||
assert result["data"] == {**MOCK_CONFIG_DATA, ATTR_DEVICE_INFO: MOCK_DEVICE_INFO}
|
||||
|
||||
|
||||
async def test_flow_not_connected_error(hass):
|
||||
async def test_flow_not_connected_error(hass: HomeAssistant) -> None:
|
||||
"""Test flow with connection error."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -73,7 +74,7 @@ async def test_flow_not_connected_error(hass):
|
|||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
async def test_flow_unknown_abort(hass):
|
||||
async def test_flow_unknown_abort(hass: HomeAssistant) -> None:
|
||||
"""Test flow with unknown error abortion."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -96,7 +97,9 @@ async def test_flow_unknown_abort(hass):
|
|||
assert result["reason"] == "unknown"
|
||||
|
||||
|
||||
async def test_flow_encrypted_not_connected_pin_code_request(hass):
|
||||
async def test_flow_encrypted_not_connected_pin_code_request(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test flow with encryption and PIN code request connection error abortion during pairing request step."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -121,7 +124,7 @@ async def test_flow_encrypted_not_connected_pin_code_request(hass):
|
|||
assert result["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
async def test_flow_encrypted_unknown_pin_code_request(hass):
|
||||
async def test_flow_encrypted_unknown_pin_code_request(hass: HomeAssistant) -> None:
|
||||
"""Test flow with encryption and PIN code request unknown error abortion during pairing request step."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -146,7 +149,7 @@ async def test_flow_encrypted_unknown_pin_code_request(hass):
|
|||
assert result["reason"] == "unknown"
|
||||
|
||||
|
||||
async def test_flow_encrypted_valid_pin_code(hass):
|
||||
async def test_flow_encrypted_valid_pin_code(hass: HomeAssistant) -> None:
|
||||
"""Test flow with encryption and valid PIN code."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -188,7 +191,7 @@ async def test_flow_encrypted_valid_pin_code(hass):
|
|||
}
|
||||
|
||||
|
||||
async def test_flow_encrypted_invalid_pin_code_error(hass):
|
||||
async def test_flow_encrypted_invalid_pin_code_error(hass: HomeAssistant) -> None:
|
||||
"""Test flow with encryption and invalid PIN code error during pairing step."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -226,7 +229,7 @@ async def test_flow_encrypted_invalid_pin_code_error(hass):
|
|||
assert result["errors"] == {"base": ERROR_INVALID_PIN_CODE}
|
||||
|
||||
|
||||
async def test_flow_encrypted_not_connected_abort(hass):
|
||||
async def test_flow_encrypted_not_connected_abort(hass: HomeAssistant) -> None:
|
||||
"""Test flow with encryption and PIN code connection error abortion during pairing step."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -259,7 +262,7 @@ async def test_flow_encrypted_not_connected_abort(hass):
|
|||
assert result["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
async def test_flow_encrypted_unknown_abort(hass):
|
||||
async def test_flow_encrypted_unknown_abort(hass: HomeAssistant) -> None:
|
||||
"""Test flow with encryption and PIN code unknown error abortion during pairing step."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -292,7 +295,7 @@ async def test_flow_encrypted_unknown_abort(hass):
|
|||
assert result["reason"] == "unknown"
|
||||
|
||||
|
||||
async def test_flow_non_encrypted_already_configured_abort(hass):
|
||||
async def test_flow_non_encrypted_already_configured_abort(hass: HomeAssistant) -> None:
|
||||
"""Test flow without encryption and existing config entry abortion."""
|
||||
|
||||
MockConfigEntry(
|
||||
|
@ -311,7 +314,7 @@ async def test_flow_non_encrypted_already_configured_abort(hass):
|
|||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_flow_encrypted_already_configured_abort(hass):
|
||||
async def test_flow_encrypted_already_configured_abort(hass: HomeAssistant) -> None:
|
||||
"""Test flow with encryption and existing config entry abortion."""
|
||||
|
||||
MockConfigEntry(
|
||||
|
@ -330,7 +333,7 @@ async def test_flow_encrypted_already_configured_abort(hass):
|
|||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_imported_flow_non_encrypted(hass):
|
||||
async def test_imported_flow_non_encrypted(hass: HomeAssistant) -> None:
|
||||
"""Test imported flow without encryption."""
|
||||
|
||||
mock_remote = get_mock_remote(encrypted=False)
|
||||
|
@ -350,7 +353,7 @@ async def test_imported_flow_non_encrypted(hass):
|
|||
assert result["data"] == {**MOCK_CONFIG_DATA, ATTR_DEVICE_INFO: MOCK_DEVICE_INFO}
|
||||
|
||||
|
||||
async def test_imported_flow_encrypted_valid_pin_code(hass):
|
||||
async def test_imported_flow_encrypted_valid_pin_code(hass: HomeAssistant) -> None:
|
||||
"""Test imported flow with encryption and valid PIN code."""
|
||||
|
||||
mock_remote = get_mock_remote(
|
||||
|
@ -386,7 +389,9 @@ async def test_imported_flow_encrypted_valid_pin_code(hass):
|
|||
}
|
||||
|
||||
|
||||
async def test_imported_flow_encrypted_invalid_pin_code_error(hass):
|
||||
async def test_imported_flow_encrypted_invalid_pin_code_error(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test imported flow with encryption and invalid PIN code error during pairing step."""
|
||||
|
||||
mock_remote = get_mock_remote(encrypted=True, authorize_error=SOAPError)
|
||||
|
@ -418,7 +423,7 @@ async def test_imported_flow_encrypted_invalid_pin_code_error(hass):
|
|||
assert result["errors"] == {"base": ERROR_INVALID_PIN_CODE}
|
||||
|
||||
|
||||
async def test_imported_flow_encrypted_not_connected_abort(hass):
|
||||
async def test_imported_flow_encrypted_not_connected_abort(hass: HomeAssistant) -> None:
|
||||
"""Test imported flow with encryption and PIN code connection error abortion during pairing step."""
|
||||
|
||||
mock_remote = get_mock_remote(encrypted=True, authorize_error=TimeoutError)
|
||||
|
@ -445,7 +450,7 @@ async def test_imported_flow_encrypted_not_connected_abort(hass):
|
|||
assert result["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
async def test_imported_flow_encrypted_unknown_abort(hass):
|
||||
async def test_imported_flow_encrypted_unknown_abort(hass: HomeAssistant) -> None:
|
||||
"""Test imported flow with encryption and PIN code unknown error abortion during pairing step."""
|
||||
|
||||
mock_remote = get_mock_remote(encrypted=True, authorize_error=Exception)
|
||||
|
@ -472,7 +477,7 @@ async def test_imported_flow_encrypted_unknown_abort(hass):
|
|||
assert result["reason"] == "unknown"
|
||||
|
||||
|
||||
async def test_imported_flow_not_connected_error(hass):
|
||||
async def test_imported_flow_not_connected_error(hass: HomeAssistant) -> None:
|
||||
"""Test imported flow with connection error abortion."""
|
||||
|
||||
with patch(
|
||||
|
@ -490,7 +495,7 @@ async def test_imported_flow_not_connected_error(hass):
|
|||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
async def test_imported_flow_unknown_abort(hass):
|
||||
async def test_imported_flow_unknown_abort(hass: HomeAssistant) -> None:
|
||||
"""Test imported flow with unknown error abortion."""
|
||||
|
||||
with patch(
|
||||
|
@ -507,7 +512,9 @@ async def test_imported_flow_unknown_abort(hass):
|
|||
assert result["reason"] == "unknown"
|
||||
|
||||
|
||||
async def test_imported_flow_non_encrypted_already_configured_abort(hass):
|
||||
async def test_imported_flow_non_encrypted_already_configured_abort(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test imported flow without encryption and existing config entry abortion."""
|
||||
|
||||
MockConfigEntry(
|
||||
|
@ -526,7 +533,9 @@ async def test_imported_flow_non_encrypted_already_configured_abort(hass):
|
|||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_imported_flow_encrypted_already_configured_abort(hass):
|
||||
async def test_imported_flow_encrypted_already_configured_abort(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test imported flow with encryption and existing config entry abortion."""
|
||||
|
||||
MockConfigEntry(
|
||||
|
|
|
@ -9,6 +9,7 @@ from homeassistant.components.panasonic_viera.const import (
|
|||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import CONF_HOST, STATE_UNAVAILABLE
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from .conftest import (
|
||||
|
@ -70,7 +71,9 @@ async def test_setup_entry_encrypted_missing_device_info(hass, mock_remote):
|
|||
assert state_remote.name == DEFAULT_NAME
|
||||
|
||||
|
||||
async def test_setup_entry_encrypted_missing_device_info_none(hass):
|
||||
async def test_setup_entry_encrypted_missing_device_info_none(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test setup with encrypted config entry and device info set to None."""
|
||||
mock_entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -151,7 +154,9 @@ async def test_setup_entry_unencrypted_missing_device_info(hass, mock_remote):
|
|||
assert state_remote.name == DEFAULT_NAME
|
||||
|
||||
|
||||
async def test_setup_entry_unencrypted_missing_device_info_none(hass):
|
||||
async def test_setup_entry_unencrypted_missing_device_info_none(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test setup with unencrypted config entry and device info set to None."""
|
||||
mock_entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -183,7 +188,7 @@ async def test_setup_entry_unencrypted_missing_device_info_none(hass):
|
|||
assert state_remote.name == DEFAULT_NAME
|
||||
|
||||
|
||||
async def test_setup_config_flow_initiated(hass):
|
||||
async def test_setup_config_flow_initiated(hass: HomeAssistant) -> None:
|
||||
"""Test if config flow is initiated in setup."""
|
||||
mock_remote = get_mock_remote()
|
||||
mock_remote.get_device_info = Mock(side_effect=OSError)
|
||||
|
|
|
@ -3,9 +3,10 @@ from unittest.mock import Mock, patch
|
|||
|
||||
from homeassistant import setup
|
||||
from homeassistant.components import frontend
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
|
||||
async def test_webcomponent_custom_path_not_found(hass):
|
||||
async def test_webcomponent_custom_path_not_found(hass: HomeAssistant) -> None:
|
||||
"""Test if a web component is found in config panels dir."""
|
||||
filename = "mock.file"
|
||||
|
||||
|
@ -30,7 +31,7 @@ async def test_webcomponent_custom_path_not_found(hass):
|
|||
assert "nice_url" not in panels
|
||||
|
||||
|
||||
async def test_js_webcomponent(hass):
|
||||
async def test_js_webcomponent(hass: HomeAssistant) -> None:
|
||||
"""Test if a web component is found in config panels dir."""
|
||||
config = {
|
||||
"panel_custom": {
|
||||
|
@ -69,7 +70,7 @@ async def test_js_webcomponent(hass):
|
|||
assert panel.sidebar_title == "Sidebar Title"
|
||||
|
||||
|
||||
async def test_module_webcomponent(hass):
|
||||
async def test_module_webcomponent(hass: HomeAssistant) -> None:
|
||||
"""Test if a js module is found in config panels dir."""
|
||||
config = {
|
||||
"panel_custom": {
|
||||
|
@ -110,7 +111,7 @@ async def test_module_webcomponent(hass):
|
|||
assert panel.sidebar_title == "Sidebar Title"
|
||||
|
||||
|
||||
async def test_latest_and_es5_build(hass):
|
||||
async def test_latest_and_es5_build(hass: HomeAssistant) -> None:
|
||||
"""Test specifying an es5 and latest build."""
|
||||
config = {
|
||||
"panel_custom": {
|
||||
|
@ -142,7 +143,7 @@ async def test_latest_and_es5_build(hass):
|
|||
assert panel.frontend_url_path == "nice_url"
|
||||
|
||||
|
||||
async def test_url_path_conflict(hass):
|
||||
async def test_url_path_conflict(hass: HomeAssistant) -> None:
|
||||
"""Test config with overlapping url path."""
|
||||
assert await setup.async_setup_component(
|
||||
hass,
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import pytest
|
||||
|
||||
from homeassistant.components import frontend
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
|
||||
|
@ -19,7 +20,7 @@ async def test_wrong_config(hass, config_to_try):
|
|||
)
|
||||
|
||||
|
||||
async def test_correct_config(hass):
|
||||
async def test_correct_config(hass: HomeAssistant) -> None:
|
||||
"""Test correct config."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
|
|
|
@ -3,9 +3,11 @@ import pytest
|
|||
|
||||
import homeassistant.components.persistent_notification as pn
|
||||
from homeassistant.components.websocket_api.const import TYPE_RESULT
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import async_capture_events
|
||||
from tests.typing import WebSocketGenerator
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
|
@ -14,7 +16,7 @@ async def setup_integration(hass):
|
|||
assert await async_setup_component(hass, pn.DOMAIN, {})
|
||||
|
||||
|
||||
async def test_create(hass):
|
||||
async def test_create(hass: HomeAssistant) -> None:
|
||||
"""Test creating notification without title or notification id."""
|
||||
notifications = hass.data[pn.DOMAIN]
|
||||
assert len(hass.states.async_entity_ids(pn.DOMAIN)) == 0
|
||||
|
@ -38,7 +40,7 @@ async def test_create(hass):
|
|||
assert notification["created_at"] is not None
|
||||
|
||||
|
||||
async def test_create_notification_id(hass):
|
||||
async def test_create_notification_id(hass: HomeAssistant) -> None:
|
||||
"""Ensure overwrites existing notification with same id."""
|
||||
notifications = hass.data[pn.DOMAIN]
|
||||
assert len(hass.states.async_entity_ids(pn.DOMAIN)) == 0
|
||||
|
@ -68,7 +70,7 @@ async def test_create_notification_id(hass):
|
|||
assert notification["message"] == "test 2"
|
||||
|
||||
|
||||
async def test_dismiss_notification(hass):
|
||||
async def test_dismiss_notification(hass: HomeAssistant) -> None:
|
||||
"""Ensure removal of specific notification."""
|
||||
notifications = hass.data[pn.DOMAIN]
|
||||
assert len(hass.states.async_entity_ids(pn.DOMAIN)) == 0
|
||||
|
@ -84,7 +86,7 @@ async def test_dismiss_notification(hass):
|
|||
assert len(notifications) == 0
|
||||
|
||||
|
||||
async def test_mark_read(hass):
|
||||
async def test_mark_read(hass: HomeAssistant) -> None:
|
||||
"""Ensure notification is marked as Read."""
|
||||
events = async_capture_events(hass, pn.EVENT_PERSISTENT_NOTIFICATIONS_UPDATED)
|
||||
notifications = hass.data[pn.DOMAIN]
|
||||
|
@ -122,7 +124,9 @@ async def test_mark_read(hass):
|
|||
assert len(events) == 3
|
||||
|
||||
|
||||
async def test_ws_get_notifications(hass, hass_ws_client):
|
||||
async def test_ws_get_notifications(
|
||||
hass: HomeAssistant, hass_ws_client: WebSocketGenerator
|
||||
) -> None:
|
||||
"""Test websocket endpoint for retrieving persistent notifications."""
|
||||
await async_setup_component(hass, pn.DOMAIN, {})
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ from homeassistant.const import (
|
|||
SERVICE_RELOAD,
|
||||
STATE_UNKNOWN,
|
||||
)
|
||||
from homeassistant.core import Context, CoreState, State
|
||||
from homeassistant.core import Context, CoreState, HomeAssistant, State
|
||||
from homeassistant.helpers import collection, entity_registry as er
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
|
@ -61,7 +61,7 @@ def storage_setup(hass, hass_storage, hass_admin_user):
|
|||
assert hass.loop.run_until_complete(async_setup_component(hass, DOMAIN, {}))
|
||||
|
||||
|
||||
async def test_minimal_setup(hass):
|
||||
async def test_minimal_setup(hass: HomeAssistant) -> None:
|
||||
"""Test minimal config with only name."""
|
||||
config = {DOMAIN: {"id": "1234", "name": "test person"}}
|
||||
assert await async_setup_component(hass, DOMAIN, config)
|
||||
|
@ -75,13 +75,13 @@ async def test_minimal_setup(hass):
|
|||
assert state.attributes.get(ATTR_ENTITY_PICTURE) is None
|
||||
|
||||
|
||||
async def test_setup_no_id(hass):
|
||||
async def test_setup_no_id(hass: HomeAssistant) -> None:
|
||||
"""Test config with no id."""
|
||||
config = {DOMAIN: {"name": "test user"}}
|
||||
assert not await async_setup_component(hass, DOMAIN, config)
|
||||
|
||||
|
||||
async def test_setup_no_name(hass):
|
||||
async def test_setup_no_name(hass: HomeAssistant) -> None:
|
||||
"""Test config with no name."""
|
||||
config = {DOMAIN: {"id": "1234"}}
|
||||
assert not await async_setup_component(hass, DOMAIN, config)
|
||||
|
@ -352,7 +352,7 @@ async def test_duplicate_ids(hass, hass_admin_user):
|
|||
assert hass.states.get("person.test_user_2") is None
|
||||
|
||||
|
||||
async def test_create_person_during_run(hass):
|
||||
async def test_create_person_during_run(hass: HomeAssistant) -> None:
|
||||
"""Test that person is updated if created while hass is running."""
|
||||
config = {DOMAIN: {}}
|
||||
assert await async_setup_component(hass, DOMAIN, config)
|
||||
|
@ -773,7 +773,7 @@ async def test_person_storage_fixing_device_trackers(storage_collection):
|
|||
assert storage_collection.data["bla"]["device_trackers"] == []
|
||||
|
||||
|
||||
async def test_persons_with_entity(hass):
|
||||
async def test_persons_with_entity(hass: HomeAssistant) -> None:
|
||||
"""Test finding persons with an entity."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
|
@ -804,7 +804,7 @@ async def test_persons_with_entity(hass):
|
|||
]
|
||||
|
||||
|
||||
async def test_entities_in_person(hass):
|
||||
async def test_entities_in_person(hass: HomeAssistant) -> None:
|
||||
"""Test finding entities tracked by person."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
|
|
|
@ -6,6 +6,7 @@ import pytest
|
|||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant.components.philips_js.const import CONF_ALLOW_NOTIFY, DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import (
|
||||
MOCK_CONFIG,
|
||||
|
@ -206,7 +207,7 @@ async def test_pair_grant_failed(hass, mock_tv_pairable, mock_setup_entry):
|
|||
}
|
||||
|
||||
|
||||
async def test_options_flow(hass):
|
||||
async def test_options_flow(hass: HomeAssistant) -> None:
|
||||
"""Test config flow options."""
|
||||
config_entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
|
|
@ -8,6 +8,7 @@ import requests
|
|||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant.components.picnic.const import CONF_COUNTRY_CODE, DOMAIN
|
||||
from homeassistant.const import CONF_ACCESS_TOKEN
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
@ -66,7 +67,7 @@ async def test_form(hass, picnic_api):
|
|||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_form_invalid_auth(hass):
|
||||
async def test_form_invalid_auth(hass: HomeAssistant) -> None:
|
||||
"""Test we handle invalid authentication."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -89,7 +90,7 @@ async def test_form_invalid_auth(hass):
|
|||
assert result2["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
async def test_form_cannot_connect(hass):
|
||||
async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
"""Test we handle connection errors."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -112,7 +113,7 @@ async def test_form_cannot_connect(hass):
|
|||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
async def test_form_exception(hass):
|
||||
async def test_form_exception(hass: HomeAssistant) -> None:
|
||||
"""Test we handle random exceptions."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -201,7 +202,7 @@ async def test_step_reauth(hass, picnic_api):
|
|||
assert len(hass.config_entries.async_entries()) == 1
|
||||
|
||||
|
||||
async def test_step_reauth_failed(hass):
|
||||
async def test_step_reauth_failed(hass: HomeAssistant) -> None:
|
||||
"""Test the re-auth flow when authentication fails."""
|
||||
# Create a mocked config entry
|
||||
user_id = "f29-2a6-o32n"
|
||||
|
|
|
@ -93,7 +93,7 @@ async def test_connection_timeout_error(mock_error, hass):
|
|||
|
||||
|
||||
@patch("pilight.pilight.Client", PilightDaemonSim)
|
||||
async def test_send_code_no_protocol(hass):
|
||||
async def test_send_code_no_protocol(hass: HomeAssistant) -> None:
|
||||
"""Try to send data without protocol information, should give error."""
|
||||
with assert_setup_component(4):
|
||||
assert await async_setup_component(hass, pilight.DOMAIN, {pilight.DOMAIN: {}})
|
||||
|
@ -365,7 +365,7 @@ async def test_whitelist_no_match(mock_debug, hass):
|
|||
assert "Event pilight_received" not in debug_log_call
|
||||
|
||||
|
||||
async def test_call_rate_delay_throttle_enabled(hass):
|
||||
async def test_call_rate_delay_throttle_enabled(hass: HomeAssistant) -> None:
|
||||
"""Test that throttling actually work."""
|
||||
runs = []
|
||||
delay = 5.0
|
||||
|
|
|
@ -5,6 +5,7 @@ import pytest
|
|||
|
||||
from homeassistant.components import pilight
|
||||
import homeassistant.components.sensor as sensor
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import assert_setup_component, mock_component
|
||||
|
@ -24,7 +25,7 @@ def fire_pilight_message(hass, protocol, data):
|
|||
hass.bus.async_fire(pilight.EVENT, message)
|
||||
|
||||
|
||||
async def test_sensor_value_from_code(hass):
|
||||
async def test_sensor_value_from_code(hass: HomeAssistant) -> None:
|
||||
"""Test the setting of value via pilight."""
|
||||
with assert_setup_component(1):
|
||||
assert await async_setup_component(
|
||||
|
@ -55,7 +56,7 @@ async def test_sensor_value_from_code(hass):
|
|||
assert state.state == "42"
|
||||
|
||||
|
||||
async def test_disregard_wrong_payload(hass):
|
||||
async def test_disregard_wrong_payload(hass: HomeAssistant) -> None:
|
||||
"""Test omitting setting of value with wrong payload."""
|
||||
with assert_setup_component(1):
|
||||
assert await async_setup_component(
|
||||
|
@ -99,7 +100,9 @@ async def test_disregard_wrong_payload(hass):
|
|||
assert state.state == "data"
|
||||
|
||||
|
||||
async def test_variable_missing(hass, caplog):
|
||||
async def test_variable_missing(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Check if error message when variable missing."""
|
||||
caplog.set_level(logging.ERROR)
|
||||
with assert_setup_component(1):
|
||||
|
|
|
@ -12,6 +12,7 @@ from homeassistant.components.plaato.const import (
|
|||
DOMAIN,
|
||||
)
|
||||
from homeassistant.const import CONF_SCAN_INTERVAL, CONF_TOKEN, CONF_WEBHOOK_ID
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
|
@ -33,7 +34,7 @@ def mock_webhook_id():
|
|||
yield
|
||||
|
||||
|
||||
async def test_show_config_form(hass):
|
||||
async def test_show_config_form(hass: HomeAssistant) -> None:
|
||||
"""Test show configuration form."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -44,7 +45,7 @@ async def test_show_config_form(hass):
|
|||
assert result["step_id"] == "user"
|
||||
|
||||
|
||||
async def test_show_config_form_device_type_airlock(hass):
|
||||
async def test_show_config_form_device_type_airlock(hass: HomeAssistant) -> None:
|
||||
"""Test show configuration form."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
|
@ -61,7 +62,7 @@ async def test_show_config_form_device_type_airlock(hass):
|
|||
assert result["data_schema"].schema.get(CONF_USE_WEBHOOK) == bool
|
||||
|
||||
|
||||
async def test_show_config_form_device_type_keg(hass):
|
||||
async def test_show_config_form_device_type_keg(hass: HomeAssistant) -> None:
|
||||
"""Test show configuration form."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
|
@ -163,7 +164,7 @@ async def test_show_config_form_validate_webhook_not_connected(hass, webhook_id)
|
|||
assert result["reason"] == "cloud_not_connected"
|
||||
|
||||
|
||||
async def test_show_config_form_validate_token(hass):
|
||||
async def test_show_config_form_validate_token(hass: HomeAssistant) -> None:
|
||||
"""Test show configuration form."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -281,7 +282,7 @@ async def test_show_config_form_api_method_no_auth_token(hass, webhook_id):
|
|||
assert result["errors"]["base"] == "no_api_method"
|
||||
|
||||
|
||||
async def test_options(hass):
|
||||
async def test_options(hass: HomeAssistant) -> None:
|
||||
"""Test updating options."""
|
||||
config_entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
|
|
@ -43,7 +43,7 @@ GOOD_CONFIG = {
|
|||
}
|
||||
|
||||
|
||||
async def test_valid_data(hass):
|
||||
async def test_valid_data(hass: HomeAssistant) -> None:
|
||||
"""Test processing valid data."""
|
||||
sensor = plant.Plant("my plant", GOOD_CONFIG)
|
||||
sensor.entity_id = "sensor.mqtt_plant_battery"
|
||||
|
@ -61,7 +61,7 @@ async def test_valid_data(hass):
|
|||
assert attrib[reading] == value
|
||||
|
||||
|
||||
async def test_low_battery(hass):
|
||||
async def test_low_battery(hass: HomeAssistant) -> None:
|
||||
"""Test processing with low battery data and limit set."""
|
||||
sensor = plant.Plant("other plant", GOOD_CONFIG)
|
||||
sensor.entity_id = "sensor.mqtt_plant_battery"
|
||||
|
@ -75,7 +75,7 @@ async def test_low_battery(hass):
|
|||
assert sensor.extra_state_attributes["problem"] == "battery low"
|
||||
|
||||
|
||||
async def test_initial_states(hass):
|
||||
async def test_initial_states(hass: HomeAssistant) -> None:
|
||||
"""Test plant initialises attributes if sensor already exists."""
|
||||
hass.states.async_set(MOISTURE_ENTITY, 5, {ATTR_UNIT_OF_MEASUREMENT: CONDUCTIVITY})
|
||||
plant_name = "some_plant"
|
||||
|
@ -87,7 +87,7 @@ async def test_initial_states(hass):
|
|||
assert state.attributes[plant.READING_MOISTURE] == 5
|
||||
|
||||
|
||||
async def test_update_states(hass):
|
||||
async def test_update_states(hass: HomeAssistant) -> None:
|
||||
"""Test updating the state of a sensor.
|
||||
|
||||
Make sure that plant processes this correctly.
|
||||
|
@ -103,7 +103,7 @@ async def test_update_states(hass):
|
|||
assert state.attributes[plant.READING_MOISTURE] == 5
|
||||
|
||||
|
||||
async def test_unavailable_state(hass):
|
||||
async def test_unavailable_state(hass: HomeAssistant) -> None:
|
||||
"""Test updating the state with unavailable.
|
||||
|
||||
Make sure that plant processes this correctly.
|
||||
|
@ -121,7 +121,7 @@ async def test_unavailable_state(hass):
|
|||
assert state.attributes[plant.READING_MOISTURE] == STATE_UNAVAILABLE
|
||||
|
||||
|
||||
async def test_state_problem_if_unavailable(hass):
|
||||
async def test_state_problem_if_unavailable(hass: HomeAssistant) -> None:
|
||||
"""Test updating the state with unavailable after setting it to valid value.
|
||||
|
||||
Make sure that plant processes this correctly.
|
||||
|
@ -170,7 +170,7 @@ async def test_load_from_db(recorder_mock, hass):
|
|||
assert max_brightness == 30
|
||||
|
||||
|
||||
async def test_brightness_history(hass):
|
||||
async def test_brightness_history(hass: HomeAssistant) -> None:
|
||||
"""Test the min_brightness check."""
|
||||
plant_name = "some_plant"
|
||||
assert await async_setup_component(
|
||||
|
|
|
@ -37,6 +37,7 @@ from homeassistant.const import (
|
|||
CONF_VERIFY_SSL,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .const import DEFAULT_OPTIONS, MOCK_SERVERS, MOCK_TOKEN, PLEX_DIRECT_URL
|
||||
from .helpers import trigger_plex_update, wait_for_debouncer
|
||||
|
@ -697,7 +698,7 @@ async def test_setup_with_limited_credentials(hass, entry, setup_plex_server):
|
|||
assert entry.state is ConfigEntryState.LOADED
|
||||
|
||||
|
||||
async def test_integration_discovery(hass):
|
||||
async def test_integration_discovery(hass: HomeAssistant) -> None:
|
||||
"""Test integration self-discovery."""
|
||||
mock_gdm = MockGDM()
|
||||
|
||||
|
@ -822,7 +823,7 @@ async def test_trigger_reauth_multiple_servers_available(
|
|||
assert entry.data[PLEX_SERVER_CONFIG][CONF_TOKEN] == "BRAND_NEW_TOKEN"
|
||||
|
||||
|
||||
async def test_client_request_missing(hass):
|
||||
async def test_client_request_missing(hass: HomeAssistant) -> None:
|
||||
"""Test when client headers are not set properly."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
|
|
|
@ -5,11 +5,12 @@ from requests.exceptions import ConnectTimeout
|
|||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.plum_lightpad.const import DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_form(hass):
|
||||
async def test_form(hass: HomeAssistant) -> None:
|
||||
"""Test we get the form."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -42,7 +43,7 @@ async def test_form(hass):
|
|||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_form_cannot_connect(hass):
|
||||
async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
"""Test we handle invalid auth."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -61,7 +62,7 @@ async def test_form_cannot_connect(hass):
|
|||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
async def test_form_one_entry_per_email_allowed(hass):
|
||||
async def test_form_one_entry_per_email_allowed(hass: HomeAssistant) -> None:
|
||||
"""Test that only one entry allowed per Plum cloud email address."""
|
||||
MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -89,7 +90,7 @@ async def test_form_one_entry_per_email_allowed(hass):
|
|||
assert len(mock_setup_entry.mock_calls) == 0
|
||||
|
||||
|
||||
async def test_import(hass):
|
||||
async def test_import(hass: HomeAssistant) -> None:
|
||||
"""Test configuring the flow using configuration.yaml."""
|
||||
|
||||
with patch(
|
||||
|
|
|
@ -7,6 +7,7 @@ import pytest
|
|||
from homeassistant import data_entry_flow
|
||||
from homeassistant.components.point import DOMAIN, config_flow
|
||||
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
|
||||
def init_config_flow(hass, side_effect=None):
|
||||
|
@ -42,7 +43,7 @@ def mock_pypoint(is_authorized):
|
|||
yield PointSession
|
||||
|
||||
|
||||
async def test_abort_if_no_implementation_registered(hass):
|
||||
async def test_abort_if_no_implementation_registered(hass: HomeAssistant) -> None:
|
||||
"""Test we abort if no implementation is registered."""
|
||||
flow = config_flow.PointFlowHandler()
|
||||
flow.hass = hass
|
||||
|
@ -52,7 +53,7 @@ async def test_abort_if_no_implementation_registered(hass):
|
|||
assert result["reason"] == "no_flows"
|
||||
|
||||
|
||||
async def test_abort_if_already_setup(hass):
|
||||
async def test_abort_if_already_setup(hass: HomeAssistant) -> None:
|
||||
"""Test we abort if Point is already setup."""
|
||||
flow = init_config_flow(hass)
|
||||
|
||||
|
@ -112,7 +113,7 @@ async def test_wrong_code_flow_implementation(hass, mock_pypoint):
|
|||
assert result["reason"] == "auth_error"
|
||||
|
||||
|
||||
async def test_not_pick_implementation_if_only_one(hass):
|
||||
async def test_not_pick_implementation_if_only_one(hass: HomeAssistant) -> None:
|
||||
"""Test we allow picking implementation if we have one flow_imp."""
|
||||
flow = init_config_flow(hass)
|
||||
|
||||
|
@ -121,7 +122,7 @@ async def test_not_pick_implementation_if_only_one(hass):
|
|||
assert result["step_id"] == "auth"
|
||||
|
||||
|
||||
async def test_abort_if_timeout_generating_auth_url(hass):
|
||||
async def test_abort_if_timeout_generating_auth_url(hass: HomeAssistant) -> None:
|
||||
"""Test we abort if generating authorize url fails."""
|
||||
flow = init_config_flow(hass, side_effect=asyncio.TimeoutError)
|
||||
|
||||
|
@ -130,7 +131,7 @@ async def test_abort_if_timeout_generating_auth_url(hass):
|
|||
assert result["reason"] == "authorize_url_timeout"
|
||||
|
||||
|
||||
async def test_abort_if_exception_generating_auth_url(hass):
|
||||
async def test_abort_if_exception_generating_auth_url(hass: HomeAssistant) -> None:
|
||||
"""Test we abort if generating authorize url blows up."""
|
||||
flow = init_config_flow(hass, side_effect=ValueError)
|
||||
|
||||
|
@ -139,7 +140,7 @@ async def test_abort_if_exception_generating_auth_url(hass):
|
|||
assert result["reason"] == "unknown_authorize_url_generation"
|
||||
|
||||
|
||||
async def test_abort_no_code(hass):
|
||||
async def test_abort_no_code(hass: HomeAssistant) -> None:
|
||||
"""Test if no code is given to step_code."""
|
||||
flow = init_config_flow(hass)
|
||||
|
||||
|
|
|
@ -5,9 +5,10 @@ from homeassistant import data_entry_flow
|
|||
from homeassistant.components.poolsense.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_USER
|
||||
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
|
||||
async def test_show_form(hass):
|
||||
async def test_show_form(hass: HomeAssistant) -> None:
|
||||
"""Test that the form is served with no input."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
|
@ -17,7 +18,7 @@ async def test_show_form(hass):
|
|||
assert result["step_id"] == SOURCE_USER
|
||||
|
||||
|
||||
async def test_invalid_credentials(hass):
|
||||
async def test_invalid_credentials(hass: HomeAssistant) -> None:
|
||||
"""Test we handle invalid credentials."""
|
||||
with patch(
|
||||
"poolsense.PoolSense.test_poolsense_credentials",
|
||||
|
@ -33,7 +34,7 @@ async def test_invalid_credentials(hass):
|
|||
assert result["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
async def test_valid_credentials(hass):
|
||||
async def test_valid_credentials(hass: HomeAssistant) -> None:
|
||||
"""Test we handle invalid credentials."""
|
||||
with patch(
|
||||
"poolsense.PoolSense.test_poolsense_credentials", return_value=True
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
"""The binary sensor tests for the powerwall platform."""
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.components.powerwall.const import DOMAIN
|
||||
from homeassistant.const import CONF_IP_ADDRESS, STATE_ON
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .mocks import _mock_powerwall_with_fixtures
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_sensors(hass):
|
||||
async def test_sensors(hass: HomeAssistant) -> None:
|
||||
"""Test creation of the binary sensors."""
|
||||
|
||||
mock_powerwall = await _mock_powerwall_with_fixtures(hass)
|
||||
|
|
|
@ -27,7 +27,7 @@ from tests.common import MockConfigEntry
|
|||
VALID_CONFIG = {CONF_IP_ADDRESS: "1.2.3.4", CONF_PASSWORD: "00GGX"}
|
||||
|
||||
|
||||
async def test_form_source_user(hass):
|
||||
async def test_form_source_user(hass: HomeAssistant) -> None:
|
||||
"""Test we get config flow setup form as a user."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -57,7 +57,7 @@ async def test_form_source_user(hass):
|
|||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_form_cannot_connect(hass):
|
||||
async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
"""Test we handle cannot connect error."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -78,7 +78,7 @@ async def test_form_cannot_connect(hass):
|
|||
assert result2["errors"] == {CONF_IP_ADDRESS: "cannot_connect"}
|
||||
|
||||
|
||||
async def test_invalid_auth(hass):
|
||||
async def test_invalid_auth(hass: HomeAssistant) -> None:
|
||||
"""Test we handle invalid auth error."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -99,7 +99,7 @@ async def test_invalid_auth(hass):
|
|||
assert result2["errors"] == {CONF_PASSWORD: "invalid_auth"}
|
||||
|
||||
|
||||
async def test_form_unknown_exeption(hass):
|
||||
async def test_form_unknown_exeption(hass: HomeAssistant) -> None:
|
||||
"""Test we handle an unknown exception."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -119,7 +119,7 @@ async def test_form_unknown_exeption(hass):
|
|||
assert result2["errors"] == {"base": "unknown"}
|
||||
|
||||
|
||||
async def test_form_wrong_version(hass):
|
||||
async def test_form_wrong_version(hass: HomeAssistant) -> None:
|
||||
"""Test we can handle wrong version error."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -142,7 +142,7 @@ async def test_form_wrong_version(hass):
|
|||
assert result3["errors"] == {"base": "wrong_version"}
|
||||
|
||||
|
||||
async def test_already_configured(hass):
|
||||
async def test_already_configured(hass: HomeAssistant) -> None:
|
||||
"""Test we abort when already configured."""
|
||||
|
||||
config_entry = MockConfigEntry(domain=DOMAIN, data={CONF_IP_ADDRESS: "1.1.1.1"})
|
||||
|
@ -161,7 +161,7 @@ async def test_already_configured(hass):
|
|||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_already_configured_with_ignored(hass):
|
||||
async def test_already_configured_with_ignored(hass: HomeAssistant) -> None:
|
||||
"""Test ignored entries do not break checking for existing entries."""
|
||||
|
||||
config_entry = MockConfigEntry(
|
||||
|
@ -206,7 +206,7 @@ async def test_already_configured_with_ignored(hass):
|
|||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_dhcp_discovery_manual_configure(hass):
|
||||
async def test_dhcp_discovery_manual_configure(hass: HomeAssistant) -> None:
|
||||
"""Test we can process the discovery from dhcp and manually configure."""
|
||||
mock_powerwall = await _mock_powerwall_site_name(hass, "Some site")
|
||||
|
||||
|
@ -245,7 +245,7 @@ async def test_dhcp_discovery_manual_configure(hass):
|
|||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_dhcp_discovery_auto_configure(hass):
|
||||
async def test_dhcp_discovery_auto_configure(hass: HomeAssistant) -> None:
|
||||
"""Test we can process the discovery from dhcp and auto configure."""
|
||||
mock_powerwall = await _mock_powerwall_site_name(hass, "Some site")
|
||||
|
||||
|
@ -284,7 +284,7 @@ async def test_dhcp_discovery_auto_configure(hass):
|
|||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_dhcp_discovery_cannot_connect(hass):
|
||||
async def test_dhcp_discovery_cannot_connect(hass: HomeAssistant) -> None:
|
||||
"""Test we can process the discovery from dhcp and we cannot connect."""
|
||||
mock_powerwall = _mock_powerwall_side_effect(site_info=PowerwallUnreachableError)
|
||||
|
||||
|
@ -305,7 +305,7 @@ async def test_dhcp_discovery_cannot_connect(hass):
|
|||
assert result["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
async def test_form_reauth(hass):
|
||||
async def test_form_reauth(hass: HomeAssistant) -> None:
|
||||
"""Test reauthenticate."""
|
||||
|
||||
entry = MockConfigEntry(
|
||||
|
@ -345,7 +345,7 @@ async def test_form_reauth(hass):
|
|||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_dhcp_discovery_update_ip_address(hass):
|
||||
async def test_dhcp_discovery_update_ip_address(hass: HomeAssistant) -> None:
|
||||
"""Test we can update the ip address from dhcp."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -377,7 +377,9 @@ async def test_dhcp_discovery_update_ip_address(hass):
|
|||
assert entry.data[CONF_IP_ADDRESS] == "1.1.1.1"
|
||||
|
||||
|
||||
async def test_dhcp_discovery_does_not_update_ip_when_auth_fails(hass):
|
||||
async def test_dhcp_discovery_does_not_update_ip_when_auth_fails(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test we do not switch to another interface when auth is failing."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -409,7 +411,9 @@ async def test_dhcp_discovery_does_not_update_ip_when_auth_fails(hass):
|
|||
assert entry.data[CONF_IP_ADDRESS] == "1.2.3.4"
|
||||
|
||||
|
||||
async def test_dhcp_discovery_does_not_update_ip_when_auth_successful(hass):
|
||||
async def test_dhcp_discovery_does_not_update_ip_when_auth_successful(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test we do not switch to another interface when auth is successful."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -441,7 +445,7 @@ async def test_dhcp_discovery_does_not_update_ip_when_auth_successful(hass):
|
|||
assert entry.data[CONF_IP_ADDRESS] == "1.2.3.4"
|
||||
|
||||
|
||||
async def test_dhcp_discovery_updates_unique_id(hass):
|
||||
async def test_dhcp_discovery_updates_unique_id(hass: HomeAssistant) -> None:
|
||||
"""Test we can update the unique id from dhcp."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -474,7 +478,9 @@ async def test_dhcp_discovery_updates_unique_id(hass):
|
|||
assert entry.unique_id == MOCK_GATEWAY_DIN
|
||||
|
||||
|
||||
async def test_dhcp_discovery_updates_unique_id_when_entry_is_failed(hass):
|
||||
async def test_dhcp_discovery_updates_unique_id_when_entry_is_failed(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test we can update the unique id from dhcp in a failed state."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
|
|
@ -12,6 +12,7 @@ from homeassistant.const import (
|
|||
CONF_IP_ADDRESS,
|
||||
PERCENTAGE,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
|
||||
from .mocks import _mock_powerwall_with_fixtures
|
||||
|
@ -116,7 +117,7 @@ async def test_sensors(hass, entity_registry_enabled_by_default):
|
|||
assert state.attributes[key] == value
|
||||
|
||||
|
||||
async def test_sensor_backup_reserve_unavailable(hass):
|
||||
async def test_sensor_backup_reserve_unavailable(hass: HomeAssistant) -> None:
|
||||
"""Confirm that backup reserve sensor is not added if data is unavailable from the device."""
|
||||
|
||||
mock_powerwall = await _mock_powerwall_with_fixtures(hass)
|
||||
|
|
|
@ -3,11 +3,12 @@ from unittest.mock import patch
|
|||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.profiler.const import DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_form_user(hass):
|
||||
async def test_form_user(hass: HomeAssistant) -> None:
|
||||
"""Test we can setup by the user."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -32,7 +33,7 @@ async def test_form_user(hass):
|
|||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_form_user_only_once(hass):
|
||||
async def test_form_user_only_once(hass: HomeAssistant) -> None:
|
||||
"""Test we can setup by the user only once."""
|
||||
MockConfigEntry(domain=DOMAIN).add_to_hass(hass)
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ from datetime import timedelta
|
|||
import os
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.profiler import (
|
||||
CONF_SECONDS,
|
||||
SERVICE_DUMP_LOG_OBJECTS,
|
||||
|
@ -15,6 +17,7 @@ from homeassistant.components.profiler import (
|
|||
)
|
||||
from homeassistant.components.profiler.const import DOMAIN
|
||||
from homeassistant.const import CONF_SCAN_INTERVAL, CONF_TYPE
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from tests.common import MockConfigEntry, async_fire_time_changed
|
||||
|
@ -78,7 +81,9 @@ async def test_memory_usage(hass, tmpdir):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
async def test_object_growth_logging(hass, caplog):
|
||||
async def test_object_growth_logging(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Test we can setup and the service and we can dump objects to the log."""
|
||||
|
||||
entry = MockConfigEntry(domain=DOMAIN)
|
||||
|
@ -119,7 +124,9 @@ async def test_object_growth_logging(hass, caplog):
|
|||
assert "Growth" not in caplog.text
|
||||
|
||||
|
||||
async def test_dump_log_object(hass, caplog):
|
||||
async def test_dump_log_object(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Test we can setup and the service is registered and logging works."""
|
||||
|
||||
entry = MockConfigEntry(domain=DOMAIN)
|
||||
|
@ -154,7 +161,9 @@ async def test_dump_log_object(hass, caplog):
|
|||
caplog.clear()
|
||||
|
||||
|
||||
async def test_log_thread_frames(hass, caplog):
|
||||
async def test_log_thread_frames(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Test we can log thread frames."""
|
||||
|
||||
entry = MockConfigEntry(domain=DOMAIN)
|
||||
|
@ -175,7 +184,9 @@ async def test_log_thread_frames(hass, caplog):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
async def test_log_scheduled(hass, caplog):
|
||||
async def test_log_scheduled(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Test we can log scheduled items in the event loop."""
|
||||
|
||||
entry = MockConfigEntry(domain=DOMAIN)
|
||||
|
|
|
@ -4,6 +4,7 @@ from unittest.mock import patch
|
|||
from homeassistant import config_entries
|
||||
from homeassistant.components.progettihwsw.const import DOMAIN
|
||||
from homeassistant.const import CONF_HOST, CONF_PORT
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
@ -16,7 +17,7 @@ mock_value_step_user = {
|
|||
}
|
||||
|
||||
|
||||
async def test_form(hass):
|
||||
async def test_form(hass: HomeAssistant) -> None:
|
||||
"""Test we get the form."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -59,7 +60,7 @@ async def test_form(hass):
|
|||
assert result3["data"]["relay_count"] == result3["data"]["input_count"] == 1
|
||||
|
||||
|
||||
async def test_form_cannot_connect(hass):
|
||||
async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
"""Test we handle unexisting board."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -81,7 +82,7 @@ async def test_form_cannot_connect(hass):
|
|||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
async def test_form_existing_entry_exception(hass):
|
||||
async def test_form_existing_entry_exception(hass: HomeAssistant) -> None:
|
||||
"""Test we handle existing board."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -107,7 +108,7 @@ async def test_form_existing_entry_exception(hass):
|
|||
assert result2["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_form_user_exception(hass):
|
||||
async def test_form_user_exception(hass: HomeAssistant) -> None:
|
||||
"""Test we handle unknown exception."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
|
|
@ -6,12 +6,13 @@ import pytest
|
|||
from homeassistant import config_entries
|
||||
from homeassistant.components.prosegur.config_flow import CannotConnect, InvalidAuth
|
||||
from homeassistant.components.prosegur.const import DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_form(hass):
|
||||
async def test_form(hass: HomeAssistant) -> None:
|
||||
"""Test we get the form."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -53,7 +54,7 @@ async def test_form(hass):
|
|||
assert len(mock_retrieve.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_form_invalid_auth(hass):
|
||||
async def test_form_invalid_auth(hass: HomeAssistant) -> None:
|
||||
"""Test we handle invalid auth."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -76,7 +77,7 @@ async def test_form_invalid_auth(hass):
|
|||
assert result2["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
async def test_form_cannot_connect(hass):
|
||||
async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
"""Test we handle cannot connect error."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -99,7 +100,7 @@ async def test_form_cannot_connect(hass):
|
|||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
async def test_form_unknown_exception(hass):
|
||||
async def test_form_unknown_exception(hass: HomeAssistant) -> None:
|
||||
"""Test we handle unknown exceptions."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -122,7 +123,7 @@ async def test_form_unknown_exception(hass):
|
|||
assert result2["errors"] == {"base": "unknown"}
|
||||
|
||||
|
||||
async def test_reauth_flow(hass):
|
||||
async def test_reauth_flow(hass: HomeAssistant) -> None:
|
||||
"""Test a reauthentication flow."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
|
|
@ -4,8 +4,10 @@ from unittest.mock import MagicMock, patch
|
|||
import pytest
|
||||
|
||||
from homeassistant.components.prosegur import DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
@ -38,7 +40,9 @@ async def test_setup_entry_fail_retrieve(hass, error):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
async def test_unload_entry(hass, aioclient_mock):
|
||||
async def test_unload_entry(
|
||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||
) -> None:
|
||||
"""Test unloading the Prosegur entry."""
|
||||
|
||||
aioclient_mock.post(
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
"""The tests for the Proximity component."""
|
||||
|
||||
from homeassistant.components.proximity import DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
|
||||
async def test_proximities(hass):
|
||||
async def test_proximities(hass: HomeAssistant) -> None:
|
||||
"""Test a list of proximities."""
|
||||
config = {
|
||||
"proximity": {
|
||||
|
@ -33,7 +33,7 @@ async def test_proximities(hass):
|
|||
assert state.state == "0"
|
||||
|
||||
|
||||
async def test_proximities_setup(hass):
|
||||
async def test_proximities_setup(hass: HomeAssistant) -> None:
|
||||
"""Test a list of proximities with missing devices."""
|
||||
config = {
|
||||
"proximity": {
|
||||
|
@ -49,7 +49,7 @@ async def test_proximities_setup(hass):
|
|||
assert await async_setup_component(hass, DOMAIN, config)
|
||||
|
||||
|
||||
async def test_proximity(hass):
|
||||
async def test_proximity(hass: HomeAssistant) -> None:
|
||||
"""Test the proximity."""
|
||||
config = {
|
||||
"proximity": {
|
||||
|
@ -74,7 +74,7 @@ async def test_proximity(hass):
|
|||
assert state.state == "0"
|
||||
|
||||
|
||||
async def test_device_tracker_test1_in_zone(hass):
|
||||
async def test_device_tracker_test1_in_zone(hass: HomeAssistant) -> None:
|
||||
"""Test for tracker in zone."""
|
||||
config = {
|
||||
"proximity": {
|
||||
|
@ -100,7 +100,7 @@ async def test_device_tracker_test1_in_zone(hass):
|
|||
assert state.attributes.get("dir_of_travel") == "arrived"
|
||||
|
||||
|
||||
async def test_device_trackers_in_zone(hass):
|
||||
async def test_device_trackers_in_zone(hass: HomeAssistant) -> None:
|
||||
"""Test for trackers in zone."""
|
||||
config = {
|
||||
"proximity": {
|
||||
|
@ -134,7 +134,7 @@ async def test_device_trackers_in_zone(hass):
|
|||
assert state.attributes.get("dir_of_travel") == "arrived"
|
||||
|
||||
|
||||
async def test_device_tracker_test1_away(hass):
|
||||
async def test_device_tracker_test1_away(hass: HomeAssistant) -> None:
|
||||
"""Test for tracker state away."""
|
||||
config = {
|
||||
"proximity": {
|
||||
|
@ -160,7 +160,7 @@ async def test_device_tracker_test1_away(hass):
|
|||
assert state.attributes.get("dir_of_travel") == "unknown"
|
||||
|
||||
|
||||
async def test_device_tracker_test1_awayfurther(hass):
|
||||
async def test_device_tracker_test1_awayfurther(hass: HomeAssistant) -> None:
|
||||
"""Test for tracker state away further."""
|
||||
|
||||
config_zones(hass)
|
||||
|
@ -199,7 +199,7 @@ async def test_device_tracker_test1_awayfurther(hass):
|
|||
assert state.attributes.get("dir_of_travel") == "away_from"
|
||||
|
||||
|
||||
async def test_device_tracker_test1_awaycloser(hass):
|
||||
async def test_device_tracker_test1_awaycloser(hass: HomeAssistant) -> None:
|
||||
"""Test for tracker state away closer."""
|
||||
config_zones(hass)
|
||||
await hass.async_block_till_done()
|
||||
|
@ -237,7 +237,7 @@ async def test_device_tracker_test1_awaycloser(hass):
|
|||
assert state.attributes.get("dir_of_travel") == "towards"
|
||||
|
||||
|
||||
async def test_all_device_trackers_in_ignored_zone(hass):
|
||||
async def test_all_device_trackers_in_ignored_zone(hass: HomeAssistant) -> None:
|
||||
"""Test for tracker in ignored zone."""
|
||||
config = {
|
||||
"proximity": {
|
||||
|
@ -259,7 +259,7 @@ async def test_all_device_trackers_in_ignored_zone(hass):
|
|||
assert state.attributes.get("dir_of_travel") == "not set"
|
||||
|
||||
|
||||
async def test_device_tracker_test1_no_coordinates(hass):
|
||||
async def test_device_tracker_test1_no_coordinates(hass: HomeAssistant) -> None:
|
||||
"""Test for tracker with no coordinates."""
|
||||
config = {
|
||||
"proximity": {
|
||||
|
@ -282,7 +282,9 @@ async def test_device_tracker_test1_no_coordinates(hass):
|
|||
assert state.attributes.get("dir_of_travel") == "not set"
|
||||
|
||||
|
||||
async def test_device_tracker_test1_awayfurther_than_test2_first_test1(hass):
|
||||
async def test_device_tracker_test1_awayfurther_than_test2_first_test1(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test for tracker ordering."""
|
||||
config_zones(hass)
|
||||
await hass.async_block_till_done()
|
||||
|
@ -332,7 +334,9 @@ async def test_device_tracker_test1_awayfurther_than_test2_first_test1(hass):
|
|||
assert state.attributes.get("dir_of_travel") == "unknown"
|
||||
|
||||
|
||||
async def test_device_tracker_test1_awayfurther_than_test2_first_test2(hass):
|
||||
async def test_device_tracker_test1_awayfurther_than_test2_first_test2(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test for tracker ordering."""
|
||||
config_zones(hass)
|
||||
await hass.async_block_till_done()
|
||||
|
@ -380,7 +384,9 @@ async def test_device_tracker_test1_awayfurther_than_test2_first_test2(hass):
|
|||
assert state.attributes.get("dir_of_travel") == "unknown"
|
||||
|
||||
|
||||
async def test_device_tracker_test1_awayfurther_test2_in_ignored_zone(hass):
|
||||
async def test_device_tracker_test1_awayfurther_test2_in_ignored_zone(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test for tracker states."""
|
||||
hass.states.async_set(
|
||||
"device_tracker.test1", "not_home", {"friendly_name": "test1"}
|
||||
|
@ -413,7 +419,9 @@ async def test_device_tracker_test1_awayfurther_test2_in_ignored_zone(hass):
|
|||
assert state.attributes.get("dir_of_travel") == "unknown"
|
||||
|
||||
|
||||
async def test_device_tracker_test1_awayfurther_test2_first(hass):
|
||||
async def test_device_tracker_test1_awayfurther_test2_first(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test for tracker state."""
|
||||
config_zones(hass)
|
||||
await hass.async_block_till_done()
|
||||
|
@ -477,7 +485,7 @@ async def test_device_tracker_test1_awayfurther_test2_first(hass):
|
|||
assert state.attributes.get("dir_of_travel") == "unknown"
|
||||
|
||||
|
||||
async def test_device_tracker_test1_awayfurther_a_bit(hass):
|
||||
async def test_device_tracker_test1_awayfurther_a_bit(hass: HomeAssistant) -> None:
|
||||
"""Test for tracker states."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
|
@ -515,7 +523,9 @@ async def test_device_tracker_test1_awayfurther_a_bit(hass):
|
|||
assert state.attributes.get("dir_of_travel") == "stationary"
|
||||
|
||||
|
||||
async def test_device_tracker_test1_nearest_after_test2_in_ignored_zone(hass):
|
||||
async def test_device_tracker_test1_nearest_after_test2_in_ignored_zone(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test for tracker states."""
|
||||
config_zones(hass)
|
||||
await hass.async_block_till_done()
|
||||
|
|
|
@ -21,6 +21,7 @@ from homeassistant.const import (
|
|||
CONF_REGION,
|
||||
CONF_TOKEN,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.util import location
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
@ -96,7 +97,7 @@ def ps4_setup_fixture():
|
|||
yield
|
||||
|
||||
|
||||
async def test_full_flow_implementation(hass):
|
||||
async def test_full_flow_implementation(hass: HomeAssistant) -> None:
|
||||
"""Test registering an implementation and flow works."""
|
||||
# User Step Started, results in Step Creds
|
||||
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
||||
|
@ -137,7 +138,7 @@ async def test_full_flow_implementation(hass):
|
|||
assert result["title"] == MOCK_TITLE
|
||||
|
||||
|
||||
async def test_multiple_flow_implementation(hass):
|
||||
async def test_multiple_flow_implementation(hass: HomeAssistant) -> None:
|
||||
"""Test multiple device flows."""
|
||||
# User Step Started, results in Step Creds
|
||||
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
||||
|
@ -242,7 +243,7 @@ async def test_multiple_flow_implementation(hass):
|
|||
assert entry_1 is not entry_2
|
||||
|
||||
|
||||
async def test_port_bind_abort(hass):
|
||||
async def test_port_bind_abort(hass: HomeAssistant) -> None:
|
||||
"""Test that flow aborted when cannot bind to ports 987, 997."""
|
||||
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=MOCK_UDP_PORT):
|
||||
reason = "port_987_bind_error"
|
||||
|
@ -261,7 +262,7 @@ async def test_port_bind_abort(hass):
|
|||
assert result["reason"] == reason
|
||||
|
||||
|
||||
async def test_duplicate_abort(hass):
|
||||
async def test_duplicate_abort(hass: HomeAssistant) -> None:
|
||||
"""Test that Flow aborts when found devices already configured."""
|
||||
MockConfigEntry(domain=ps4.DOMAIN, data=MOCK_DATA).add_to_hass(hass)
|
||||
|
||||
|
@ -289,7 +290,7 @@ async def test_duplicate_abort(hass):
|
|||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_additional_device(hass):
|
||||
async def test_additional_device(hass: HomeAssistant) -> None:
|
||||
"""Test that Flow can configure another device."""
|
||||
# Mock existing entry.
|
||||
entry = MockConfigEntry(domain=ps4.DOMAIN, data=MOCK_DATA)
|
||||
|
@ -328,7 +329,7 @@ async def test_additional_device(hass):
|
|||
assert result["title"] == MOCK_TITLE
|
||||
|
||||
|
||||
async def test_0_pin(hass):
|
||||
async def test_0_pin(hass: HomeAssistant) -> None:
|
||||
"""Test Pin with leading '0' is passed correctly."""
|
||||
with patch("pyps4_2ndscreen.Helper.get_creds", return_value=MOCK_CREDS):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -366,7 +367,7 @@ async def test_0_pin(hass):
|
|||
)
|
||||
|
||||
|
||||
async def test_no_devices_found_abort(hass):
|
||||
async def test_no_devices_found_abort(hass: HomeAssistant) -> None:
|
||||
"""Test that failure to find devices aborts flow."""
|
||||
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -391,7 +392,7 @@ async def test_no_devices_found_abort(hass):
|
|||
assert result["reason"] == "no_devices_found"
|
||||
|
||||
|
||||
async def test_manual_mode(hass):
|
||||
async def test_manual_mode(hass: HomeAssistant) -> None:
|
||||
"""Test host specified in manual mode is passed to Step Link."""
|
||||
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -419,7 +420,7 @@ async def test_manual_mode(hass):
|
|||
assert result["step_id"] == "link"
|
||||
|
||||
|
||||
async def test_credential_abort(hass):
|
||||
async def test_credential_abort(hass: HomeAssistant) -> None:
|
||||
"""Test that failure to get credentials aborts flow."""
|
||||
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -437,7 +438,7 @@ async def test_credential_abort(hass):
|
|||
assert result["reason"] == "credential_error"
|
||||
|
||||
|
||||
async def test_credential_timeout(hass):
|
||||
async def test_credential_timeout(hass: HomeAssistant) -> None:
|
||||
"""Test that Credential Timeout shows error."""
|
||||
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -456,7 +457,7 @@ async def test_credential_timeout(hass):
|
|||
assert result["errors"] == {"base": "credential_timeout"}
|
||||
|
||||
|
||||
async def test_wrong_pin_error(hass):
|
||||
async def test_wrong_pin_error(hass: HomeAssistant) -> None:
|
||||
"""Test that incorrect pin throws an error."""
|
||||
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -488,7 +489,7 @@ async def test_wrong_pin_error(hass):
|
|||
assert result["errors"] == {"base": "login_failed"}
|
||||
|
||||
|
||||
async def test_device_connection_error(hass):
|
||||
async def test_device_connection_error(hass: HomeAssistant) -> None:
|
||||
"""Test that device not connected or on throws an error."""
|
||||
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -520,7 +521,7 @@ async def test_device_connection_error(hass):
|
|||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
async def test_manual_mode_no_ip_error(hass):
|
||||
async def test_manual_mode_no_ip_error(hass: HomeAssistant) -> None:
|
||||
"""Test no IP specified in manual mode throws an error."""
|
||||
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
|
|
@ -109,14 +109,14 @@ MOCK_GAMES = {MOCK_ID: MOCK_GAMES_DATA}
|
|||
MOCK_GAMES_LOCKED = {MOCK_ID: MOCK_GAMES_DATA_LOCKED}
|
||||
|
||||
|
||||
async def test_ps4_integration_setup(hass):
|
||||
async def test_ps4_integration_setup(hass: HomeAssistant) -> None:
|
||||
"""Test PS4 integration is setup."""
|
||||
await ps4.async_setup(hass, {})
|
||||
await hass.async_block_till_done()
|
||||
assert hass.data[PS4_DATA].protocol is not None
|
||||
|
||||
|
||||
async def test_creating_entry_sets_up_media_player(hass):
|
||||
async def test_creating_entry_sets_up_media_player(hass: HomeAssistant) -> None:
|
||||
"""Test setting up PS4 loads the media player."""
|
||||
mock_flow = "homeassistant.components.ps4.PlayStation4FlowHandler.async_step_user"
|
||||
with patch(
|
||||
|
@ -133,7 +133,7 @@ async def test_creating_entry_sets_up_media_player(hass):
|
|||
assert len(mock_setup.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_config_flow_entry_migrate(hass):
|
||||
async def test_config_flow_entry_migrate(hass: HomeAssistant) -> None:
|
||||
"""Test that config flow entry is migrated correctly."""
|
||||
# Start with the config entry at Version 1.
|
||||
manager = hass.config_entries
|
||||
|
@ -182,7 +182,7 @@ async def test_config_flow_entry_migrate(hass):
|
|||
assert mock_entry.data["devices"][0][CONF_REGION] == DEFAULT_REGION
|
||||
|
||||
|
||||
async def test_media_player_is_setup(hass):
|
||||
async def test_media_player_is_setup(hass: HomeAssistant) -> None:
|
||||
"""Test media_player is setup correctly."""
|
||||
await setup_mock_component(hass)
|
||||
assert len(hass.data[PS4_DATA].devices) == 1
|
||||
|
@ -269,7 +269,7 @@ def test_loading_games_returns_dict(hass: HomeAssistant) -> None:
|
|||
assert not mock_games
|
||||
|
||||
|
||||
async def test_send_command(hass):
|
||||
async def test_send_command(hass: HomeAssistant) -> None:
|
||||
"""Test send_command service."""
|
||||
await setup_mock_component(hass)
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ from homeassistant.const import (
|
|||
STATE_STANDBY,
|
||||
STATE_UNKNOWN,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import MockConfigEntry, mock_device_registry, mock_registry
|
||||
|
@ -162,7 +163,7 @@ async def mock_ddp_response(hass, mock_status_data):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
async def test_media_player_is_setup_correctly_with_entry(hass):
|
||||
async def test_media_player_is_setup_correctly_with_entry(hass: HomeAssistant) -> None:
|
||||
"""Test entity is setup correctly with entry correctly."""
|
||||
mock_entity_id = await setup_mock_component(hass)
|
||||
mock_state = hass.states.get(mock_entity_id).state
|
||||
|
@ -176,7 +177,7 @@ async def test_media_player_is_setup_correctly_with_entry(hass):
|
|||
assert mock_state == STATE_UNKNOWN
|
||||
|
||||
|
||||
async def test_state_standby_is_set(hass):
|
||||
async def test_state_standby_is_set(hass: HomeAssistant) -> None:
|
||||
"""Test that state is set to standby."""
|
||||
mock_entity_id = await setup_mock_component(hass)
|
||||
|
||||
|
@ -185,7 +186,7 @@ async def test_state_standby_is_set(hass):
|
|||
assert hass.states.get(mock_entity_id).state == STATE_STANDBY
|
||||
|
||||
|
||||
async def test_state_playing_is_set(hass):
|
||||
async def test_state_playing_is_set(hass: HomeAssistant) -> None:
|
||||
"""Test that state is set to playing."""
|
||||
mock_entity_id = await setup_mock_component(hass)
|
||||
mock_func = "{}{}".format(
|
||||
|
@ -199,7 +200,7 @@ async def test_state_playing_is_set(hass):
|
|||
assert hass.states.get(mock_entity_id).state == STATE_PLAYING
|
||||
|
||||
|
||||
async def test_state_idle_is_set(hass):
|
||||
async def test_state_idle_is_set(hass: HomeAssistant) -> None:
|
||||
"""Test that state is set to idle."""
|
||||
mock_entity_id = await setup_mock_component(hass)
|
||||
|
||||
|
@ -208,14 +209,14 @@ async def test_state_idle_is_set(hass):
|
|||
assert hass.states.get(mock_entity_id).state == STATE_IDLE
|
||||
|
||||
|
||||
async def test_state_none_is_set(hass):
|
||||
async def test_state_none_is_set(hass: HomeAssistant) -> None:
|
||||
"""Test that state is set to None."""
|
||||
mock_entity_id = await setup_mock_component(hass)
|
||||
|
||||
assert hass.states.get(mock_entity_id).state == STATE_UNKNOWN
|
||||
|
||||
|
||||
async def test_media_attributes_are_fetched(hass):
|
||||
async def test_media_attributes_are_fetched(hass: HomeAssistant) -> None:
|
||||
"""Test that media attributes are fetched."""
|
||||
mock_entity_id = await setup_mock_component(hass)
|
||||
mock_func = "{}{}".format(
|
||||
|
@ -313,7 +314,7 @@ async def test_device_info_is_set_from_status_correctly(hass, patch_get_status):
|
|||
assert mock_entry.identifiers == {(DOMAIN, MOCK_HOST_ID)}
|
||||
|
||||
|
||||
async def test_device_info_is_assummed(hass):
|
||||
async def test_device_info_is_assummed(hass: HomeAssistant) -> None:
|
||||
"""Test that device info is assumed if device is unavailable."""
|
||||
# Create a device registry entry with device info.
|
||||
mock_d_registry = mock_device_registry(hass)
|
||||
|
@ -349,7 +350,7 @@ async def test_device_info_is_assummed(hass):
|
|||
assert mock_entities[0] == mock_entity_id
|
||||
|
||||
|
||||
async def test_device_info_assummed_works(hass):
|
||||
async def test_device_info_assummed_works(hass: HomeAssistant) -> None:
|
||||
"""Reverse test that device info assumption works."""
|
||||
mock_d_registry = mock_device_registry(hass)
|
||||
mock_entity_id = await setup_mock_component(hass)
|
||||
|
@ -363,7 +364,7 @@ async def test_device_info_assummed_works(hass):
|
|||
assert not mock_d_entries
|
||||
|
||||
|
||||
async def test_turn_on(hass):
|
||||
async def test_turn_on(hass: HomeAssistant) -> None:
|
||||
"""Test that turn on service calls function."""
|
||||
mock_entity_id = await setup_mock_component(hass)
|
||||
mock_func = "{}{}".format(
|
||||
|
@ -379,7 +380,7 @@ async def test_turn_on(hass):
|
|||
assert len(mock_call.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_turn_off(hass):
|
||||
async def test_turn_off(hass: HomeAssistant) -> None:
|
||||
"""Test that turn off service calls function."""
|
||||
mock_entity_id = await setup_mock_component(hass)
|
||||
mock_func = "{}{}".format(
|
||||
|
@ -395,7 +396,7 @@ async def test_turn_off(hass):
|
|||
assert len(mock_call.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_toggle(hass):
|
||||
async def test_toggle(hass: HomeAssistant) -> None:
|
||||
"""Test that toggle service calls function."""
|
||||
mock_entity_id = await setup_mock_component(hass)
|
||||
mock_func = "{}{}".format(
|
||||
|
@ -411,7 +412,7 @@ async def test_toggle(hass):
|
|||
assert len(mock_call.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_media_pause(hass):
|
||||
async def test_media_pause(hass: HomeAssistant) -> None:
|
||||
"""Test that media pause service calls function."""
|
||||
mock_entity_id = await setup_mock_component(hass)
|
||||
mock_func = "{}{}".format(
|
||||
|
@ -427,7 +428,7 @@ async def test_media_pause(hass):
|
|||
assert len(mock_call.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_media_stop(hass):
|
||||
async def test_media_stop(hass: HomeAssistant) -> None:
|
||||
"""Test that media stop service calls function."""
|
||||
mock_entity_id = await setup_mock_component(hass)
|
||||
mock_func = "{}{}".format(
|
||||
|
@ -506,7 +507,7 @@ async def test_select_source_id(hass, patch_load_json):
|
|||
assert len(mock_call.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_ps4_send_command(hass):
|
||||
async def test_ps4_send_command(hass: HomeAssistant) -> None:
|
||||
"""Test that ps4 send command service calls function."""
|
||||
mock_entity_id = await setup_mock_component(hass)
|
||||
|
||||
|
@ -521,7 +522,7 @@ async def test_ps4_send_command(hass):
|
|||
assert len(mock_call.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_entry_is_unloaded(hass):
|
||||
async def test_entry_is_unloaded(hass: HomeAssistant) -> None:
|
||||
"""Test that entry is unloaded."""
|
||||
mock_entry = MockConfigEntry(
|
||||
domain=ps4.DOMAIN, data=MOCK_DATA, version=VERSION, entry_id=MOCK_ENTRY_ID
|
||||
|
|
|
@ -4,13 +4,17 @@ from http import HTTPStatus
|
|||
import io
|
||||
|
||||
from homeassistant.config import async_process_ha_core_config
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
from tests.common import async_fire_time_changed
|
||||
from tests.typing import ClientSessionGenerator
|
||||
|
||||
|
||||
async def test_bad_posting(hass, hass_client_no_auth):
|
||||
async def test_bad_posting(
|
||||
hass: HomeAssistant, hass_client_no_auth: ClientSessionGenerator
|
||||
) -> None:
|
||||
"""Test that posting to wrong api endpoint fails."""
|
||||
await async_process_ha_core_config(
|
||||
hass,
|
||||
|
@ -41,7 +45,9 @@ async def test_bad_posting(hass, hass_client_no_auth):
|
|||
assert camera_state.state == "idle" # no file supplied we are still idle
|
||||
|
||||
|
||||
async def test_posting_url(hass, hass_client_no_auth):
|
||||
async def test_posting_url(
|
||||
hass: HomeAssistant, hass_client_no_auth: ClientSessionGenerator
|
||||
) -> None:
|
||||
"""Test that posting to api endpoint works."""
|
||||
await async_process_ha_core_config(
|
||||
hass,
|
||||
|
|
|
@ -2,14 +2,17 @@
|
|||
import logging
|
||||
from unittest.mock import mock_open, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.python_script import DOMAIN, FOLDER, execute
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.service import async_get_all_descriptions
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import patch_yaml_files
|
||||
|
||||
|
||||
async def test_setup(hass):
|
||||
async def test_setup(hass: HomeAssistant) -> None:
|
||||
"""Test we can discover scripts."""
|
||||
scripts = [
|
||||
"/some/config/dir/python_scripts/hello.py",
|
||||
|
@ -42,7 +45,9 @@ async def test_setup(hass):
|
|||
assert data == {"some": "data"}
|
||||
|
||||
|
||||
async def test_setup_fails_on_no_dir(hass, caplog):
|
||||
async def test_setup_fails_on_no_dir(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Test we fail setup when no dir found."""
|
||||
with patch(
|
||||
"homeassistant.components.python_script.os.path.isdir", return_value=False
|
||||
|
@ -53,7 +58,9 @@ async def test_setup_fails_on_no_dir(hass, caplog):
|
|||
assert "Folder python_scripts not found in configuration folder" in caplog.text
|
||||
|
||||
|
||||
async def test_execute_with_data(hass, caplog):
|
||||
async def test_execute_with_data(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Test executing a script."""
|
||||
caplog.set_level(logging.WARNING)
|
||||
source = """
|
||||
|
@ -69,7 +76,9 @@ hass.states.set('test.entity', data.get('name', 'not set'))
|
|||
assert caplog.text == ""
|
||||
|
||||
|
||||
async def test_execute_warns_print(hass, caplog):
|
||||
async def test_execute_warns_print(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Test print triggers warning."""
|
||||
caplog.set_level(logging.WARNING)
|
||||
source = """
|
||||
|
@ -82,7 +91,9 @@ print("This triggers warning.")
|
|||
assert "Don't use print() inside scripts." in caplog.text
|
||||
|
||||
|
||||
async def test_execute_logging(hass, caplog):
|
||||
async def test_execute_logging(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Test logging works."""
|
||||
caplog.set_level(logging.INFO)
|
||||
source = """
|
||||
|
@ -95,7 +106,9 @@ logger.info('Logging from inside script')
|
|||
assert "Logging from inside script" in caplog.text
|
||||
|
||||
|
||||
async def test_execute_compile_error(hass, caplog):
|
||||
async def test_execute_compile_error(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Test compile error logs error."""
|
||||
caplog.set_level(logging.ERROR)
|
||||
source = """
|
||||
|
@ -108,7 +121,9 @@ this is not valid Python
|
|||
assert "Error loading script test.py" in caplog.text
|
||||
|
||||
|
||||
async def test_execute_runtime_error(hass, caplog):
|
||||
async def test_execute_runtime_error(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Test compile error logs error."""
|
||||
caplog.set_level(logging.ERROR)
|
||||
source = """
|
||||
|
@ -121,7 +136,9 @@ raise Exception('boom')
|
|||
assert "Error executing script: boom" in caplog.text
|
||||
|
||||
|
||||
async def test_accessing_async_methods(hass, caplog):
|
||||
async def test_accessing_async_methods(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Test compile error logs error."""
|
||||
caplog.set_level(logging.ERROR)
|
||||
source = """
|
||||
|
@ -134,7 +151,9 @@ hass.async_stop()
|
|||
assert "Not allowed to access async methods" in caplog.text
|
||||
|
||||
|
||||
async def test_using_complex_structures(hass, caplog):
|
||||
async def test_using_complex_structures(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Test that dicts and lists work."""
|
||||
caplog.set_level(logging.INFO)
|
||||
source = """
|
||||
|
@ -149,7 +168,9 @@ logger.info('Logging from inside script: %s %s' % (mydict["a"], mylist[2]))
|
|||
assert "Logging from inside script: 1 3" in caplog.text
|
||||
|
||||
|
||||
async def test_accessing_forbidden_methods(hass, caplog):
|
||||
async def test_accessing_forbidden_methods(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Test compile error logs error."""
|
||||
caplog.set_level(logging.ERROR)
|
||||
|
||||
|
@ -165,7 +186,7 @@ async def test_accessing_forbidden_methods(hass, caplog):
|
|||
assert f"Not allowed to access {name}" in caplog.text
|
||||
|
||||
|
||||
async def test_iterating(hass):
|
||||
async def test_iterating(hass: HomeAssistant) -> None:
|
||||
"""Test compile error logs error."""
|
||||
source = """
|
||||
for i in [1, 2]:
|
||||
|
@ -179,7 +200,7 @@ for i in [1, 2]:
|
|||
assert hass.states.is_state("hello.2", "world")
|
||||
|
||||
|
||||
async def test_using_enumerate(hass):
|
||||
async def test_using_enumerate(hass: HomeAssistant) -> None:
|
||||
"""Test that enumerate is accepted and executed."""
|
||||
source = """
|
||||
for index, value in enumerate(["earth", "mars"]):
|
||||
|
@ -193,7 +214,9 @@ for index, value in enumerate(["earth", "mars"]):
|
|||
assert hass.states.is_state("hello.1", "mars")
|
||||
|
||||
|
||||
async def test_unpacking_sequence(hass, caplog):
|
||||
async def test_unpacking_sequence(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Test compile error logs error."""
|
||||
caplog.set_level(logging.ERROR)
|
||||
source = """
|
||||
|
@ -215,7 +238,9 @@ hass.states.set('hello.ab_list', '{}'.format(ab_list))
|
|||
assert caplog.text == ""
|
||||
|
||||
|
||||
async def test_execute_sorted(hass, caplog):
|
||||
async def test_execute_sorted(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Test sorted() function."""
|
||||
caplog.set_level(logging.ERROR)
|
||||
source = """
|
||||
|
@ -235,7 +260,9 @@ hass.states.set('hello.c', a[2])
|
|||
assert caplog.text == ""
|
||||
|
||||
|
||||
async def test_exposed_modules(hass, caplog):
|
||||
async def test_exposed_modules(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Test datetime and time modules exposed."""
|
||||
caplog.set_level(logging.ERROR)
|
||||
source = """
|
||||
|
@ -257,7 +284,9 @@ hass.states.set('module.datetime',
|
|||
assert caplog.text == ""
|
||||
|
||||
|
||||
async def test_execute_functions(hass, caplog):
|
||||
async def test_execute_functions(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Test functions defined in script can call one another."""
|
||||
caplog.set_level(logging.ERROR)
|
||||
source = """
|
||||
|
@ -279,7 +308,7 @@ b()
|
|||
assert caplog.text == ""
|
||||
|
||||
|
||||
async def test_reload(hass):
|
||||
async def test_reload(hass: HomeAssistant) -> None:
|
||||
"""Test we can re-discover scripts."""
|
||||
scripts = [
|
||||
"/some/config/dir/python_scripts/hello.py",
|
||||
|
@ -310,7 +339,7 @@ async def test_reload(hass):
|
|||
assert hass.services.has_service("python_script", "reload")
|
||||
|
||||
|
||||
async def test_service_descriptions(hass):
|
||||
async def test_service_descriptions(hass: HomeAssistant) -> None:
|
||||
"""Test that service descriptions are loaded and reloaded correctly."""
|
||||
# Test 1: no user-provided services.yaml file
|
||||
scripts1 = [
|
||||
|
@ -409,7 +438,9 @@ async def test_service_descriptions(hass):
|
|||
)
|
||||
|
||||
|
||||
async def test_sleep_warns_one(hass, caplog):
|
||||
async def test_sleep_warns_one(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Test time.sleep warns once."""
|
||||
caplog.set_level(logging.WARNING)
|
||||
source = """
|
||||
|
|
Loading…
Reference in New Issue