diff --git a/tests/components/sensor/test_init.py b/tests/components/sensor/test_init.py index 521c633f94a..98fb9d6604a 100644 --- a/tests/components/sensor/test_init.py +++ b/tests/components/sensor/test_init.py @@ -15,7 +15,7 @@ from homeassistant.components.number import NumberDeviceClass from homeassistant.components.sensor import ( DEVICE_CLASS_STATE_CLASSES, DEVICE_CLASS_UNITS, - DOMAIN as SENSOR_DOMAIN, + DOMAIN, NON_NUMERIC_DEVICE_CLASSES, SensorDeviceClass, SensorEntity, @@ -2752,7 +2752,7 @@ async def test_name(hass: HomeAssistant) -> None: mock_platform( hass, - f"{TEST_DOMAIN}.{SENSOR_DOMAIN}", + f"{TEST_DOMAIN}.{DOMAIN}", MockPlatform(async_setup_entry=async_setup_entry_platform), ) diff --git a/tests/components/solarlog/conftest.py b/tests/components/solarlog/conftest.py index caa3621b9bb..51d84c9b1a7 100644 --- a/tests/components/solarlog/conftest.py +++ b/tests/components/solarlog/conftest.py @@ -6,10 +6,7 @@ from unittest.mock import AsyncMock, MagicMock, patch import pytest from solarlog_cli.solarlog_models import InverterData, SolarlogData -from homeassistant.components.solarlog.const import ( - CONF_HAS_PWD, - DOMAIN as SOLARLOG_DOMAIN, -) +from homeassistant.components.solarlog.const import CONF_HAS_PWD, DOMAIN from homeassistant.const import CONF_HOST, CONF_PASSWORD from .const import HOST @@ -34,7 +31,7 @@ INVERTER_DATA = { def mock_config_entry() -> MockConfigEntry: """Mock a config entry.""" return MockConfigEntry( - domain=SOLARLOG_DOMAIN, + domain=DOMAIN, title="solarlog", data={ 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.""" 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 diff --git a/tests/components/sonos/test_media_player.py b/tests/components/sonos/test_media_player.py index 37ce119b0de..b15d7698e05 100644 --- a/tests/components/sonos/test_media_player.py +++ b/tests/components/sonos/test_media_player.py @@ -27,7 +27,7 @@ from homeassistant.components.media_player import ( RepeatMode, ) from homeassistant.components.sonos.const import ( - DOMAIN as SONOS_DOMAIN, + DOMAIN, MEDIA_TYPE_DIRECTORY, SOURCE_LINEIN, SOURCE_TV, @@ -1012,7 +1012,7 @@ async def test_play_media_favorite_item_id( async def _setup_hass(hass: HomeAssistant): await async_setup_component( hass, - SONOS_DOMAIN, + DOMAIN, { "sonos": { "media_player": { @@ -1037,7 +1037,7 @@ async def test_service_snapshot_restore( "homeassistant.components.sonos.speaker.Snapshot.snapshot" ) as mock_snapshot: await hass.services.async_call( - SONOS_DOMAIN, + DOMAIN, SERVICE_SNAPSHOT, { 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" ) as mock_restore: await hass.services.async_call( - SONOS_DOMAIN, + DOMAIN, SERVICE_RESTORE, { 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.""" soco_mock = soco_factory.mock_list.get("192.168.42.2") result = await hass.services.async_call( - SONOS_DOMAIN, + DOMAIN, SERVICE_GET_QUEUE, { ATTR_ENTITY_ID: "media_player.zone_a", diff --git a/tests/components/statistics/test_init.py b/tests/components/statistics/test_init.py index 64829ea7d66..3eb0bf59405 100644 --- a/tests/components/statistics/test_init.py +++ b/tests/components/statistics/test_init.py @@ -2,7 +2,7 @@ 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.core import HomeAssistant 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 statistics_config_entry = MockConfigEntry( data={}, - domain=STATISTICS_DOMAIN, + domain=DOMAIN, options={ "name": "Statistics", "entity_id": "sensor.test_source", diff --git a/tests/components/statistics/test_sensor.py b/tests/components/statistics/test_sensor.py index 1dff13bb21a..21df0146ef5 100644 --- a/tests/components/statistics/test_sensor.py +++ b/tests/components/statistics/test_sensor.py @@ -20,7 +20,7 @@ from homeassistant.components.sensor import ( SensorDeviceClass, SensorStateClass, ) -from homeassistant.components.statistics import DOMAIN as STATISTICS_DOMAIN +from homeassistant.components.statistics import DOMAIN from homeassistant.components.statistics.sensor import ( CONF_KEEP_LAST_SAMPLE, CONF_PERCENTILE, @@ -78,7 +78,7 @@ async def test_unique_id( await hass.async_block_till_done() entity_id = entity_registry.async_get_entity_id( - "sensor", STATISTICS_DOMAIN, "uniqueid_sensor_test" + "sensor", DOMAIN, "uniqueid_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") with patch.object(hass_config, "YAML_CONFIG_FILE", yaml_path): await hass.services.async_call( - STATISTICS_DOMAIN, + DOMAIN, SERVICE_RELOAD, {}, blocking=True, @@ -1690,7 +1690,7 @@ async def test_device_id( statistics_config_entry = MockConfigEntry( data={}, - domain=STATISTICS_DOMAIN, + domain=DOMAIN, options={ "name": "Statistics", "entity_id": "sensor.test_source", diff --git a/tests/components/subaru/test_lock.py b/tests/components/subaru/test_lock.py index c954634cf63..fd0b6fcc823 100644 --- a/tests/components/subaru/test_lock.py +++ b/tests/components/subaru/test_lock.py @@ -8,7 +8,7 @@ from voluptuous.error import MultipleInvalid from homeassistant.components.lock import DOMAIN as LOCK_DOMAIN from homeassistant.components.subaru.const import ( ATTR_DOOR, - DOMAIN as SUBARU_DOMAIN, + DOMAIN, SERVICE_UNLOCK_SPECIFIC_DOOR, UNLOCK_DOOR_DRIVERS, ) @@ -68,7 +68,7 @@ async def test_unlock_specific_door(hass: HomeAssistant, ev_entry) -> None: """Test subaru unlock specific door function.""" with patch(MOCK_API_UNLOCK) as mock_unlock: await hass.services.async_call( - SUBARU_DOMAIN, + DOMAIN, SERVICE_UNLOCK_SPECIFIC_DOOR, {ATTR_ENTITY_ID: DEVICE_ID, ATTR_DOOR: UNLOCK_DOOR_DRIVERS}, blocking=True, @@ -81,7 +81,7 @@ async def test_unlock_specific_door_invalid(hass: HomeAssistant, ev_entry) -> No """Test subaru unlock specific door function.""" with patch(MOCK_API_UNLOCK) as mock_unlock, pytest.raises(MultipleInvalid): await hass.services.async_call( - SUBARU_DOMAIN, + DOMAIN, SERVICE_UNLOCK_SPECIFIC_DOOR, {ATTR_ENTITY_ID: DEVICE_ID, ATTR_DOOR: "bad_value"}, blocking=True, diff --git a/tests/components/subaru/test_sensor.py b/tests/components/subaru/test_sensor.py index c8812460e68..f133b46d3d3 100644 --- a/tests/components/subaru/test_sensor.py +++ b/tests/components/subaru/test_sensor.py @@ -8,7 +8,7 @@ import pytest from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN from homeassistant.components.subaru.sensor import ( API_GEN_2_SENSORS, - DOMAIN as SUBARU_DOMAIN, + DOMAIN, EV_SENSORS, SAFETY_SENSORS, ) @@ -50,7 +50,7 @@ async def test_sensors_missing_vin_data(hass: HomeAssistant, ev_entry) -> None: ( { "domain": SENSOR_DOMAIN, - "platform": SUBARU_DOMAIN, + "platform": DOMAIN, "unique_id": 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, - "platform": SUBARU_DOMAIN, + "platform": DOMAIN, "unique_id": 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 existing_entity = entity_registry.async_get_or_create( SENSOR_DOMAIN, - SUBARU_DOMAIN, + DOMAIN, unique_id=new_unique_id, 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) for item in sensor_list: 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] diff --git a/tests/components/tts/common.py b/tests/components/tts/common.py index da960b145d9..74cea380351 100644 --- a/tests/components/tts/common.py +++ b/tests/components/tts/common.py @@ -15,7 +15,7 @@ from homeassistant.components import media_source from homeassistant.components.tts import ( CONF_LANG, DATA_TTS_MANAGER, - DOMAIN as TTS_DOMAIN, + DOMAIN, PLATFORM_SCHEMA as TTS_PLATFORM_SCHEMA, Provider, ResultStream, @@ -212,11 +212,9 @@ async def mock_setup( ) -> None: """Set up a test provider.""" 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( - hass, TTS_DOMAIN, {TTS_DOMAIN: {"platform": TEST_DOMAIN}} - ) + await async_setup_component(hass, DOMAIN, {DOMAIN: {"platform": TEST_DOMAIN}}) await hass.async_block_till_done() @@ -261,7 +259,7 @@ async def mock_config_entry_setup( async_add_entities([tts_entity]) 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.add_to_hass(hass) diff --git a/tests/components/unifi/conftest.py b/tests/components/unifi/conftest.py index 4075aa0ad59..7cbefee6760 100644 --- a/tests/components/unifi/conftest.py +++ b/tests/components/unifi/conftest.py @@ -14,7 +14,7 @@ import orjson import pytest 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.const import ( CONF_HOST, @@ -112,7 +112,7 @@ def fixture_config_entry( ) -> MockConfigEntry: """Define a config entry fixture.""" config_entry = MockConfigEntry( - domain=UNIFI_DOMAIN, + domain=DOMAIN, entry_id="1", unique_id="1", data=config_entry_data, diff --git a/tests/components/unifi/test_config_flow.py b/tests/components/unifi/test_config_flow.py index 9d85dedbc9a..cf699e0dcfb 100644 --- a/tests/components/unifi/test_config_flow.py +++ b/tests/components/unifi/test_config_flow.py @@ -21,7 +21,7 @@ from homeassistant.components.unifi.const import ( CONF_TRACK_CLIENTS, CONF_TRACK_DEVICES, CONF_TRACK_WIRED_CLIENTS, - DOMAIN as UNIFI_DOMAIN, + DOMAIN, ) from homeassistant.const import ( CONF_HOST, @@ -100,7 +100,7 @@ async def test_flow_works(hass: HomeAssistant, mock_discovery) -> None: """Test config flow.""" mock_discovery.return_value = "1" 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 @@ -139,7 +139,7 @@ async def test_flow_works(hass: HomeAssistant, mock_discovery) -> None: async def test_flow_works_negative_discovery(hass: HomeAssistant) -> None: """Test config flow with a negative outcome of async_discovery_unifi.""" 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 @@ -166,7 +166,7 @@ async def test_flow_works_negative_discovery(hass: HomeAssistant) -> None: async def test_flow_multiple_sites(hass: HomeAssistant) -> None: """Test config flow works when finding multiple sites.""" 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 @@ -193,7 +193,7 @@ async def test_flow_multiple_sites(hass: HomeAssistant) -> None: async def test_flow_raise_already_configured(hass: HomeAssistant) -> None: """Test config flow aborts since a connected config entry already exists.""" 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 @@ -218,7 +218,7 @@ async def test_flow_raise_already_configured(hass: HomeAssistant) -> None: async def test_flow_aborts_configuration_updated(hass: HomeAssistant) -> None: """Test config flow aborts since a connected config entry already exists.""" 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 @@ -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: """Test config flow.""" 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 @@ -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: """Test config flow.""" 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 @@ -480,7 +480,7 @@ async def test_simple_option_flow( async def test_form_ssdp(hass: HomeAssistant) -> None: """Test we get the form with ssdp source.""" result = await hass.config_entries.flow.async_init( - UNIFI_DOMAIN, + DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=SsdpServiceInfo( 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: """Test we abort if the host is already configured.""" result = await hass.config_entries.flow.async_init( - UNIFI_DOMAIN, + DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=SsdpServiceInfo( 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.""" result = await hass.config_entries.flow.async_init( - UNIFI_DOMAIN, + DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=SsdpServiceInfo( 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: """Test we can still setup if there is an ignored never configured entry.""" entry = MockConfigEntry( - domain=UNIFI_DOMAIN, + domain=DOMAIN, data={"not_controller_key": None}, source=config_entries.SOURCE_IGNORE, ) entry.add_to_hass(hass) result = await hass.config_entries.flow.async_init( - UNIFI_DOMAIN, + DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=SsdpServiceInfo( ssdp_usn="mock_usn", diff --git a/tests/components/unifi/test_device_tracker.py b/tests/components/unifi/test_device_tracker.py index 73b986aed87..65d3bf892d8 100644 --- a/tests/components/unifi/test_device_tracker.py +++ b/tests/components/unifi/test_device_tracker.py @@ -21,7 +21,7 @@ from homeassistant.components.unifi.const import ( CONF_TRACK_DEVICES, CONF_TRACK_WIRED_CLIENTS, DEFAULT_DETECTION_TIME, - DOMAIN as UNIFI_DOMAIN, + DOMAIN, ) from homeassistant.const import STATE_HOME, STATE_NOT_HOME, STATE_UNAVAILABLE, Platform 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.""" entity_registry.async_get_or_create( # Make sure unique ID converts to site_id-mac TRACKER_DOMAIN, - UNIFI_DOMAIN, + DOMAIN, f"{clients_all_payload[0]['mac']}-site_id", suggested_object_id=clients_all_payload[0]["hostname"], config_entry=config_entry, ) entity_registry.async_get_or_create( # Unique ID already follow format site_id-mac TRACKER_DOMAIN, - UNIFI_DOMAIN, + DOMAIN, f"site_id-{client_payload[0]['mac']}", suggested_object_id=client_payload[0]["hostname"], config_entry=config_entry, diff --git a/tests/components/unifi/test_hub.py b/tests/components/unifi/test_hub.py index 8b129d3d648..897eab2ae12 100644 --- a/tests/components/unifi/test_hub.py +++ b/tests/components/unifi/test_hub.py @@ -8,7 +8,7 @@ from unittest.mock import patch import aiounifi 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.hub import get_unifi_api from homeassistant.config_entries import ConfigEntryState @@ -49,7 +49,7 @@ async def test_hub_setup( device_entry = device_registry.async_get_or_create( 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" diff --git a/tests/components/unifi/test_services.py b/tests/components/unifi/test_services.py index a7968a92e22..8f06359fb6b 100644 --- a/tests/components/unifi/test_services.py +++ b/tests/components/unifi/test_services.py @@ -5,7 +5,7 @@ from unittest.mock import PropertyMock, patch 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 ( SERVICE_RECONNECT_CLIENT, SERVICE_REMOVE_CLIENTS, @@ -41,7 +41,7 @@ async def test_reconnect_client( ) await hass.services.async_call( - UNIFI_DOMAIN, + DOMAIN, SERVICE_RECONNECT_CLIENT, service_data={ATTR_DEVICE_ID: device_entry.id}, blocking=True, @@ -57,7 +57,7 @@ async def test_reconnect_non_existant_device( aioclient_mock.clear_requests() await hass.services.async_call( - UNIFI_DOMAIN, + DOMAIN, SERVICE_RECONNECT_CLIENT, service_data={ATTR_DEVICE_ID: "device_entry.id"}, blocking=True, @@ -80,7 +80,7 @@ async def test_reconnect_device_without_mac( ) await hass.services.async_call( - UNIFI_DOMAIN, + DOMAIN, SERVICE_RECONNECT_CLIENT, service_data={ATTR_DEVICE_ID: device_entry.id}, blocking=True, @@ -115,7 +115,7 @@ async def test_reconnect_client_hub_unavailable( ) as ws_mock: ws_mock.return_value = False await hass.services.async_call( - UNIFI_DOMAIN, + DOMAIN, SERVICE_RECONNECT_CLIENT, service_data={ATTR_DEVICE_ID: device_entry.id}, blocking=True, @@ -137,7 +137,7 @@ async def test_reconnect_client_unknown_mac( ) await hass.services.async_call( - UNIFI_DOMAIN, + DOMAIN, SERVICE_RECONNECT_CLIENT, service_data={ATTR_DEVICE_ID: device_entry.id}, blocking=True, @@ -163,7 +163,7 @@ async def test_reconnect_wired_client( ) await hass.services.async_call( - UNIFI_DOMAIN, + DOMAIN, SERVICE_RECONNECT_CLIENT, service_data={ATTR_DEVICE_ID: device_entry.id}, blocking=True, @@ -213,7 +213,7 @@ async def test_remove_clients( 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] == { "cmd": "forget-sta", "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 ) as ws_mock: ws_mock.return_value = False - 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 @@ -268,7 +266,7 @@ async def test_remove_clients_no_call_on_empty_list( ) -> None: """Verify no call is made if no fitting client has been added to the list.""" 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 @@ -297,7 +295,7 @@ async def test_services_handle_unloaded_config_entry( 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 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"])}, ) await hass.services.async_call( - UNIFI_DOMAIN, + DOMAIN, SERVICE_RECONNECT_CLIENT, service_data={ATTR_DEVICE_ID: device_entry.id}, blocking=True, diff --git a/tests/components/unifi/test_switch.py b/tests/components/unifi/test_switch.py index c336c4ef6db..c14ecbc0b06 100644 --- a/tests/components/unifi/test_switch.py +++ b/tests/components/unifi/test_switch.py @@ -20,7 +20,7 @@ from homeassistant.components.unifi.const import ( CONF_SITE_ID, CONF_TRACK_CLIENTS, CONF_TRACK_DEVICES, - DOMAIN as UNIFI_DOMAIN, + DOMAIN, ) from homeassistant.config_entries import RELOAD_AFTER_UPDATE_DELAY from homeassistant.const import ( @@ -1743,14 +1743,14 @@ async def test_updating_unique_id( """Verify outlet control and poe control unique ID update works.""" entity_registry.async_get_or_create( SWITCH_DOMAIN, - UNIFI_DOMAIN, + DOMAIN, f"{device_payload[0]['mac']}-outlet-1", suggested_object_id="plug_outlet_1", config_entry=config_entry, ) entity_registry.async_get_or_create( SWITCH_DOMAIN, - UNIFI_DOMAIN, + DOMAIN, f"{device_payload[1]['mac']}-poe-1", suggested_object_id="switch_port_1_poe", config_entry=config_entry, diff --git a/tests/components/vacuum/conftest.py b/tests/components/vacuum/conftest.py index 5938caa5ce4..f210910cd39 100644 --- a/tests/components/vacuum/conftest.py +++ b/tests/components/vacuum/conftest.py @@ -5,7 +5,7 @@ from unittest.mock import MagicMock, patch 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.const import Platform from homeassistant.core import HomeAssistant @@ -95,7 +95,7 @@ async def setup_vacuum_platform_test_entity( mock_platform( hass, - f"{TEST_DOMAIN}.{VACUUM_DOMAIN}", + f"{TEST_DOMAIN}.{DOMAIN}", MockPlatform(async_setup_entry=async_setup_entry_platform), ) diff --git a/tests/components/vacuum/test_init.py b/tests/components/vacuum/test_init.py index 967b9672805..b4fab54e98d 100644 --- a/tests/components/vacuum/test_init.py +++ b/tests/components/vacuum/test_init.py @@ -10,7 +10,7 @@ import pytest from homeassistant.components import vacuum from homeassistant.components.vacuum import ( - DOMAIN as VACUUM_DOMAIN, + DOMAIN, SERVICE_CLEAN_SPOT, SERVICE_LOCATE, SERVICE_PAUSE, @@ -120,13 +120,11 @@ async def test_state_services( async_unload_entry=help_async_unload_entry, ), ) - setup_test_component_platform( - hass, VACUUM_DOMAIN, [mock_vacuum], from_config_entry=True - ) + setup_test_component_platform(hass, DOMAIN, [mock_vacuum], from_config_entry=True) assert await hass.config_entries.async_setup(config_entry.entry_id) await hass.services.async_call( - VACUUM_DOMAIN, + DOMAIN, service, {"entity_id": mock_vacuum.entity_id}, 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, ), ) - setup_test_component_platform( - hass, VACUUM_DOMAIN, [mock_vacuum], from_config_entry=True - ) + setup_test_component_platform(hass, DOMAIN, [mock_vacuum], from_config_entry=True) assert await hass.config_entries.async_setup(config_entry.entry_id) config_entry = MockConfigEntry(domain="test", data={}) config_entry.add_to_hass(hass) await hass.services.async_call( - VACUUM_DOMAIN, + DOMAIN, SERVICE_SET_FAN_SPEED, {"entity_id": mock_vacuum.entity_id, "fan_speed": "high"}, blocking=True, @@ -201,13 +197,11 @@ async def test_locate(hass: HomeAssistant, config_flow_fixture: None) -> None: async_unload_entry=help_async_unload_entry, ), ) - setup_test_component_platform( - hass, VACUUM_DOMAIN, [mock_vacuum], from_config_entry=True - ) + setup_test_component_platform(hass, DOMAIN, [mock_vacuum], from_config_entry=True) assert await hass.config_entries.async_setup(config_entry.entry_id) await hass.services.async_call( - VACUUM_DOMAIN, + DOMAIN, SERVICE_LOCATE, {"entity_id": mock_vacuum.entity_id}, 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, ), ) - setup_test_component_platform( - hass, VACUUM_DOMAIN, [mock_vacuum], from_config_entry=True - ) + setup_test_component_platform(hass, DOMAIN, [mock_vacuum], from_config_entry=True) assert await hass.config_entries.async_setup(config_entry.entry_id) await hass.services.async_call( - VACUUM_DOMAIN, + DOMAIN, SERVICE_SEND_COMMAND, { "entity_id": mock_vacuum.entity_id, @@ -355,7 +347,7 @@ async def test_vacuum_log_deprecated_state_warning_using_state_prop( ), 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) 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, ) - 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) state = hass.states.get(entity.entity_id) @@ -462,7 +454,7 @@ async def test_vacuum_deprecated_state_does_not_break_state( ), 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) 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" await hass.services.async_call( - VACUUM_DOMAIN, + DOMAIN, SERVICE_START, { "entity_id": entity.entity_id, diff --git a/tests/components/venstar/test_init.py b/tests/components/venstar/test_init.py index 3a03c4c4b88..e0cf8555141 100644 --- a/tests/components/venstar/test_init.py +++ b/tests/components/venstar/test_init.py @@ -2,7 +2,7 @@ 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.const import CONF_HOST, CONF_SSL from homeassistant.core import HomeAssistant @@ -17,7 +17,7 @@ TEST_HOST = "venstartest.localdomain" async def test_setup_entry(hass: HomeAssistant) -> None: """Validate that setup entry also configure the client.""" config_entry = MockConfigEntry( - domain=VENSTAR_DOMAIN, + domain=DOMAIN, data={ CONF_HOST: TEST_HOST, CONF_SSL: False, @@ -64,7 +64,7 @@ async def test_setup_entry(hass: HomeAssistant) -> None: async def test_setup_entry_exception(hass: HomeAssistant) -> None: """Validate that setup entry also configure the client.""" config_entry = MockConfigEntry( - domain=VENSTAR_DOMAIN, + domain=DOMAIN, data={ CONF_HOST: TEST_HOST, CONF_SSL: False, diff --git a/tests/components/wilight/test_switch.py b/tests/components/wilight/test_switch.py index 7140a0780ef..6b248a251e5 100644 --- a/tests/components/wilight/test_switch.py +++ b/tests/components/wilight/test_switch.py @@ -6,7 +6,7 @@ import pytest import pywilight 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 ( ATTR_PAUSE_TIME, ATTR_TRIGGER, @@ -159,7 +159,7 @@ async def test_switch_services( # Set watering time await hass.services.async_call( - WILIGHT_DOMAIN, + DOMAIN, SERVICE_SET_WATERING_TIME, {ATTR_WATERING_TIME: 30, ATTR_ENTITY_ID: "switch.wl000000000099_1_watering"}, blocking=True, @@ -172,7 +172,7 @@ async def test_switch_services( # Set pause time await hass.services.async_call( - WILIGHT_DOMAIN, + DOMAIN, SERVICE_SET_PAUSE_TIME, {ATTR_PAUSE_TIME: 18, ATTR_ENTITY_ID: "switch.wl000000000099_2_pause"}, blocking=True, @@ -185,7 +185,7 @@ async def test_switch_services( # Set trigger_1 await hass.services.async_call( - WILIGHT_DOMAIN, + DOMAIN, SERVICE_SET_TRIGGER, { ATTR_TRIGGER_INDEX: "1", @@ -202,7 +202,7 @@ async def test_switch_services( # Set trigger_2 await hass.services.async_call( - WILIGHT_DOMAIN, + DOMAIN, SERVICE_SET_TRIGGER, { ATTR_TRIGGER_INDEX: "2", @@ -219,7 +219,7 @@ async def test_switch_services( # Set trigger_3 await hass.services.async_call( - WILIGHT_DOMAIN, + DOMAIN, SERVICE_SET_TRIGGER, { ATTR_TRIGGER_INDEX: "3", @@ -236,7 +236,7 @@ async def test_switch_services( # Set trigger_4 await hass.services.async_call( - WILIGHT_DOMAIN, + DOMAIN, SERVICE_SET_TRIGGER, { ATTR_TRIGGER_INDEX: "4", @@ -254,7 +254,7 @@ async def test_switch_services( # Set watering time using WiLight Pause Switch to raise with pytest.raises(TypeError) as exc_info: await hass.services.async_call( - WILIGHT_DOMAIN, + DOMAIN, SERVICE_SET_WATERING_TIME, {ATTR_WATERING_TIME: 30, ATTR_ENTITY_ID: "switch.wl000000000099_2_pause"}, blocking=True, diff --git a/tests/components/xiaomi_miio/test_button.py b/tests/components/xiaomi_miio/test_button.py index 1f79a3ec0d0..6b5b536e8cc 100644 --- a/tests/components/xiaomi_miio/test_button.py +++ b/tests/components/xiaomi_miio/test_button.py @@ -7,7 +7,7 @@ import pytest from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, SERVICE_PRESS from homeassistant.components.xiaomi_miio.const import ( CONF_FLOW_TYPE, - DOMAIN as XIAOMI_DOMAIN, + DOMAIN, MODELS_VACUUM, ) 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}" config_entry = MockConfigEntry( - domain=XIAOMI_DOMAIN, + domain=DOMAIN, unique_id="123456", title=entity_name, data={ diff --git a/tests/components/xiaomi_miio/test_select.py b/tests/components/xiaomi_miio/test_select.py index 566f1516fdf..945809efd33 100644 --- a/tests/components/xiaomi_miio/test_select.py +++ b/tests/components/xiaomi_miio/test_select.py @@ -18,7 +18,7 @@ from homeassistant.components.select import ( from homeassistant.components.xiaomi_miio import UPDATE_INTERVAL from homeassistant.components.xiaomi_miio.const import ( CONF_FLOW_TYPE, - DOMAIN as XIAOMI_DOMAIN, + DOMAIN, MODEL_AIRFRESH_T2017, ) 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}" config_entry = MockConfigEntry( - domain=XIAOMI_DOMAIN, + domain=DOMAIN, unique_id="123456", title=entity_name, data={ diff --git a/tests/components/xiaomi_miio/test_vacuum.py b/tests/components/xiaomi_miio/test_vacuum.py index e58f21e387b..385e706f0bf 100644 --- a/tests/components/xiaomi_miio/test_vacuum.py +++ b/tests/components/xiaomi_miio/test_vacuum.py @@ -25,7 +25,7 @@ from homeassistant.components.vacuum import ( ) from homeassistant.components.xiaomi_miio.const import ( CONF_FLOW_TYPE, - DOMAIN as XIAOMI_DOMAIN, + DOMAIN, MODELS_VACUUM, ) from homeassistant.components.xiaomi_miio.vacuum import ( @@ -471,7 +471,7 @@ async def test_xiaomi_specific_services( device_method_attr.side_effect = error await hass.services.async_call( - XIAOMI_DOMAIN, + DOMAIN, service, service_data, blocking=True, @@ -537,7 +537,7 @@ async def setup_component(hass: HomeAssistant, entity_name: str) -> str: entity_id = f"{VACUUM_DOMAIN}.{entity_name}" config_entry = MockConfigEntry( - domain=XIAOMI_DOMAIN, + domain=DOMAIN, unique_id="123456", title=entity_name, data={ diff --git a/tests/components/zamg/__init__.py b/tests/components/zamg/__init__.py index 33a9acaddba..50d859e791f 100644 --- a/tests/components/zamg/__init__.py +++ b/tests/components/zamg/__init__.py @@ -1,13 +1,13 @@ """Tests for the ZAMG component.""" 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 FIXTURE_CONFIG_ENTRY = { "entry_id": "1", - "domain": ZAMG_DOMAIN, + "domain": DOMAIN, "title": TEST_STATION_NAME, "data": { CONF_STATION_ID: TEST_STATION_ID, diff --git a/tests/components/zamg/test_init.py b/tests/components/zamg/test_init.py index 9f05882853a..adde24f71a8 100644 --- a/tests/components/zamg/test_init.py +++ b/tests/components/zamg/test_init.py @@ -4,7 +4,7 @@ import pytest from homeassistant.components.sensor import DOMAIN as SENSOR_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.helpers import entity_registry as er @@ -25,7 +25,7 @@ from tests.common import MockConfigEntry ( { "domain": WEATHER_DOMAIN, - "platform": ZAMG_DOMAIN, + "platform": DOMAIN, "unique_id": f"{TEST_STATION_NAME}_{TEST_STATION_ID}", "suggested_object_id": f"Zamg {TEST_STATION_NAME}", "disabled_by": None, @@ -37,7 +37,7 @@ from tests.common import MockConfigEntry ( { "domain": WEATHER_DOMAIN, - "platform": ZAMG_DOMAIN, + "platform": DOMAIN, "unique_id": f"{TEST_STATION_NAME_2}_{TEST_STATION_ID_2}", "suggested_object_id": f"Zamg {TEST_STATION_NAME_2}", "disabled_by": None, @@ -49,7 +49,7 @@ from tests.common import MockConfigEntry ( { "domain": SENSOR_DOMAIN, - "platform": ZAMG_DOMAIN, + "platform": DOMAIN, "unique_id": f"{TEST_STATION_NAME_2}_{TEST_STATION_ID_2}_temperature", "suggested_object_id": f"Zamg {TEST_STATION_NAME_2}", "disabled_by": None, @@ -95,7 +95,7 @@ async def test_migrate_unique_ids( ( { "domain": WEATHER_DOMAIN, - "platform": ZAMG_DOMAIN, + "platform": DOMAIN, "unique_id": f"{TEST_STATION_NAME}_{TEST_STATION_ID}", "suggested_object_id": f"Zamg {TEST_STATION_NAME}", "disabled_by": None, @@ -123,7 +123,7 @@ async def test_dont_migrate_unique_ids( # create existing entry with new_unique_id existing_entity = entity_registry.async_get_or_create( WEATHER_DOMAIN, - ZAMG_DOMAIN, + DOMAIN, unique_id=TEST_STATION_ID, suggested_object_id=f"Zamg {TEST_STATION_NAME}", config_entry=mock_config_entry, @@ -156,7 +156,7 @@ async def test_dont_migrate_unique_ids( ( { "domain": WEATHER_DOMAIN, - "platform": ZAMG_DOMAIN, + "platform": DOMAIN, "unique_id": TEST_STATION_ID, "suggested_object_id": f"Zamg {TEST_STATION_NAME}", "disabled_by": None, @@ -178,7 +178,7 @@ async def test_unload_entry( entity_registry.async_get_or_create( WEATHER_DOMAIN, - ZAMG_DOMAIN, + DOMAIN, unique_id=TEST_STATION_ID, suggested_object_id=f"Zamg {TEST_STATION_NAME}", config_entry=mock_config_entry, diff --git a/tests/components/zwave_js/test_lock.py b/tests/components/zwave_js/test_lock.py index 47e680570f0..1011026ac68 100644 --- a/tests/components/zwave_js/test_lock.py +++ b/tests/components/zwave_js/test_lock.py @@ -20,7 +20,7 @@ from homeassistant.components.lock import ( from homeassistant.components.zwave_js.const import ( ATTR_LOCK_TIMEOUT, ATTR_OPERATION_TYPE, - DOMAIN as ZWAVE_JS_DOMAIN, + DOMAIN, ) from homeassistant.components.zwave_js.helpers import ZwaveValueMatcher from homeassistant.components.zwave_js.lock import ( @@ -119,7 +119,7 @@ async def test_door_lock( # Test set usercode service await hass.services.async_call( - ZWAVE_JS_DOMAIN, + DOMAIN, SERVICE_SET_LOCK_USERCODE, { ATTR_ENTITY_ID: SCHLAGE_BE469_LOCK_ENTITY, @@ -145,7 +145,7 @@ async def test_door_lock( # Test clear usercode await hass.services.async_call( - ZWAVE_JS_DOMAIN, + DOMAIN, SERVICE_CLEAR_LOCK_USERCODE, {ATTR_ENTITY_ID: SCHLAGE_BE469_LOCK_ENTITY, ATTR_CODE_SLOT: 1}, blocking=True, @@ -171,7 +171,7 @@ async def test_door_lock( } caplog.clear() await hass.services.async_call( - ZWAVE_JS_DOMAIN, + DOMAIN, SERVICE_SET_LOCK_CONFIGURATION, { ATTR_ENTITY_ID: SCHLAGE_BE469_LOCK_ENTITY, @@ -216,7 +216,7 @@ async def test_door_lock( node.receive_event(event) await hass.services.async_call( - ZWAVE_JS_DOMAIN, + DOMAIN, SERVICE_SET_LOCK_CONFIGURATION, { ATTR_ENTITY_ID: SCHLAGE_BE469_LOCK_ENTITY, @@ -261,7 +261,7 @@ async def test_door_lock( # Test set usercode service error handling with pytest.raises(HomeAssistantError): await hass.services.async_call( - ZWAVE_JS_DOMAIN, + DOMAIN, SERVICE_SET_LOCK_USERCODE, { ATTR_ENTITY_ID: SCHLAGE_BE469_LOCK_ENTITY, @@ -274,7 +274,7 @@ async def test_door_lock( # Test clear usercode service error handling with pytest.raises(HomeAssistantError): await hass.services.async_call( - ZWAVE_JS_DOMAIN, + DOMAIN, SERVICE_CLEAR_LOCK_USERCODE, {ATTR_ENTITY_ID: SCHLAGE_BE469_LOCK_ENTITY, ATTR_CODE_SLOT: 1}, blocking=True,