Rename DOMAIN aliases in tests (#163176)

This commit is contained in:
epenet
2026-02-16 16:47:53 +01:00
committed by GitHub
parent 97df38f1da
commit fed9ed615e
12 changed files with 57 additions and 59 deletions

View File

@@ -12,7 +12,7 @@ from syrupy.assertion import SnapshotAssertion
from homeassistant.components.ecovacs.const import DOMAIN
from homeassistant.components.ecovacs.controller import EcovacsController
from homeassistant.components.lawn_mower import (
DOMAIN as PLATFORM_DOMAIN,
DOMAIN as LAWN_MOWER_DOMAIN,
SERVICE_DOCK,
SERVICE_PAUSE,
SERVICE_START_MOWING,
@@ -108,7 +108,7 @@ async def test_mover_services(
for test in tests:
device._execute_command.reset_mock()
await hass.services.async_call(
PLATFORM_DOMAIN,
LAWN_MOWER_DOMAIN,
test.service_name,
{ATTR_ENTITY_ID: entity_id},
blocking=True,

View File

@@ -18,7 +18,7 @@ from homeassistant.components.ecovacs.const import DOMAIN
from homeassistant.components.ecovacs.controller import EcovacsController
from homeassistant.components.number import (
ATTR_VALUE,
DOMAIN as PLATFORM_DOMAIN,
DOMAIN as NUMBER_DOMAIN,
SERVICE_SET_VALUE,
)
from homeassistant.const import ATTR_ENTITY_ID, STATE_UNKNOWN, Platform
@@ -139,7 +139,7 @@ async def test_number_entities(
device._execute_command.reset_mock()
await hass.services.async_call(
PLATFORM_DOMAIN,
NUMBER_DOMAIN,
SERVICE_SET_VALUE,
{ATTR_ENTITY_ID: entity_id, ATTR_VALUE: test_case.set_value},
blocking=True,

View File

@@ -33,7 +33,7 @@ from syrupy.assertion import SnapshotAssertion
from homeassistant.components.ecovacs.const import DOMAIN
from homeassistant.components.ecovacs.controller import EcovacsController
from homeassistant.components.switch import DOMAIN as PLATFORM_DOMAIN
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
from homeassistant.const import (
ATTR_ENTITY_ID,
SERVICE_TURN_OFF,
@@ -196,7 +196,7 @@ async def test_switch_entities(
device._execute_command.reset_mock()
await hass.services.async_call(
PLATFORM_DOMAIN,
SWITCH_DOMAIN,
SERVICE_TURN_OFF,
{ATTR_ENTITY_ID: entity_id},
blocking=True,
@@ -205,7 +205,7 @@ async def test_switch_entities(
device._execute_command.reset_mock()
await hass.services.async_call(
PLATFORM_DOMAIN,
SWITCH_DOMAIN,
SERVICE_TURN_ON,
{ATTR_ENTITY_ID: entity_id},
blocking=True,

View File

@@ -6,7 +6,7 @@ import pytest
from homeassistant.components.litterrobot.sensor import icon_for_gauge_level
from homeassistant.components.sensor import (
DOMAIN as PLATFORM_DOMAIN,
DOMAIN as SENSOR_DOMAIN,
SensorDeviceClass,
SensorStateClass,
)
@@ -24,7 +24,7 @@ async def test_waste_drawer_sensor(
hass: HomeAssistant, mock_account: MagicMock
) -> None:
"""Tests the waste drawer sensor entity was set up."""
await setup_integration(hass, mock_account, PLATFORM_DOMAIN)
await setup_integration(hass, mock_account, SENSOR_DOMAIN)
sensor = hass.states.get(WASTE_DRAWER_ENTITY_ID)
assert sensor
@@ -36,9 +36,7 @@ async def test_sleep_time_sensor_with_sleep_disabled(
hass: HomeAssistant, mock_account_with_sleep_disabled_robot: MagicMock
) -> None:
"""Tests the sleep mode start time sensor where sleep mode is disabled."""
await setup_integration(
hass, mock_account_with_sleep_disabled_robot, PLATFORM_DOMAIN
)
await setup_integration(hass, mock_account_with_sleep_disabled_robot, SENSOR_DOMAIN)
sensor = hass.states.get(SLEEP_START_TIME_ENTITY_ID)
assert sensor
@@ -79,7 +77,7 @@ async def test_litter_robot_sensor(
hass: HomeAssistant, mock_account_with_litterrobot_4: MagicMock
) -> None:
"""Tests Litter-Robot sensors."""
await setup_integration(hass, mock_account_with_litterrobot_4, PLATFORM_DOMAIN)
await setup_integration(hass, mock_account_with_litterrobot_4, SENSOR_DOMAIN)
sensor = hass.states.get(SLEEP_START_TIME_ENTITY_ID)
assert sensor.state == "2022-09-19T04:00:00+00:00"
@@ -109,7 +107,7 @@ async def test_feeder_robot_sensor(
hass: HomeAssistant, mock_account_with_feederrobot: MagicMock
) -> None:
"""Tests Feeder-Robot sensors."""
await setup_integration(hass, mock_account_with_feederrobot, PLATFORM_DOMAIN)
await setup_integration(hass, mock_account_with_feederrobot, SENSOR_DOMAIN)
sensor = hass.states.get("sensor.test_food_level")
assert sensor.state == "10"
assert sensor.attributes["unit_of_measurement"] == PERCENTAGE
@@ -133,7 +131,7 @@ async def test_pet_weight_sensor(
hass: HomeAssistant, mock_account_with_pet: MagicMock
) -> None:
"""Tests pet weight sensors."""
await setup_integration(hass, mock_account_with_pet, PLATFORM_DOMAIN)
await setup_integration(hass, mock_account_with_pet, SENSOR_DOMAIN)
sensor = hass.states.get("sensor.kitty_weight")
assert sensor.state == "9.1"
assert sensor.attributes["unit_of_measurement"] == UnitOfMass.POUNDS
@@ -144,7 +142,7 @@ async def test_pet_visits_today_sensor(
hass: HomeAssistant, mock_account_with_pet: MagicMock
) -> None:
"""Tests pet visits today sensors."""
await setup_integration(hass, mock_account_with_pet, PLATFORM_DOMAIN)
await setup_integration(hass, mock_account_with_pet, SENSOR_DOMAIN)
sensor = hass.states.get("sensor.kitty_visits_today")
assert sensor.state == "2"
@@ -153,6 +151,6 @@ async def test_litterhopper_sensor(
hass: HomeAssistant, mock_account_with_litterhopper: MagicMock
) -> None:
"""Tests LitterHopper sensors."""
await setup_integration(hass, mock_account_with_litterhopper, PLATFORM_DOMAIN)
await setup_integration(hass, mock_account_with_litterhopper, SENSOR_DOMAIN)
sensor = hass.states.get("sensor.test_hopper_status")
assert sensor.state == "enabled"

View File

@@ -7,7 +7,7 @@ import pytest
from homeassistant.components.litterrobot import DOMAIN
from homeassistant.components.switch import (
DOMAIN as PLATFORM_DOMAIN,
DOMAIN as SWITCH_DOMAIN,
SERVICE_TURN_OFF,
SERVICE_TURN_ON,
)
@@ -25,7 +25,7 @@ async def test_switch(
hass: HomeAssistant, mock_account: MagicMock, entity_registry: er.EntityRegistry
) -> None:
"""Tests the switch entity was set up."""
await setup_integration(hass, mock_account, PLATFORM_DOMAIN)
await setup_integration(hass, mock_account, SWITCH_DOMAIN)
state = hass.states.get(NIGHT_LIGHT_MODE_ENTITY_ID)
assert state
@@ -51,7 +51,7 @@ async def test_on_off_commands(
updated_field: str,
) -> None:
"""Test sending commands to the switch."""
await setup_integration(hass, mock_account, PLATFORM_DOMAIN)
await setup_integration(hass, mock_account, SWITCH_DOMAIN)
robot: Robot = mock_account.robots[0]
state = hass.states.get(entity_id)
@@ -61,7 +61,7 @@ async def test_on_off_commands(
services = ((SERVICE_TURN_ON, STATE_ON, "1"), (SERVICE_TURN_OFF, STATE_OFF, "0"))
for count, (service, new_state, new_value) in enumerate(services):
await hass.services.async_call(PLATFORM_DOMAIN, service, data, blocking=True)
await hass.services.async_call(SWITCH_DOMAIN, service, data, blocking=True)
robot._update_data({updated_field: new_value}, partial=True)
assert getattr(robot, robot_command).call_count == count + 1
@@ -73,7 +73,7 @@ async def test_feeder_robot_switch(
hass: HomeAssistant, mock_account_with_feederrobot: MagicMock
) -> None:
"""Tests Feeder-Robot switches."""
await setup_integration(hass, mock_account_with_feederrobot, PLATFORM_DOMAIN)
await setup_integration(hass, mock_account_with_feederrobot, SWITCH_DOMAIN)
robot: FeederRobot = mock_account_with_feederrobot.robots[0]
gravity_mode_switch = "switch.test_gravity_mode"
@@ -85,7 +85,7 @@ async def test_feeder_robot_switch(
services = ((SERVICE_TURN_ON, STATE_ON, True), (SERVICE_TURN_OFF, STATE_OFF, False))
for count, (service, new_state, new_value) in enumerate(services):
await hass.services.async_call(PLATFORM_DOMAIN, service, data, blocking=True)
await hass.services.async_call(SWITCH_DOMAIN, service, data, blocking=True)
robot._update_data({"state": {"info": {"gravity": new_value}}}, partial=True)
assert robot.set_gravity_mode.call_count == count + 1
@@ -114,16 +114,16 @@ async def test_litterrobot_4_deprecated_switch(
"""Test switch deprecation issue."""
entity_uid = "LR4C010001-night_light_mode_enabled"
if preexisting_entity:
suggested_id = NIGHT_LIGHT_MODE_ENTITY_ID.replace(f"{PLATFORM_DOMAIN}.", "")
suggested_id = NIGHT_LIGHT_MODE_ENTITY_ID.replace(f"{SWITCH_DOMAIN}.", "")
entity_registry.async_get_or_create(
PLATFORM_DOMAIN,
SWITCH_DOMAIN,
DOMAIN,
entity_uid,
suggested_object_id=suggested_id,
disabled_by=disabled_by,
)
await setup_integration(hass, mock_account_with_litterrobot_4, PLATFORM_DOMAIN)
await setup_integration(hass, mock_account_with_litterrobot_4, SWITCH_DOMAIN)
assert (
entity_registry.async_get(NIGHT_LIGHT_MODE_ENTITY_ID) is not None

View File

@@ -8,7 +8,7 @@ from unittest.mock import MagicMock
from pylitterbot import LitterRobot3
import pytest
from homeassistant.components.time import DOMAIN as PLATFORM_DOMAIN
from homeassistant.components.time import DOMAIN as TIME_DOMAIN
from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.core import HomeAssistant
@@ -22,7 +22,7 @@ async def test_sleep_mode_start_time(
hass: HomeAssistant, mock_account: MagicMock
) -> None:
"""Tests the sleep mode start time."""
await setup_integration(hass, mock_account, PLATFORM_DOMAIN)
await setup_integration(hass, mock_account, TIME_DOMAIN)
entity = hass.states.get(SLEEP_START_TIME_ENTITY_ID)
assert entity
@@ -30,7 +30,7 @@ async def test_sleep_mode_start_time(
robot: LitterRobot3 = mock_account.robots[0]
await hass.services.async_call(
PLATFORM_DOMAIN,
TIME_DOMAIN,
"set_value",
{ATTR_ENTITY_ID: SLEEP_START_TIME_ENTITY_ID, "time": time(23, 0)},
blocking=True,

View File

@@ -10,7 +10,7 @@ from homeassistant.components.update import (
ATTR_INSTALLED_VERSION,
ATTR_LATEST_VERSION,
ATTR_RELEASE_URL,
DOMAIN as PLATFORM_DOMAIN,
DOMAIN as UPDATE_DOMAIN,
SERVICE_INSTALL,
UpdateDeviceClass,
)
@@ -40,7 +40,7 @@ async def test_robot_with_no_update(
robot.get_latest_firmware = AsyncMock(return_value=None)
entry = await setup_integration(
hass, mock_account_with_litterrobot_4, PLATFORM_DOMAIN
hass, mock_account_with_litterrobot_4, UPDATE_DOMAIN
)
state = hass.states.get(ENTITY_ID)
@@ -63,7 +63,7 @@ async def test_robot_with_update(
robot.has_firmware_update = AsyncMock(return_value=True)
robot.get_latest_firmware = AsyncMock(return_value=NEW_FIRMWARE)
await setup_integration(hass, mock_account_with_litterrobot_4, PLATFORM_DOMAIN)
await setup_integration(hass, mock_account_with_litterrobot_4, UPDATE_DOMAIN)
state = hass.states.get(ENTITY_ID)
assert state
@@ -77,7 +77,7 @@ async def test_robot_with_update(
with pytest.raises(HomeAssistantError):
await hass.services.async_call(
PLATFORM_DOMAIN,
UPDATE_DOMAIN,
SERVICE_INSTALL,
{ATTR_ENTITY_ID: ENTITY_ID},
blocking=True,
@@ -87,7 +87,7 @@ async def test_robot_with_update(
robot.update_firmware = AsyncMock(return_value=True)
await hass.services.async_call(
PLATFORM_DOMAIN, SERVICE_INSTALL, {ATTR_ENTITY_ID: ENTITY_ID}, blocking=True
UPDATE_DOMAIN, SERVICE_INSTALL, {ATTR_ENTITY_ID: ENTITY_ID}, blocking=True
)
await hass.async_block_till_done()
assert robot.update_firmware.call_count == 1
@@ -101,7 +101,7 @@ async def test_robot_with_update_already_in_progress(
robot._update_data({"isFirmwareUpdateTriggered": True}, partial=True)
entry = await setup_integration(
hass, mock_account_with_litterrobot_4, PLATFORM_DOMAIN
hass, mock_account_with_litterrobot_4, UPDATE_DOMAIN
)
state = hass.states.get(ENTITY_ID)

View File

@@ -8,7 +8,7 @@ from nibe.coil_groups import UNIT_COILGROUPS
from nibe.heatpump import Model
import pytest
from homeassistant.components.button import DOMAIN as PLATFORM_DOMAIN, SERVICE_PRESS
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, SERVICE_PRESS
from homeassistant.const import (
ATTR_ENTITY_ID,
STATE_UNAVAILABLE,
@@ -67,7 +67,7 @@ async def test_reset_button(
# Press button
await hass.services.async_call(
PLATFORM_DOMAIN,
BUTTON_DOMAIN,
SERVICE_PRESS,
{ATTR_ENTITY_ID: entity_id},
blocking=True,

View File

@@ -19,7 +19,7 @@ from homeassistant.components.climate import (
ATTR_TARGET_TEMP_HIGH,
ATTR_TARGET_TEMP_LOW,
ATTR_TEMPERATURE,
DOMAIN as PLATFORM_DOMAIN,
DOMAIN as CLIMATE_DOMAIN,
SERVICE_SET_HVAC_MODE,
SERVICE_SET_TEMPERATURE,
HVACMode,
@@ -164,7 +164,7 @@ async def test_set_temperature_supported_cooling(
)
await hass.services.async_call(
PLATFORM_DOMAIN,
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{
ATTR_ENTITY_ID: entity_id,
@@ -181,7 +181,7 @@ async def test_set_temperature_supported_cooling(
mock_connection.write_coil.reset_mock()
await hass.services.async_call(
PLATFORM_DOMAIN,
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{
ATTR_ENTITY_ID: entity_id,
@@ -199,7 +199,7 @@ async def test_set_temperature_supported_cooling(
with pytest.raises(ServiceValidationError):
await hass.services.async_call(
PLATFORM_DOMAIN,
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{
ATTR_ENTITY_ID: entity_id,
@@ -209,7 +209,7 @@ async def test_set_temperature_supported_cooling(
)
await hass.services.async_call(
PLATFORM_DOMAIN,
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{
ATTR_ENTITY_ID: entity_id,
@@ -255,7 +255,7 @@ async def test_set_temperature_unsupported_cooling(
# Set temperature to heat
await hass.services.async_call(
PLATFORM_DOMAIN,
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{
ATTR_ENTITY_ID: entity_id,
@@ -272,7 +272,7 @@ async def test_set_temperature_unsupported_cooling(
# Attempt to set temperature to cool should raise ServiceValidationError
with pytest.raises(ServiceValidationError):
await hass.services.async_call(
PLATFORM_DOMAIN,
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{
ATTR_ENTITY_ID: entity_id,
@@ -324,7 +324,7 @@ async def test_set_hvac_mode(
)
await hass.services.async_call(
PLATFORM_DOMAIN,
CLIMATE_DOMAIN,
SERVICE_SET_HVAC_MODE,
{
ATTR_ENTITY_ID: entity_id,
@@ -364,7 +364,7 @@ async def test_set_invalid_hvac_mode(
await async_add_model(hass, model)
with pytest.raises(ServiceValidationError):
await hass.services.async_call(
PLATFORM_DOMAIN,
CLIMATE_DOMAIN,
SERVICE_SET_HVAC_MODE,
{
ATTR_ENTITY_ID: entity_id,

View File

@@ -11,7 +11,7 @@ from syrupy.assertion import SnapshotAssertion
from homeassistant.components.number import (
ATTR_VALUE,
DOMAIN as PLATFORM_DOMAIN,
DOMAIN as NUMBER_DOMAIN,
SERVICE_SET_VALUE,
)
from homeassistant.const import ATTR_ENTITY_ID, Platform
@@ -95,7 +95,7 @@ async def test_set_value(
# Write value
await hass.services.async_call(
PLATFORM_DOMAIN,
NUMBER_DOMAIN,
SERVICE_SET_VALUE,
{ATTR_ENTITY_ID: entity_id, ATTR_VALUE: value},
blocking=True,
@@ -158,7 +158,7 @@ async def test_set_value_fail(
# Write value
with pytest.raises(HomeAssistantError) as exc_info:
await hass.services.async_call(
PLATFORM_DOMAIN,
NUMBER_DOMAIN,
SERVICE_SET_VALUE,
{ATTR_ENTITY_ID: entity_id, ATTR_VALUE: value},
blocking=True,
@@ -192,7 +192,7 @@ async def test_set_value_same(
# Write value
await hass.services.async_call(
PLATFORM_DOMAIN,
NUMBER_DOMAIN,
SERVICE_SET_VALUE,
{ATTR_ENTITY_ID: entity_id, ATTR_VALUE: value},
blocking=True,

View File

@@ -10,7 +10,7 @@ from homeassistant.components.update import (
ATTR_LATEST_VERSION,
ATTR_RELEASE_SUMMARY,
ATTR_RELEASE_URL,
DOMAIN as PLATFORM_DOMAIN,
DOMAIN as UPDATE_DOMAIN,
SERVICE_INSTALL,
UpdateDeviceClass,
)
@@ -148,7 +148,7 @@ async def test_update_available(hass: HomeAssistant) -> None:
)
await hass.services.async_call(
PLATFORM_DOMAIN,
UPDATE_DOMAIN,
SERVICE_INSTALL,
{ATTR_ENTITY_ID: "update.friendly_name"},
blocking=True,
@@ -166,7 +166,7 @@ async def test_firmware_update_not_required(hass: HomeAssistant) -> None:
with pytest.raises(HomeAssistantError):
await hass.services.async_call(
PLATFORM_DOMAIN,
UPDATE_DOMAIN,
SERVICE_INSTALL,
{ATTR_ENTITY_ID: "update.friendly_name"},
blocking=True,

View File

@@ -16,7 +16,7 @@ from homeassistant.components.update import (
ATTR_INSTALLED_VERSION,
ATTR_LATEST_VERSION,
ATTR_UPDATE_PERCENTAGE,
DOMAIN as PLATFORM,
DOMAIN as UPDATE_DOMAIN,
SERVICE_INSTALL,
)
from homeassistant.const import ATTR_ENTITY_ID, STATE_OFF, STATE_ON, Platform
@@ -113,7 +113,7 @@ async def test_update_firmware(
assert state.attributes[ATTR_LATEST_VERSION] == "v2.7.5"
await hass.services.async_call(
PLATFORM,
UPDATE_DOMAIN,
SERVICE_INSTALL,
{ATTR_ENTITY_ID: entity_id},
blocking=False,
@@ -167,7 +167,7 @@ async def test_update_zigbee2_firmware(
assert state.attributes[ATTR_LATEST_VERSION] == "20240716"
await hass.services.async_call(
PLATFORM,
UPDATE_DOMAIN,
SERVICE_INSTALL,
{ATTR_ENTITY_ID: entity_id},
blocking=False,
@@ -212,7 +212,7 @@ async def test_update_legacy_firmware_v2(
assert state.attributes[ATTR_LATEST_VERSION] == "v2.7.5"
await hass.services.async_call(
PLATFORM,
UPDATE_DOMAIN,
SERVICE_INSTALL,
{ATTR_ENTITY_ID: entity_id},
blocking=False,
@@ -253,7 +253,7 @@ async def test_update_firmware_failed(
assert state.attributes[ATTR_LATEST_VERSION] == "v2.7.5"
await hass.services.async_call(
PLATFORM,
UPDATE_DOMAIN,
SERVICE_INSTALL,
{ATTR_ENTITY_ID: entity_id},
blocking=False,
@@ -300,7 +300,7 @@ async def test_update_reboot_timeout(
),
):
await hass.services.async_call(
PLATFORM,
UPDATE_DOMAIN,
SERVICE_INSTALL,
{ATTR_ENTITY_ID: entity_id},
blocking=False,