Remove unnecessary DOMAIN alias in tests (s-z) (#146010)

This commit is contained in:
epenet 2025-06-02 08:48:37 +02:00 committed by GitHub
parent 43ac550ca0
commit de4a5fa30b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
24 changed files with 113 additions and 128 deletions

View File

@ -15,7 +15,7 @@ from homeassistant.components.number import NumberDeviceClass
from homeassistant.components.sensor import ( from homeassistant.components.sensor import (
DEVICE_CLASS_STATE_CLASSES, DEVICE_CLASS_STATE_CLASSES,
DEVICE_CLASS_UNITS, DEVICE_CLASS_UNITS,
DOMAIN as SENSOR_DOMAIN, DOMAIN,
NON_NUMERIC_DEVICE_CLASSES, NON_NUMERIC_DEVICE_CLASSES,
SensorDeviceClass, SensorDeviceClass,
SensorEntity, SensorEntity,
@ -2752,7 +2752,7 @@ async def test_name(hass: HomeAssistant) -> None:
mock_platform( mock_platform(
hass, hass,
f"{TEST_DOMAIN}.{SENSOR_DOMAIN}", f"{TEST_DOMAIN}.{DOMAIN}",
MockPlatform(async_setup_entry=async_setup_entry_platform), MockPlatform(async_setup_entry=async_setup_entry_platform),
) )

View File

@ -6,10 +6,7 @@ from unittest.mock import AsyncMock, MagicMock, patch
import pytest import pytest
from solarlog_cli.solarlog_models import InverterData, SolarlogData from solarlog_cli.solarlog_models import InverterData, SolarlogData
from homeassistant.components.solarlog.const import ( from homeassistant.components.solarlog.const import CONF_HAS_PWD, DOMAIN
CONF_HAS_PWD,
DOMAIN as SOLARLOG_DOMAIN,
)
from homeassistant.const import CONF_HOST, CONF_PASSWORD from homeassistant.const import CONF_HOST, CONF_PASSWORD
from .const import HOST from .const import HOST
@ -34,7 +31,7 @@ INVERTER_DATA = {
def mock_config_entry() -> MockConfigEntry: def mock_config_entry() -> MockConfigEntry:
"""Mock a config entry.""" """Mock a config entry."""
return MockConfigEntry( return MockConfigEntry(
domain=SOLARLOG_DOMAIN, domain=DOMAIN,
title="solarlog", title="solarlog",
data={ data={
CONF_HOST: HOST, CONF_HOST: HOST,
@ -51,7 +48,7 @@ def mock_solarlog_connector():
"""Build a fixture for the SolarLog API that connects successfully and returns one device.""" """Build a fixture for the SolarLog API that connects successfully and returns one device."""
data = SolarlogData.from_dict( data = SolarlogData.from_dict(
load_json_object_fixture("solarlog_data.json", SOLARLOG_DOMAIN) load_json_object_fixture("solarlog_data.json", DOMAIN)
) )
data.inverter_data = INVERTER_DATA data.inverter_data = INVERTER_DATA

View File

@ -27,7 +27,7 @@ from homeassistant.components.media_player import (
RepeatMode, RepeatMode,
) )
from homeassistant.components.sonos.const import ( from homeassistant.components.sonos.const import (
DOMAIN as SONOS_DOMAIN, DOMAIN,
MEDIA_TYPE_DIRECTORY, MEDIA_TYPE_DIRECTORY,
SOURCE_LINEIN, SOURCE_LINEIN,
SOURCE_TV, SOURCE_TV,
@ -1012,7 +1012,7 @@ async def test_play_media_favorite_item_id(
async def _setup_hass(hass: HomeAssistant): async def _setup_hass(hass: HomeAssistant):
await async_setup_component( await async_setup_component(
hass, hass,
SONOS_DOMAIN, DOMAIN,
{ {
"sonos": { "sonos": {
"media_player": { "media_player": {
@ -1037,7 +1037,7 @@ async def test_service_snapshot_restore(
"homeassistant.components.sonos.speaker.Snapshot.snapshot" "homeassistant.components.sonos.speaker.Snapshot.snapshot"
) as mock_snapshot: ) as mock_snapshot:
await hass.services.async_call( await hass.services.async_call(
SONOS_DOMAIN, DOMAIN,
SERVICE_SNAPSHOT, SERVICE_SNAPSHOT,
{ {
ATTR_ENTITY_ID: ["media_player.living_room", "media_player.bedroom"], ATTR_ENTITY_ID: ["media_player.living_room", "media_player.bedroom"],
@ -1050,7 +1050,7 @@ async def test_service_snapshot_restore(
"homeassistant.components.sonos.speaker.Snapshot.restore" "homeassistant.components.sonos.speaker.Snapshot.restore"
) as mock_restore: ) as mock_restore:
await hass.services.async_call( await hass.services.async_call(
SONOS_DOMAIN, DOMAIN,
SERVICE_RESTORE, SERVICE_RESTORE,
{ {
ATTR_ENTITY_ID: ["media_player.living_room", "media_player.bedroom"], ATTR_ENTITY_ID: ["media_player.living_room", "media_player.bedroom"],
@ -1227,7 +1227,7 @@ async def test_media_get_queue(
"""Test getting the media queue.""" """Test getting the media queue."""
soco_mock = soco_factory.mock_list.get("192.168.42.2") soco_mock = soco_factory.mock_list.get("192.168.42.2")
result = await hass.services.async_call( result = await hass.services.async_call(
SONOS_DOMAIN, DOMAIN,
SERVICE_GET_QUEUE, SERVICE_GET_QUEUE,
{ {
ATTR_ENTITY_ID: "media_player.zone_a", ATTR_ENTITY_ID: "media_player.zone_a",

View File

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
from homeassistant.components.statistics import DOMAIN as STATISTICS_DOMAIN from homeassistant.components.statistics import DOMAIN
from homeassistant.config_entries import ConfigEntryState from homeassistant.config_entries import ConfigEntryState
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr, entity_registry as er from homeassistant.helpers import device_registry as dr, entity_registry as er
@ -51,7 +51,7 @@ async def test_device_cleaning(
# Configure the configuration entry for Statistics # Configure the configuration entry for Statistics
statistics_config_entry = MockConfigEntry( statistics_config_entry = MockConfigEntry(
data={}, data={},
domain=STATISTICS_DOMAIN, domain=DOMAIN,
options={ options={
"name": "Statistics", "name": "Statistics",
"entity_id": "sensor.test_source", "entity_id": "sensor.test_source",

View File

@ -20,7 +20,7 @@ from homeassistant.components.sensor import (
SensorDeviceClass, SensorDeviceClass,
SensorStateClass, SensorStateClass,
) )
from homeassistant.components.statistics import DOMAIN as STATISTICS_DOMAIN from homeassistant.components.statistics import DOMAIN
from homeassistant.components.statistics.sensor import ( from homeassistant.components.statistics.sensor import (
CONF_KEEP_LAST_SAMPLE, CONF_KEEP_LAST_SAMPLE,
CONF_PERCENTILE, CONF_PERCENTILE,
@ -78,7 +78,7 @@ async def test_unique_id(
await hass.async_block_till_done() await hass.async_block_till_done()
entity_id = entity_registry.async_get_entity_id( entity_id = entity_registry.async_get_entity_id(
"sensor", STATISTICS_DOMAIN, "uniqueid_sensor_test" "sensor", DOMAIN, "uniqueid_sensor_test"
) )
assert entity_id == "sensor.test" assert entity_id == "sensor.test"
@ -1652,7 +1652,7 @@ async def test_reload(recorder_mock: Recorder, hass: HomeAssistant) -> None:
yaml_path = get_fixture_path("configuration.yaml", "statistics") yaml_path = get_fixture_path("configuration.yaml", "statistics")
with patch.object(hass_config, "YAML_CONFIG_FILE", yaml_path): with patch.object(hass_config, "YAML_CONFIG_FILE", yaml_path):
await hass.services.async_call( await hass.services.async_call(
STATISTICS_DOMAIN, DOMAIN,
SERVICE_RELOAD, SERVICE_RELOAD,
{}, {},
blocking=True, blocking=True,
@ -1690,7 +1690,7 @@ async def test_device_id(
statistics_config_entry = MockConfigEntry( statistics_config_entry = MockConfigEntry(
data={}, data={},
domain=STATISTICS_DOMAIN, domain=DOMAIN,
options={ options={
"name": "Statistics", "name": "Statistics",
"entity_id": "sensor.test_source", "entity_id": "sensor.test_source",

View File

@ -8,7 +8,7 @@ from voluptuous.error import MultipleInvalid
from homeassistant.components.lock import DOMAIN as LOCK_DOMAIN from homeassistant.components.lock import DOMAIN as LOCK_DOMAIN
from homeassistant.components.subaru.const import ( from homeassistant.components.subaru.const import (
ATTR_DOOR, ATTR_DOOR,
DOMAIN as SUBARU_DOMAIN, DOMAIN,
SERVICE_UNLOCK_SPECIFIC_DOOR, SERVICE_UNLOCK_SPECIFIC_DOOR,
UNLOCK_DOOR_DRIVERS, UNLOCK_DOOR_DRIVERS,
) )
@ -68,7 +68,7 @@ async def test_unlock_specific_door(hass: HomeAssistant, ev_entry) -> None:
"""Test subaru unlock specific door function.""" """Test subaru unlock specific door function."""
with patch(MOCK_API_UNLOCK) as mock_unlock: with patch(MOCK_API_UNLOCK) as mock_unlock:
await hass.services.async_call( await hass.services.async_call(
SUBARU_DOMAIN, DOMAIN,
SERVICE_UNLOCK_SPECIFIC_DOOR, SERVICE_UNLOCK_SPECIFIC_DOOR,
{ATTR_ENTITY_ID: DEVICE_ID, ATTR_DOOR: UNLOCK_DOOR_DRIVERS}, {ATTR_ENTITY_ID: DEVICE_ID, ATTR_DOOR: UNLOCK_DOOR_DRIVERS},
blocking=True, blocking=True,
@ -81,7 +81,7 @@ async def test_unlock_specific_door_invalid(hass: HomeAssistant, ev_entry) -> No
"""Test subaru unlock specific door function.""" """Test subaru unlock specific door function."""
with patch(MOCK_API_UNLOCK) as mock_unlock, pytest.raises(MultipleInvalid): with patch(MOCK_API_UNLOCK) as mock_unlock, pytest.raises(MultipleInvalid):
await hass.services.async_call( await hass.services.async_call(
SUBARU_DOMAIN, DOMAIN,
SERVICE_UNLOCK_SPECIFIC_DOOR, SERVICE_UNLOCK_SPECIFIC_DOOR,
{ATTR_ENTITY_ID: DEVICE_ID, ATTR_DOOR: "bad_value"}, {ATTR_ENTITY_ID: DEVICE_ID, ATTR_DOOR: "bad_value"},
blocking=True, blocking=True,

View File

@ -8,7 +8,7 @@ import pytest
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
from homeassistant.components.subaru.sensor import ( from homeassistant.components.subaru.sensor import (
API_GEN_2_SENSORS, API_GEN_2_SENSORS,
DOMAIN as SUBARU_DOMAIN, DOMAIN,
EV_SENSORS, EV_SENSORS,
SAFETY_SENSORS, SAFETY_SENSORS,
) )
@ -50,7 +50,7 @@ async def test_sensors_missing_vin_data(hass: HomeAssistant, ev_entry) -> None:
( (
{ {
"domain": SENSOR_DOMAIN, "domain": SENSOR_DOMAIN,
"platform": SUBARU_DOMAIN, "platform": DOMAIN,
"unique_id": f"{TEST_VIN_2_EV}_Avg fuel consumption", "unique_id": f"{TEST_VIN_2_EV}_Avg fuel consumption",
}, },
f"{TEST_VIN_2_EV}_Avg fuel consumption", f"{TEST_VIN_2_EV}_Avg fuel consumption",
@ -86,7 +86,7 @@ async def test_sensor_migrate_unique_ids(
( (
{ {
"domain": SENSOR_DOMAIN, "domain": SENSOR_DOMAIN,
"platform": SUBARU_DOMAIN, "platform": DOMAIN,
"unique_id": f"{TEST_VIN_2_EV}_Avg fuel consumption", "unique_id": f"{TEST_VIN_2_EV}_Avg fuel consumption",
}, },
f"{TEST_VIN_2_EV}_Avg fuel consumption", f"{TEST_VIN_2_EV}_Avg fuel consumption",
@ -112,7 +112,7 @@ async def test_sensor_migrate_unique_ids_duplicate(
# create existing entry with new_unique_id that conflicts with migrate # create existing entry with new_unique_id that conflicts with migrate
existing_entity = entity_registry.async_get_or_create( existing_entity = entity_registry.async_get_or_create(
SENSOR_DOMAIN, SENSOR_DOMAIN,
SUBARU_DOMAIN, DOMAIN,
unique_id=new_unique_id, unique_id=new_unique_id,
config_entry=subaru_config_entry, config_entry=subaru_config_entry,
) )
@ -138,7 +138,7 @@ def _assert_data(hass: HomeAssistant, expected_state: dict[str, Any]) -> None:
entity_registry = er.async_get(hass) entity_registry = er.async_get(hass)
for item in sensor_list: for item in sensor_list:
entity = entity_registry.async_get_entity_id( entity = entity_registry.async_get_entity_id(
SENSOR_DOMAIN, SUBARU_DOMAIN, f"{TEST_VIN_2_EV}_{item.key}" SENSOR_DOMAIN, DOMAIN, f"{TEST_VIN_2_EV}_{item.key}"
) )
expected_states[entity] = expected_state[item.key] expected_states[entity] = expected_state[item.key]

View File

@ -15,7 +15,7 @@ from homeassistant.components import media_source
from homeassistant.components.tts import ( from homeassistant.components.tts import (
CONF_LANG, CONF_LANG,
DATA_TTS_MANAGER, DATA_TTS_MANAGER,
DOMAIN as TTS_DOMAIN, DOMAIN,
PLATFORM_SCHEMA as TTS_PLATFORM_SCHEMA, PLATFORM_SCHEMA as TTS_PLATFORM_SCHEMA,
Provider, Provider,
ResultStream, ResultStream,
@ -212,11 +212,9 @@ async def mock_setup(
) -> None: ) -> None:
"""Set up a test provider.""" """Set up a test provider."""
mock_integration(hass, MockModule(domain=TEST_DOMAIN)) mock_integration(hass, MockModule(domain=TEST_DOMAIN))
mock_platform(hass, f"{TEST_DOMAIN}.{TTS_DOMAIN}", MockTTS(mock_provider)) mock_platform(hass, f"{TEST_DOMAIN}.{DOMAIN}", MockTTS(mock_provider))
await async_setup_component( await async_setup_component(hass, DOMAIN, {DOMAIN: {"platform": TEST_DOMAIN}})
hass, TTS_DOMAIN, {TTS_DOMAIN: {"platform": TEST_DOMAIN}}
)
await hass.async_block_till_done() await hass.async_block_till_done()
@ -261,7 +259,7 @@ async def mock_config_entry_setup(
async_add_entities([tts_entity]) async_add_entities([tts_entity])
loaded_platform = MockPlatform(async_setup_entry=async_setup_entry_platform) loaded_platform = MockPlatform(async_setup_entry=async_setup_entry_platform)
mock_platform(hass, f"{test_domain}.{TTS_DOMAIN}", loaded_platform) mock_platform(hass, f"{test_domain}.{DOMAIN}", loaded_platform)
config_entry = MockConfigEntry(domain=test_domain) config_entry = MockConfigEntry(domain=test_domain)
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)

View File

@ -14,7 +14,7 @@ import orjson
import pytest import pytest
from homeassistant.components.unifi import STORAGE_KEY, STORAGE_VERSION from homeassistant.components.unifi import STORAGE_KEY, STORAGE_VERSION
from homeassistant.components.unifi.const import CONF_SITE_ID, DOMAIN as UNIFI_DOMAIN from homeassistant.components.unifi.const import CONF_SITE_ID, DOMAIN
from homeassistant.components.unifi.hub.websocket import RETRY_TIMER from homeassistant.components.unifi.hub.websocket import RETRY_TIMER
from homeassistant.const import ( from homeassistant.const import (
CONF_HOST, CONF_HOST,
@ -112,7 +112,7 @@ def fixture_config_entry(
) -> MockConfigEntry: ) -> MockConfigEntry:
"""Define a config entry fixture.""" """Define a config entry fixture."""
config_entry = MockConfigEntry( config_entry = MockConfigEntry(
domain=UNIFI_DOMAIN, domain=DOMAIN,
entry_id="1", entry_id="1",
unique_id="1", unique_id="1",
data=config_entry_data, data=config_entry_data,

View File

@ -21,7 +21,7 @@ from homeassistant.components.unifi.const import (
CONF_TRACK_CLIENTS, CONF_TRACK_CLIENTS,
CONF_TRACK_DEVICES, CONF_TRACK_DEVICES,
CONF_TRACK_WIRED_CLIENTS, CONF_TRACK_WIRED_CLIENTS,
DOMAIN as UNIFI_DOMAIN, DOMAIN,
) )
from homeassistant.const import ( from homeassistant.const import (
CONF_HOST, CONF_HOST,
@ -100,7 +100,7 @@ async def test_flow_works(hass: HomeAssistant, mock_discovery) -> None:
"""Test config flow.""" """Test config flow."""
mock_discovery.return_value = "1" mock_discovery.return_value = "1"
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
UNIFI_DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] is FlowResultType.FORM assert result["type"] is FlowResultType.FORM
@ -139,7 +139,7 @@ async def test_flow_works(hass: HomeAssistant, mock_discovery) -> None:
async def test_flow_works_negative_discovery(hass: HomeAssistant) -> None: async def test_flow_works_negative_discovery(hass: HomeAssistant) -> None:
"""Test config flow with a negative outcome of async_discovery_unifi.""" """Test config flow with a negative outcome of async_discovery_unifi."""
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
UNIFI_DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] is FlowResultType.FORM assert result["type"] is FlowResultType.FORM
@ -166,7 +166,7 @@ async def test_flow_works_negative_discovery(hass: HomeAssistant) -> None:
async def test_flow_multiple_sites(hass: HomeAssistant) -> None: async def test_flow_multiple_sites(hass: HomeAssistant) -> None:
"""Test config flow works when finding multiple sites.""" """Test config flow works when finding multiple sites."""
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
UNIFI_DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] is FlowResultType.FORM assert result["type"] is FlowResultType.FORM
@ -193,7 +193,7 @@ async def test_flow_multiple_sites(hass: HomeAssistant) -> None:
async def test_flow_raise_already_configured(hass: HomeAssistant) -> None: async def test_flow_raise_already_configured(hass: HomeAssistant) -> None:
"""Test config flow aborts since a connected config entry already exists.""" """Test config flow aborts since a connected config entry already exists."""
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
UNIFI_DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] is FlowResultType.FORM assert result["type"] is FlowResultType.FORM
@ -218,7 +218,7 @@ async def test_flow_raise_already_configured(hass: HomeAssistant) -> None:
async def test_flow_aborts_configuration_updated(hass: HomeAssistant) -> None: async def test_flow_aborts_configuration_updated(hass: HomeAssistant) -> None:
"""Test config flow aborts since a connected config entry already exists.""" """Test config flow aborts since a connected config entry already exists."""
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
UNIFI_DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] is FlowResultType.FORM assert result["type"] is FlowResultType.FORM
@ -247,7 +247,7 @@ async def test_flow_aborts_configuration_updated(hass: HomeAssistant) -> None:
async def test_flow_fails_user_credentials_faulty(hass: HomeAssistant) -> None: async def test_flow_fails_user_credentials_faulty(hass: HomeAssistant) -> None:
"""Test config flow.""" """Test config flow."""
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
UNIFI_DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] is FlowResultType.FORM assert result["type"] is FlowResultType.FORM
@ -273,7 +273,7 @@ async def test_flow_fails_user_credentials_faulty(hass: HomeAssistant) -> None:
async def test_flow_fails_hub_unavailable(hass: HomeAssistant) -> None: async def test_flow_fails_hub_unavailable(hass: HomeAssistant) -> None:
"""Test config flow.""" """Test config flow."""
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
UNIFI_DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] is FlowResultType.FORM assert result["type"] is FlowResultType.FORM
@ -480,7 +480,7 @@ async def test_simple_option_flow(
async def test_form_ssdp(hass: HomeAssistant) -> None: async def test_form_ssdp(hass: HomeAssistant) -> None:
"""Test we get the form with ssdp source.""" """Test we get the form with ssdp source."""
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
UNIFI_DOMAIN, DOMAIN,
context={"source": config_entries.SOURCE_SSDP}, context={"source": config_entries.SOURCE_SSDP},
data=SsdpServiceInfo( data=SsdpServiceInfo(
ssdp_usn="mock_usn", ssdp_usn="mock_usn",
@ -520,7 +520,7 @@ async def test_form_ssdp(hass: HomeAssistant) -> None:
async def test_form_ssdp_aborts_if_host_already_exists(hass: HomeAssistant) -> None: async def test_form_ssdp_aborts_if_host_already_exists(hass: HomeAssistant) -> None:
"""Test we abort if the host is already configured.""" """Test we abort if the host is already configured."""
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
UNIFI_DOMAIN, DOMAIN,
context={"source": config_entries.SOURCE_SSDP}, context={"source": config_entries.SOURCE_SSDP},
data=SsdpServiceInfo( data=SsdpServiceInfo(
ssdp_usn="mock_usn", ssdp_usn="mock_usn",
@ -542,7 +542,7 @@ async def test_form_ssdp_aborts_if_serial_already_exists(hass: HomeAssistant) ->
"""Test we abort if the serial is already configured.""" """Test we abort if the serial is already configured."""
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
UNIFI_DOMAIN, DOMAIN,
context={"source": config_entries.SOURCE_SSDP}, context={"source": config_entries.SOURCE_SSDP},
data=SsdpServiceInfo( data=SsdpServiceInfo(
ssdp_usn="mock_usn", ssdp_usn="mock_usn",
@ -562,13 +562,13 @@ async def test_form_ssdp_aborts_if_serial_already_exists(hass: HomeAssistant) ->
async def test_form_ssdp_gets_form_with_ignored_entry(hass: HomeAssistant) -> None: async def test_form_ssdp_gets_form_with_ignored_entry(hass: HomeAssistant) -> None:
"""Test we can still setup if there is an ignored never configured entry.""" """Test we can still setup if there is an ignored never configured entry."""
entry = MockConfigEntry( entry = MockConfigEntry(
domain=UNIFI_DOMAIN, domain=DOMAIN,
data={"not_controller_key": None}, data={"not_controller_key": None},
source=config_entries.SOURCE_IGNORE, source=config_entries.SOURCE_IGNORE,
) )
entry.add_to_hass(hass) entry.add_to_hass(hass)
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
UNIFI_DOMAIN, DOMAIN,
context={"source": config_entries.SOURCE_SSDP}, context={"source": config_entries.SOURCE_SSDP},
data=SsdpServiceInfo( data=SsdpServiceInfo(
ssdp_usn="mock_usn", ssdp_usn="mock_usn",

View File

@ -21,7 +21,7 @@ from homeassistant.components.unifi.const import (
CONF_TRACK_DEVICES, CONF_TRACK_DEVICES,
CONF_TRACK_WIRED_CLIENTS, CONF_TRACK_WIRED_CLIENTS,
DEFAULT_DETECTION_TIME, DEFAULT_DETECTION_TIME,
DOMAIN as UNIFI_DOMAIN, DOMAIN,
) )
from homeassistant.const import STATE_HOME, STATE_NOT_HOME, STATE_UNAVAILABLE, Platform from homeassistant.const import STATE_HOME, STATE_NOT_HOME, STATE_UNAVAILABLE, Platform
from homeassistant.core import HomeAssistant, State from homeassistant.core import HomeAssistant, State
@ -588,14 +588,14 @@ async def test_restoring_client(
"""Verify clients are restored from clients_all if they ever was registered to entity registry.""" """Verify clients are restored from clients_all if they ever was registered to entity registry."""
entity_registry.async_get_or_create( # Make sure unique ID converts to site_id-mac entity_registry.async_get_or_create( # Make sure unique ID converts to site_id-mac
TRACKER_DOMAIN, TRACKER_DOMAIN,
UNIFI_DOMAIN, DOMAIN,
f"{clients_all_payload[0]['mac']}-site_id", f"{clients_all_payload[0]['mac']}-site_id",
suggested_object_id=clients_all_payload[0]["hostname"], suggested_object_id=clients_all_payload[0]["hostname"],
config_entry=config_entry, config_entry=config_entry,
) )
entity_registry.async_get_or_create( # Unique ID already follow format site_id-mac entity_registry.async_get_or_create( # Unique ID already follow format site_id-mac
TRACKER_DOMAIN, TRACKER_DOMAIN,
UNIFI_DOMAIN, DOMAIN,
f"site_id-{client_payload[0]['mac']}", f"site_id-{client_payload[0]['mac']}",
suggested_object_id=client_payload[0]["hostname"], suggested_object_id=client_payload[0]["hostname"],
config_entry=config_entry, config_entry=config_entry,

View File

@ -8,7 +8,7 @@ from unittest.mock import patch
import aiounifi import aiounifi
import pytest import pytest
from homeassistant.components.unifi.const import DOMAIN as UNIFI_DOMAIN from homeassistant.components.unifi.const import DOMAIN
from homeassistant.components.unifi.errors import AuthenticationRequired, CannotConnect from homeassistant.components.unifi.errors import AuthenticationRequired, CannotConnect
from homeassistant.components.unifi.hub import get_unifi_api from homeassistant.components.unifi.hub import get_unifi_api
from homeassistant.config_entries import ConfigEntryState from homeassistant.config_entries import ConfigEntryState
@ -49,7 +49,7 @@ async def test_hub_setup(
device_entry = device_registry.async_get_or_create( device_entry = device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id, config_entry_id=config_entry.entry_id,
identifiers={(UNIFI_DOMAIN, config_entry.unique_id)}, identifiers={(DOMAIN, config_entry.unique_id)},
) )
assert device_entry.sw_version == "7.4.162" assert device_entry.sw_version == "7.4.162"

View File

@ -5,7 +5,7 @@ from unittest.mock import PropertyMock, patch
import pytest import pytest
from homeassistant.components.unifi.const import CONF_SITE_ID, DOMAIN as UNIFI_DOMAIN from homeassistant.components.unifi.const import CONF_SITE_ID, DOMAIN
from homeassistant.components.unifi.services import ( from homeassistant.components.unifi.services import (
SERVICE_RECONNECT_CLIENT, SERVICE_RECONNECT_CLIENT,
SERVICE_REMOVE_CLIENTS, SERVICE_REMOVE_CLIENTS,
@ -41,7 +41,7 @@ async def test_reconnect_client(
) )
await hass.services.async_call( await hass.services.async_call(
UNIFI_DOMAIN, DOMAIN,
SERVICE_RECONNECT_CLIENT, SERVICE_RECONNECT_CLIENT,
service_data={ATTR_DEVICE_ID: device_entry.id}, service_data={ATTR_DEVICE_ID: device_entry.id},
blocking=True, blocking=True,
@ -57,7 +57,7 @@ async def test_reconnect_non_existant_device(
aioclient_mock.clear_requests() aioclient_mock.clear_requests()
await hass.services.async_call( await hass.services.async_call(
UNIFI_DOMAIN, DOMAIN,
SERVICE_RECONNECT_CLIENT, SERVICE_RECONNECT_CLIENT,
service_data={ATTR_DEVICE_ID: "device_entry.id"}, service_data={ATTR_DEVICE_ID: "device_entry.id"},
blocking=True, blocking=True,
@ -80,7 +80,7 @@ async def test_reconnect_device_without_mac(
) )
await hass.services.async_call( await hass.services.async_call(
UNIFI_DOMAIN, DOMAIN,
SERVICE_RECONNECT_CLIENT, SERVICE_RECONNECT_CLIENT,
service_data={ATTR_DEVICE_ID: device_entry.id}, service_data={ATTR_DEVICE_ID: device_entry.id},
blocking=True, blocking=True,
@ -115,7 +115,7 @@ async def test_reconnect_client_hub_unavailable(
) as ws_mock: ) as ws_mock:
ws_mock.return_value = False ws_mock.return_value = False
await hass.services.async_call( await hass.services.async_call(
UNIFI_DOMAIN, DOMAIN,
SERVICE_RECONNECT_CLIENT, SERVICE_RECONNECT_CLIENT,
service_data={ATTR_DEVICE_ID: device_entry.id}, service_data={ATTR_DEVICE_ID: device_entry.id},
blocking=True, blocking=True,
@ -137,7 +137,7 @@ async def test_reconnect_client_unknown_mac(
) )
await hass.services.async_call( await hass.services.async_call(
UNIFI_DOMAIN, DOMAIN,
SERVICE_RECONNECT_CLIENT, SERVICE_RECONNECT_CLIENT,
service_data={ATTR_DEVICE_ID: device_entry.id}, service_data={ATTR_DEVICE_ID: device_entry.id},
blocking=True, blocking=True,
@ -163,7 +163,7 @@ async def test_reconnect_wired_client(
) )
await hass.services.async_call( await hass.services.async_call(
UNIFI_DOMAIN, DOMAIN,
SERVICE_RECONNECT_CLIENT, SERVICE_RECONNECT_CLIENT,
service_data={ATTR_DEVICE_ID: device_entry.id}, service_data={ATTR_DEVICE_ID: device_entry.id},
blocking=True, blocking=True,
@ -213,7 +213,7 @@ async def test_remove_clients(
f"/api/s/{config_entry_setup.data[CONF_SITE_ID]}/cmd/stamgr", f"/api/s/{config_entry_setup.data[CONF_SITE_ID]}/cmd/stamgr",
) )
await hass.services.async_call(UNIFI_DOMAIN, SERVICE_REMOVE_CLIENTS, blocking=True) await hass.services.async_call(DOMAIN, SERVICE_REMOVE_CLIENTS, blocking=True)
assert aioclient_mock.mock_calls[0][2] == { assert aioclient_mock.mock_calls[0][2] == {
"cmd": "forget-sta", "cmd": "forget-sta",
"macs": ["00:00:00:00:00:00", "00:00:00:00:00:01"], "macs": ["00:00:00:00:00:00", "00:00:00:00:00:01"],
@ -244,9 +244,7 @@ async def test_remove_clients_hub_unavailable(
"homeassistant.components.unifi.UnifiHub.available", new_callable=PropertyMock "homeassistant.components.unifi.UnifiHub.available", new_callable=PropertyMock
) as ws_mock: ) as ws_mock:
ws_mock.return_value = False ws_mock.return_value = False
await hass.services.async_call( await hass.services.async_call(DOMAIN, SERVICE_REMOVE_CLIENTS, blocking=True)
UNIFI_DOMAIN, SERVICE_REMOVE_CLIENTS, blocking=True
)
assert aioclient_mock.call_count == 0 assert aioclient_mock.call_count == 0
@ -268,7 +266,7 @@ async def test_remove_clients_no_call_on_empty_list(
) -> None: ) -> None:
"""Verify no call is made if no fitting client has been added to the list.""" """Verify no call is made if no fitting client has been added to the list."""
aioclient_mock.clear_requests() aioclient_mock.clear_requests()
await hass.services.async_call(UNIFI_DOMAIN, SERVICE_REMOVE_CLIENTS, blocking=True) await hass.services.async_call(DOMAIN, SERVICE_REMOVE_CLIENTS, blocking=True)
assert aioclient_mock.call_count == 0 assert aioclient_mock.call_count == 0
@ -297,7 +295,7 @@ async def test_services_handle_unloaded_config_entry(
aioclient_mock.clear_requests() aioclient_mock.clear_requests()
await hass.services.async_call(UNIFI_DOMAIN, SERVICE_REMOVE_CLIENTS, blocking=True) await hass.services.async_call(DOMAIN, SERVICE_REMOVE_CLIENTS, blocking=True)
assert aioclient_mock.call_count == 0 assert aioclient_mock.call_count == 0
device_entry = device_registry.async_get_or_create( device_entry = device_registry.async_get_or_create(
@ -305,7 +303,7 @@ async def test_services_handle_unloaded_config_entry(
connections={(dr.CONNECTION_NETWORK_MAC, clients_all_payload[0]["mac"])}, connections={(dr.CONNECTION_NETWORK_MAC, clients_all_payload[0]["mac"])},
) )
await hass.services.async_call( await hass.services.async_call(
UNIFI_DOMAIN, DOMAIN,
SERVICE_RECONNECT_CLIENT, SERVICE_RECONNECT_CLIENT,
service_data={ATTR_DEVICE_ID: device_entry.id}, service_data={ATTR_DEVICE_ID: device_entry.id},
blocking=True, blocking=True,

View File

@ -20,7 +20,7 @@ from homeassistant.components.unifi.const import (
CONF_SITE_ID, CONF_SITE_ID,
CONF_TRACK_CLIENTS, CONF_TRACK_CLIENTS,
CONF_TRACK_DEVICES, CONF_TRACK_DEVICES,
DOMAIN as UNIFI_DOMAIN, DOMAIN,
) )
from homeassistant.config_entries import RELOAD_AFTER_UPDATE_DELAY from homeassistant.config_entries import RELOAD_AFTER_UPDATE_DELAY
from homeassistant.const import ( from homeassistant.const import (
@ -1743,14 +1743,14 @@ async def test_updating_unique_id(
"""Verify outlet control and poe control unique ID update works.""" """Verify outlet control and poe control unique ID update works."""
entity_registry.async_get_or_create( entity_registry.async_get_or_create(
SWITCH_DOMAIN, SWITCH_DOMAIN,
UNIFI_DOMAIN, DOMAIN,
f"{device_payload[0]['mac']}-outlet-1", f"{device_payload[0]['mac']}-outlet-1",
suggested_object_id="plug_outlet_1", suggested_object_id="plug_outlet_1",
config_entry=config_entry, config_entry=config_entry,
) )
entity_registry.async_get_or_create( entity_registry.async_get_or_create(
SWITCH_DOMAIN, SWITCH_DOMAIN,
UNIFI_DOMAIN, DOMAIN,
f"{device_payload[1]['mac']}-poe-1", f"{device_payload[1]['mac']}-poe-1",
suggested_object_id="switch_port_1_poe", suggested_object_id="switch_port_1_poe",
config_entry=config_entry, config_entry=config_entry,

View File

@ -5,7 +5,7 @@ from unittest.mock import MagicMock, patch
import pytest import pytest
from homeassistant.components.vacuum import DOMAIN as VACUUM_DOMAIN, VacuumEntityFeature from homeassistant.components.vacuum import DOMAIN, VacuumEntityFeature
from homeassistant.config_entries import ConfigEntry, ConfigFlow from homeassistant.config_entries import ConfigEntry, ConfigFlow
from homeassistant.const import Platform from homeassistant.const import Platform
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -95,7 +95,7 @@ async def setup_vacuum_platform_test_entity(
mock_platform( mock_platform(
hass, hass,
f"{TEST_DOMAIN}.{VACUUM_DOMAIN}", f"{TEST_DOMAIN}.{DOMAIN}",
MockPlatform(async_setup_entry=async_setup_entry_platform), MockPlatform(async_setup_entry=async_setup_entry_platform),
) )

View File

@ -10,7 +10,7 @@ import pytest
from homeassistant.components import vacuum from homeassistant.components import vacuum
from homeassistant.components.vacuum import ( from homeassistant.components.vacuum import (
DOMAIN as VACUUM_DOMAIN, DOMAIN,
SERVICE_CLEAN_SPOT, SERVICE_CLEAN_SPOT,
SERVICE_LOCATE, SERVICE_LOCATE,
SERVICE_PAUSE, SERVICE_PAUSE,
@ -120,13 +120,11 @@ async def test_state_services(
async_unload_entry=help_async_unload_entry, async_unload_entry=help_async_unload_entry,
), ),
) )
setup_test_component_platform( setup_test_component_platform(hass, DOMAIN, [mock_vacuum], from_config_entry=True)
hass, VACUUM_DOMAIN, [mock_vacuum], from_config_entry=True
)
assert await hass.config_entries.async_setup(config_entry.entry_id) assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.services.async_call( await hass.services.async_call(
VACUUM_DOMAIN, DOMAIN,
service, service,
{"entity_id": mock_vacuum.entity_id}, {"entity_id": mock_vacuum.entity_id},
blocking=True, blocking=True,
@ -153,16 +151,14 @@ async def test_fan_speed(hass: HomeAssistant, config_flow_fixture: None) -> None
async_unload_entry=help_async_unload_entry, async_unload_entry=help_async_unload_entry,
), ),
) )
setup_test_component_platform( setup_test_component_platform(hass, DOMAIN, [mock_vacuum], from_config_entry=True)
hass, VACUUM_DOMAIN, [mock_vacuum], from_config_entry=True
)
assert await hass.config_entries.async_setup(config_entry.entry_id) assert await hass.config_entries.async_setup(config_entry.entry_id)
config_entry = MockConfigEntry(domain="test", data={}) config_entry = MockConfigEntry(domain="test", data={})
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)
await hass.services.async_call( await hass.services.async_call(
VACUUM_DOMAIN, DOMAIN,
SERVICE_SET_FAN_SPEED, SERVICE_SET_FAN_SPEED,
{"entity_id": mock_vacuum.entity_id, "fan_speed": "high"}, {"entity_id": mock_vacuum.entity_id, "fan_speed": "high"},
blocking=True, blocking=True,
@ -201,13 +197,11 @@ async def test_locate(hass: HomeAssistant, config_flow_fixture: None) -> None:
async_unload_entry=help_async_unload_entry, async_unload_entry=help_async_unload_entry,
), ),
) )
setup_test_component_platform( setup_test_component_platform(hass, DOMAIN, [mock_vacuum], from_config_entry=True)
hass, VACUUM_DOMAIN, [mock_vacuum], from_config_entry=True
)
assert await hass.config_entries.async_setup(config_entry.entry_id) assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.services.async_call( await hass.services.async_call(
VACUUM_DOMAIN, DOMAIN,
SERVICE_LOCATE, SERVICE_LOCATE,
{"entity_id": mock_vacuum.entity_id}, {"entity_id": mock_vacuum.entity_id},
blocking=True, blocking=True,
@ -252,13 +246,11 @@ async def test_send_command(hass: HomeAssistant, config_flow_fixture: None) -> N
async_unload_entry=help_async_unload_entry, async_unload_entry=help_async_unload_entry,
), ),
) )
setup_test_component_platform( setup_test_component_platform(hass, DOMAIN, [mock_vacuum], from_config_entry=True)
hass, VACUUM_DOMAIN, [mock_vacuum], from_config_entry=True
)
assert await hass.config_entries.async_setup(config_entry.entry_id) assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.services.async_call( await hass.services.async_call(
VACUUM_DOMAIN, DOMAIN,
SERVICE_SEND_COMMAND, SERVICE_SEND_COMMAND,
{ {
"entity_id": mock_vacuum.entity_id, "entity_id": mock_vacuum.entity_id,
@ -355,7 +347,7 @@ async def test_vacuum_log_deprecated_state_warning_using_state_prop(
), ),
built_in=False, built_in=False,
) )
setup_test_component_platform(hass, VACUUM_DOMAIN, [entity], from_config_entry=True) setup_test_component_platform(hass, DOMAIN, [entity], from_config_entry=True)
assert await hass.config_entries.async_setup(config_entry.entry_id) assert await hass.config_entries.async_setup(config_entry.entry_id)
state = hass.states.get(entity.entity_id) state = hass.states.get(entity.entity_id)
@ -398,7 +390,7 @@ async def test_vacuum_log_deprecated_state_warning_using_attr_state_attr(
), ),
built_in=False, built_in=False,
) )
setup_test_component_platform(hass, VACUUM_DOMAIN, [entity], from_config_entry=True) setup_test_component_platform(hass, DOMAIN, [entity], from_config_entry=True)
assert await hass.config_entries.async_setup(config_entry.entry_id) assert await hass.config_entries.async_setup(config_entry.entry_id)
state = hass.states.get(entity.entity_id) state = hass.states.get(entity.entity_id)
@ -462,7 +454,7 @@ async def test_vacuum_deprecated_state_does_not_break_state(
), ),
built_in=False, built_in=False,
) )
setup_test_component_platform(hass, VACUUM_DOMAIN, [entity], from_config_entry=True) setup_test_component_platform(hass, DOMAIN, [entity], from_config_entry=True)
assert await hass.config_entries.async_setup(config_entry.entry_id) assert await hass.config_entries.async_setup(config_entry.entry_id)
state = hass.states.get(entity.entity_id) state = hass.states.get(entity.entity_id)
@ -470,7 +462,7 @@ async def test_vacuum_deprecated_state_does_not_break_state(
assert state.state == "docked" assert state.state == "docked"
await hass.services.async_call( await hass.services.async_call(
VACUUM_DOMAIN, DOMAIN,
SERVICE_START, SERVICE_START,
{ {
"entity_id": entity.entity_id, "entity_id": entity.entity_id,

View File

@ -2,7 +2,7 @@
from unittest.mock import patch from unittest.mock import patch
from homeassistant.components.venstar.const import DOMAIN as VENSTAR_DOMAIN from homeassistant.components.venstar.const import DOMAIN
from homeassistant.config_entries import ConfigEntryState from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import CONF_HOST, CONF_SSL from homeassistant.const import CONF_HOST, CONF_SSL
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -17,7 +17,7 @@ TEST_HOST = "venstartest.localdomain"
async def test_setup_entry(hass: HomeAssistant) -> None: async def test_setup_entry(hass: HomeAssistant) -> None:
"""Validate that setup entry also configure the client.""" """Validate that setup entry also configure the client."""
config_entry = MockConfigEntry( config_entry = MockConfigEntry(
domain=VENSTAR_DOMAIN, domain=DOMAIN,
data={ data={
CONF_HOST: TEST_HOST, CONF_HOST: TEST_HOST,
CONF_SSL: False, CONF_SSL: False,
@ -64,7 +64,7 @@ async def test_setup_entry(hass: HomeAssistant) -> None:
async def test_setup_entry_exception(hass: HomeAssistant) -> None: async def test_setup_entry_exception(hass: HomeAssistant) -> None:
"""Validate that setup entry also configure the client.""" """Validate that setup entry also configure the client."""
config_entry = MockConfigEntry( config_entry = MockConfigEntry(
domain=VENSTAR_DOMAIN, domain=DOMAIN,
data={ data={
CONF_HOST: TEST_HOST, CONF_HOST: TEST_HOST,
CONF_SSL: False, CONF_SSL: False,

View File

@ -6,7 +6,7 @@ import pytest
import pywilight import pywilight
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
from homeassistant.components.wilight import DOMAIN as WILIGHT_DOMAIN from homeassistant.components.wilight import DOMAIN
from homeassistant.components.wilight.switch import ( from homeassistant.components.wilight.switch import (
ATTR_PAUSE_TIME, ATTR_PAUSE_TIME,
ATTR_TRIGGER, ATTR_TRIGGER,
@ -159,7 +159,7 @@ async def test_switch_services(
# Set watering time # Set watering time
await hass.services.async_call( await hass.services.async_call(
WILIGHT_DOMAIN, DOMAIN,
SERVICE_SET_WATERING_TIME, SERVICE_SET_WATERING_TIME,
{ATTR_WATERING_TIME: 30, ATTR_ENTITY_ID: "switch.wl000000000099_1_watering"}, {ATTR_WATERING_TIME: 30, ATTR_ENTITY_ID: "switch.wl000000000099_1_watering"},
blocking=True, blocking=True,
@ -172,7 +172,7 @@ async def test_switch_services(
# Set pause time # Set pause time
await hass.services.async_call( await hass.services.async_call(
WILIGHT_DOMAIN, DOMAIN,
SERVICE_SET_PAUSE_TIME, SERVICE_SET_PAUSE_TIME,
{ATTR_PAUSE_TIME: 18, ATTR_ENTITY_ID: "switch.wl000000000099_2_pause"}, {ATTR_PAUSE_TIME: 18, ATTR_ENTITY_ID: "switch.wl000000000099_2_pause"},
blocking=True, blocking=True,
@ -185,7 +185,7 @@ async def test_switch_services(
# Set trigger_1 # Set trigger_1
await hass.services.async_call( await hass.services.async_call(
WILIGHT_DOMAIN, DOMAIN,
SERVICE_SET_TRIGGER, SERVICE_SET_TRIGGER,
{ {
ATTR_TRIGGER_INDEX: "1", ATTR_TRIGGER_INDEX: "1",
@ -202,7 +202,7 @@ async def test_switch_services(
# Set trigger_2 # Set trigger_2
await hass.services.async_call( await hass.services.async_call(
WILIGHT_DOMAIN, DOMAIN,
SERVICE_SET_TRIGGER, SERVICE_SET_TRIGGER,
{ {
ATTR_TRIGGER_INDEX: "2", ATTR_TRIGGER_INDEX: "2",
@ -219,7 +219,7 @@ async def test_switch_services(
# Set trigger_3 # Set trigger_3
await hass.services.async_call( await hass.services.async_call(
WILIGHT_DOMAIN, DOMAIN,
SERVICE_SET_TRIGGER, SERVICE_SET_TRIGGER,
{ {
ATTR_TRIGGER_INDEX: "3", ATTR_TRIGGER_INDEX: "3",
@ -236,7 +236,7 @@ async def test_switch_services(
# Set trigger_4 # Set trigger_4
await hass.services.async_call( await hass.services.async_call(
WILIGHT_DOMAIN, DOMAIN,
SERVICE_SET_TRIGGER, SERVICE_SET_TRIGGER,
{ {
ATTR_TRIGGER_INDEX: "4", ATTR_TRIGGER_INDEX: "4",
@ -254,7 +254,7 @@ async def test_switch_services(
# Set watering time using WiLight Pause Switch to raise # Set watering time using WiLight Pause Switch to raise
with pytest.raises(TypeError) as exc_info: with pytest.raises(TypeError) as exc_info:
await hass.services.async_call( await hass.services.async_call(
WILIGHT_DOMAIN, DOMAIN,
SERVICE_SET_WATERING_TIME, SERVICE_SET_WATERING_TIME,
{ATTR_WATERING_TIME: 30, ATTR_ENTITY_ID: "switch.wl000000000099_2_pause"}, {ATTR_WATERING_TIME: 30, ATTR_ENTITY_ID: "switch.wl000000000099_2_pause"},
blocking=True, blocking=True,

View File

@ -7,7 +7,7 @@ import pytest
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, SERVICE_PRESS from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, SERVICE_PRESS
from homeassistant.components.xiaomi_miio.const import ( from homeassistant.components.xiaomi_miio.const import (
CONF_FLOW_TYPE, CONF_FLOW_TYPE,
DOMAIN as XIAOMI_DOMAIN, DOMAIN,
MODELS_VACUUM, MODELS_VACUUM,
) )
from homeassistant.const import ( from homeassistant.const import (
@ -84,7 +84,7 @@ async def setup_component(hass: HomeAssistant, entity_name: str) -> str:
entity_id = f"{BUTTON_DOMAIN}.{entity_name}" entity_id = f"{BUTTON_DOMAIN}.{entity_name}"
config_entry = MockConfigEntry( config_entry = MockConfigEntry(
domain=XIAOMI_DOMAIN, domain=DOMAIN,
unique_id="123456", unique_id="123456",
title=entity_name, title=entity_name,
data={ data={

View File

@ -18,7 +18,7 @@ from homeassistant.components.select import (
from homeassistant.components.xiaomi_miio import UPDATE_INTERVAL from homeassistant.components.xiaomi_miio import UPDATE_INTERVAL
from homeassistant.components.xiaomi_miio.const import ( from homeassistant.components.xiaomi_miio.const import (
CONF_FLOW_TYPE, CONF_FLOW_TYPE,
DOMAIN as XIAOMI_DOMAIN, DOMAIN,
MODEL_AIRFRESH_T2017, MODEL_AIRFRESH_T2017,
) )
from homeassistant.const import ( from homeassistant.const import (
@ -146,7 +146,7 @@ async def setup_component(hass: HomeAssistant, entity_name: str) -> str:
entity_id = f"{SELECT_DOMAIN}.{entity_name}" entity_id = f"{SELECT_DOMAIN}.{entity_name}"
config_entry = MockConfigEntry( config_entry = MockConfigEntry(
domain=XIAOMI_DOMAIN, domain=DOMAIN,
unique_id="123456", unique_id="123456",
title=entity_name, title=entity_name,
data={ data={

View File

@ -25,7 +25,7 @@ from homeassistant.components.vacuum import (
) )
from homeassistant.components.xiaomi_miio.const import ( from homeassistant.components.xiaomi_miio.const import (
CONF_FLOW_TYPE, CONF_FLOW_TYPE,
DOMAIN as XIAOMI_DOMAIN, DOMAIN,
MODELS_VACUUM, MODELS_VACUUM,
) )
from homeassistant.components.xiaomi_miio.vacuum import ( from homeassistant.components.xiaomi_miio.vacuum import (
@ -471,7 +471,7 @@ async def test_xiaomi_specific_services(
device_method_attr.side_effect = error device_method_attr.side_effect = error
await hass.services.async_call( await hass.services.async_call(
XIAOMI_DOMAIN, DOMAIN,
service, service,
service_data, service_data,
blocking=True, blocking=True,
@ -537,7 +537,7 @@ async def setup_component(hass: HomeAssistant, entity_name: str) -> str:
entity_id = f"{VACUUM_DOMAIN}.{entity_name}" entity_id = f"{VACUUM_DOMAIN}.{entity_name}"
config_entry = MockConfigEntry( config_entry = MockConfigEntry(
domain=XIAOMI_DOMAIN, domain=DOMAIN,
unique_id="123456", unique_id="123456",
title=entity_name, title=entity_name,
data={ data={

View File

@ -1,13 +1,13 @@
"""Tests for the ZAMG component.""" """Tests for the ZAMG component."""
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.components.zamg.const import CONF_STATION_ID, DOMAIN as ZAMG_DOMAIN from homeassistant.components.zamg.const import CONF_STATION_ID, DOMAIN
from .conftest import TEST_STATION_ID, TEST_STATION_NAME from .conftest import TEST_STATION_ID, TEST_STATION_NAME
FIXTURE_CONFIG_ENTRY = { FIXTURE_CONFIG_ENTRY = {
"entry_id": "1", "entry_id": "1",
"domain": ZAMG_DOMAIN, "domain": DOMAIN,
"title": TEST_STATION_NAME, "title": TEST_STATION_NAME,
"data": { "data": {
CONF_STATION_ID: TEST_STATION_ID, CONF_STATION_ID: TEST_STATION_ID,

View File

@ -4,7 +4,7 @@ import pytest
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
from homeassistant.components.weather import DOMAIN as WEATHER_DOMAIN from homeassistant.components.weather import DOMAIN as WEATHER_DOMAIN
from homeassistant.components.zamg.const import CONF_STATION_ID, DOMAIN as ZAMG_DOMAIN from homeassistant.components.zamg.const import CONF_STATION_ID, DOMAIN
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er from homeassistant.helpers import entity_registry as er
@ -25,7 +25,7 @@ from tests.common import MockConfigEntry
( (
{ {
"domain": WEATHER_DOMAIN, "domain": WEATHER_DOMAIN,
"platform": ZAMG_DOMAIN, "platform": DOMAIN,
"unique_id": f"{TEST_STATION_NAME}_{TEST_STATION_ID}", "unique_id": f"{TEST_STATION_NAME}_{TEST_STATION_ID}",
"suggested_object_id": f"Zamg {TEST_STATION_NAME}", "suggested_object_id": f"Zamg {TEST_STATION_NAME}",
"disabled_by": None, "disabled_by": None,
@ -37,7 +37,7 @@ from tests.common import MockConfigEntry
( (
{ {
"domain": WEATHER_DOMAIN, "domain": WEATHER_DOMAIN,
"platform": ZAMG_DOMAIN, "platform": DOMAIN,
"unique_id": f"{TEST_STATION_NAME_2}_{TEST_STATION_ID_2}", "unique_id": f"{TEST_STATION_NAME_2}_{TEST_STATION_ID_2}",
"suggested_object_id": f"Zamg {TEST_STATION_NAME_2}", "suggested_object_id": f"Zamg {TEST_STATION_NAME_2}",
"disabled_by": None, "disabled_by": None,
@ -49,7 +49,7 @@ from tests.common import MockConfigEntry
( (
{ {
"domain": SENSOR_DOMAIN, "domain": SENSOR_DOMAIN,
"platform": ZAMG_DOMAIN, "platform": DOMAIN,
"unique_id": f"{TEST_STATION_NAME_2}_{TEST_STATION_ID_2}_temperature", "unique_id": f"{TEST_STATION_NAME_2}_{TEST_STATION_ID_2}_temperature",
"suggested_object_id": f"Zamg {TEST_STATION_NAME_2}", "suggested_object_id": f"Zamg {TEST_STATION_NAME_2}",
"disabled_by": None, "disabled_by": None,
@ -95,7 +95,7 @@ async def test_migrate_unique_ids(
( (
{ {
"domain": WEATHER_DOMAIN, "domain": WEATHER_DOMAIN,
"platform": ZAMG_DOMAIN, "platform": DOMAIN,
"unique_id": f"{TEST_STATION_NAME}_{TEST_STATION_ID}", "unique_id": f"{TEST_STATION_NAME}_{TEST_STATION_ID}",
"suggested_object_id": f"Zamg {TEST_STATION_NAME}", "suggested_object_id": f"Zamg {TEST_STATION_NAME}",
"disabled_by": None, "disabled_by": None,
@ -123,7 +123,7 @@ async def test_dont_migrate_unique_ids(
# create existing entry with new_unique_id # create existing entry with new_unique_id
existing_entity = entity_registry.async_get_or_create( existing_entity = entity_registry.async_get_or_create(
WEATHER_DOMAIN, WEATHER_DOMAIN,
ZAMG_DOMAIN, DOMAIN,
unique_id=TEST_STATION_ID, unique_id=TEST_STATION_ID,
suggested_object_id=f"Zamg {TEST_STATION_NAME}", suggested_object_id=f"Zamg {TEST_STATION_NAME}",
config_entry=mock_config_entry, config_entry=mock_config_entry,
@ -156,7 +156,7 @@ async def test_dont_migrate_unique_ids(
( (
{ {
"domain": WEATHER_DOMAIN, "domain": WEATHER_DOMAIN,
"platform": ZAMG_DOMAIN, "platform": DOMAIN,
"unique_id": TEST_STATION_ID, "unique_id": TEST_STATION_ID,
"suggested_object_id": f"Zamg {TEST_STATION_NAME}", "suggested_object_id": f"Zamg {TEST_STATION_NAME}",
"disabled_by": None, "disabled_by": None,
@ -178,7 +178,7 @@ async def test_unload_entry(
entity_registry.async_get_or_create( entity_registry.async_get_or_create(
WEATHER_DOMAIN, WEATHER_DOMAIN,
ZAMG_DOMAIN, DOMAIN,
unique_id=TEST_STATION_ID, unique_id=TEST_STATION_ID,
suggested_object_id=f"Zamg {TEST_STATION_NAME}", suggested_object_id=f"Zamg {TEST_STATION_NAME}",
config_entry=mock_config_entry, config_entry=mock_config_entry,

View File

@ -20,7 +20,7 @@ from homeassistant.components.lock import (
from homeassistant.components.zwave_js.const import ( from homeassistant.components.zwave_js.const import (
ATTR_LOCK_TIMEOUT, ATTR_LOCK_TIMEOUT,
ATTR_OPERATION_TYPE, ATTR_OPERATION_TYPE,
DOMAIN as ZWAVE_JS_DOMAIN, DOMAIN,
) )
from homeassistant.components.zwave_js.helpers import ZwaveValueMatcher from homeassistant.components.zwave_js.helpers import ZwaveValueMatcher
from homeassistant.components.zwave_js.lock import ( from homeassistant.components.zwave_js.lock import (
@ -119,7 +119,7 @@ async def test_door_lock(
# Test set usercode service # Test set usercode service
await hass.services.async_call( await hass.services.async_call(
ZWAVE_JS_DOMAIN, DOMAIN,
SERVICE_SET_LOCK_USERCODE, SERVICE_SET_LOCK_USERCODE,
{ {
ATTR_ENTITY_ID: SCHLAGE_BE469_LOCK_ENTITY, ATTR_ENTITY_ID: SCHLAGE_BE469_LOCK_ENTITY,
@ -145,7 +145,7 @@ async def test_door_lock(
# Test clear usercode # Test clear usercode
await hass.services.async_call( await hass.services.async_call(
ZWAVE_JS_DOMAIN, DOMAIN,
SERVICE_CLEAR_LOCK_USERCODE, SERVICE_CLEAR_LOCK_USERCODE,
{ATTR_ENTITY_ID: SCHLAGE_BE469_LOCK_ENTITY, ATTR_CODE_SLOT: 1}, {ATTR_ENTITY_ID: SCHLAGE_BE469_LOCK_ENTITY, ATTR_CODE_SLOT: 1},
blocking=True, blocking=True,
@ -171,7 +171,7 @@ async def test_door_lock(
} }
caplog.clear() caplog.clear()
await hass.services.async_call( await hass.services.async_call(
ZWAVE_JS_DOMAIN, DOMAIN,
SERVICE_SET_LOCK_CONFIGURATION, SERVICE_SET_LOCK_CONFIGURATION,
{ {
ATTR_ENTITY_ID: SCHLAGE_BE469_LOCK_ENTITY, ATTR_ENTITY_ID: SCHLAGE_BE469_LOCK_ENTITY,
@ -216,7 +216,7 @@ async def test_door_lock(
node.receive_event(event) node.receive_event(event)
await hass.services.async_call( await hass.services.async_call(
ZWAVE_JS_DOMAIN, DOMAIN,
SERVICE_SET_LOCK_CONFIGURATION, SERVICE_SET_LOCK_CONFIGURATION,
{ {
ATTR_ENTITY_ID: SCHLAGE_BE469_LOCK_ENTITY, ATTR_ENTITY_ID: SCHLAGE_BE469_LOCK_ENTITY,
@ -261,7 +261,7 @@ async def test_door_lock(
# Test set usercode service error handling # Test set usercode service error handling
with pytest.raises(HomeAssistantError): with pytest.raises(HomeAssistantError):
await hass.services.async_call( await hass.services.async_call(
ZWAVE_JS_DOMAIN, DOMAIN,
SERVICE_SET_LOCK_USERCODE, SERVICE_SET_LOCK_USERCODE,
{ {
ATTR_ENTITY_ID: SCHLAGE_BE469_LOCK_ENTITY, ATTR_ENTITY_ID: SCHLAGE_BE469_LOCK_ENTITY,
@ -274,7 +274,7 @@ async def test_door_lock(
# Test clear usercode service error handling # Test clear usercode service error handling
with pytest.raises(HomeAssistantError): with pytest.raises(HomeAssistantError):
await hass.services.async_call( await hass.services.async_call(
ZWAVE_JS_DOMAIN, DOMAIN,
SERVICE_CLEAR_LOCK_USERCODE, SERVICE_CLEAR_LOCK_USERCODE,
{ATTR_ENTITY_ID: SCHLAGE_BE469_LOCK_ENTITY, ATTR_CODE_SLOT: 1}, {ATTR_ENTITY_ID: SCHLAGE_BE469_LOCK_ENTITY, ATTR_CODE_SLOT: 1},
blocking=True, blocking=True,