Remove unnecessary DOMAIN alias in tests (l-r) (#146009)

* Remove unnecessary DOMAIN alias in tests (l-r)

* Keep late import in lirc
This commit is contained in:
epenet 2025-06-02 08:54:55 +02:00 committed by GitHub
parent 85a86c3f11
commit 0cf2ee0bcb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
25 changed files with 147 additions and 183 deletions

View File

@ -2,9 +2,7 @@
from unittest.mock import MagicMock, patch
from homeassistant.components.landisgyr_heat_meter.const import (
DOMAIN as LANDISGYR_HEAT_METER_DOMAIN,
)
from homeassistant.components.landisgyr_heat_meter.const import DOMAIN
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
@ -66,7 +64,7 @@ async def test_migrate_entry(
# Create entity entry to migrate to new unique ID
entity_registry.async_get_or_create(
SENSOR_DOMAIN,
LANDISGYR_HEAT_METER_DOMAIN,
DOMAIN,
"landisgyr_heat_meter_987654321_measuring_range_m3ph",
suggested_object_id="heat_meter_measuring_range",
config_entry=mock_entry,

View File

@ -6,7 +6,7 @@ from unittest.mock import MagicMock
import pytest
from homeassistant.components.lawn_mower import (
DOMAIN as LAWN_MOWER_DOMAIN,
DOMAIN,
LawnMowerActivity,
LawnMowerEntity,
LawnMowerEntityFeature,
@ -104,7 +104,7 @@ async def test_lawn_mower_setup(hass: HomeAssistant) -> None:
mock_platform(
hass,
f"{TEST_DOMAIN}.{LAWN_MOWER_DOMAIN}",
f"{TEST_DOMAIN}.{DOMAIN}",
MockPlatform(async_setup_entry=async_setup_entry_platform),
)

View File

@ -14,18 +14,18 @@ async def test_repair_issue_is_created(
) -> None:
"""Test repair issue is created."""
from homeassistant.components.lirc import ( # pylint: disable=import-outside-toplevel
DOMAIN as LIRC_DOMAIN,
DOMAIN,
)
assert await async_setup_component(
hass,
LIRC_DOMAIN,
DOMAIN,
{
LIRC_DOMAIN: {},
DOMAIN: {},
},
)
await hass.async_block_till_done()
assert (
HOMEASSISTANT_DOMAIN,
f"deprecated_system_packages_yaml_integration_{LIRC_DOMAIN}",
f"deprecated_system_packages_yaml_integration_{DOMAIN}",
) in issue_registry.issues

View File

@ -6,11 +6,7 @@ from unittest.mock import MagicMock
import pytest
from homeassistant.components.lock import (
DOMAIN as LOCK_DOMAIN,
LockEntity,
LockEntityFeature,
)
from homeassistant.components.lock import DOMAIN, LockEntity, LockEntityFeature
from homeassistant.config_entries import ConfigEntry, ConfigFlow
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
@ -128,7 +124,7 @@ async def setup_lock_platform_test_entity(
mock_platform(
hass,
f"{TEST_DOMAIN}.{LOCK_DOMAIN}",
f"{TEST_DOMAIN}.{DOMAIN}",
MockPlatform(async_setup_entry=async_setup_entry_platform),
)

View File

@ -38,7 +38,7 @@ from homeassistant.components.matrix import (
RoomAnyID,
RoomID,
)
from homeassistant.components.matrix.const import DOMAIN as MATRIX_DOMAIN
from homeassistant.components.matrix.const import DOMAIN
from homeassistant.components.matrix.notify import CONF_DEFAULT_ROOM
from homeassistant.components.notify import DOMAIN as NOTIFY_DOMAIN
from homeassistant.const import (
@ -137,7 +137,7 @@ class _MockAsyncClient(AsyncClient):
MOCK_CONFIG_DATA = {
MATRIX_DOMAIN: {
DOMAIN: {
CONF_HOMESERVER: "https://matrix.example.com",
CONF_USERNAME: TEST_MXID,
CONF_PASSWORD: TEST_PASSWORD,
@ -166,7 +166,7 @@ MOCK_CONFIG_DATA = {
},
NOTIFY_DOMAIN: {
CONF_NAME: TEST_NOTIFIER_NAME,
CONF_PLATFORM: MATRIX_DOMAIN,
CONF_PLATFORM: DOMAIN,
CONF_DEFAULT_ROOM: TEST_DEFAULT_ROOM,
},
}
@ -282,13 +282,13 @@ async def matrix_bot(
The resulting MatrixBot will have a mocked _client.
"""
assert await async_setup_component(hass, MATRIX_DOMAIN, MOCK_CONFIG_DATA)
assert await async_setup_component(hass, DOMAIN, MOCK_CONFIG_DATA)
assert await async_setup_component(hass, NOTIFY_DOMAIN, MOCK_CONFIG_DATA)
await hass.async_block_till_done()
# Accessing hass.data in tests is not desirable, but all the tests here
# currently do this.
assert isinstance(matrix_bot := hass.data[MATRIX_DOMAIN], MatrixBot)
assert isinstance(matrix_bot := hass.data[DOMAIN], MatrixBot)
await hass.async_start()
@ -298,7 +298,7 @@ async def matrix_bot(
@pytest.fixture
def matrix_events(hass: HomeAssistant) -> list[Event]:
"""Track event calls."""
return async_capture_events(hass, MATRIX_DOMAIN)
return async_capture_events(hass, DOMAIN)
@pytest.fixture

View File

@ -1,10 +1,6 @@
"""Configure and test MatrixBot."""
from homeassistant.components.matrix import (
DOMAIN as MATRIX_DOMAIN,
SERVICE_SEND_MESSAGE,
MatrixBot,
)
from homeassistant.components.matrix import DOMAIN, SERVICE_SEND_MESSAGE, MatrixBot
from homeassistant.components.notify import DOMAIN as NOTIFY_DOMAIN
from homeassistant.core import HomeAssistant
@ -17,7 +13,7 @@ async def test_services(hass: HomeAssistant, matrix_bot: MatrixBot) -> None:
services = hass.services.async_services()
# Verify that the matrix service is registered
assert (matrix_service := services.get(MATRIX_DOMAIN))
assert (matrix_service := services.get(DOMAIN))
assert SERVICE_SEND_MESSAGE in matrix_service
# Verify that the matrix notifier is registered

View File

@ -3,7 +3,7 @@
import pytest
from homeassistant.components.matrix import MatrixBot
from homeassistant.components.matrix.const import DOMAIN as MATRIX_DOMAIN
from homeassistant.components.matrix.const import DOMAIN
from homeassistant.components.notify import DOMAIN as NOTIFY_DOMAIN
from homeassistant.const import EVENT_HOMEASSISTANT_START
from homeassistant.core import HomeAssistant
@ -20,14 +20,14 @@ async def test_join(
mock_allowed_path,
) -> None:
"""Test joining configured rooms."""
assert await async_setup_component(hass, MATRIX_DOMAIN, MOCK_CONFIG_DATA)
assert await async_setup_component(hass, DOMAIN, MOCK_CONFIG_DATA)
assert await async_setup_component(hass, NOTIFY_DOMAIN, MOCK_CONFIG_DATA)
hass.bus.async_fire(EVENT_HOMEASSISTANT_START)
await hass.async_block_till_done(wait_background_tasks=True)
# Accessing hass.data in tests is not desirable, but all the tests here
# currently do this.
matrix_bot = hass.data[MATRIX_DOMAIN]
matrix_bot = hass.data[DOMAIN]
for room_id in TEST_JOINABLE_ROOMS:
assert f"Joined or already in room '{room_id}'" in caplog.messages

View File

@ -2,12 +2,7 @@
import pytest
from homeassistant.components.matrix import (
ATTR_FORMAT,
ATTR_IMAGES,
DOMAIN as MATRIX_DOMAIN,
MatrixBot,
)
from homeassistant.components.matrix import ATTR_FORMAT, ATTR_IMAGES, DOMAIN, MatrixBot
from homeassistant.components.matrix.const import FORMAT_HTML, SERVICE_SEND_MESSAGE
from homeassistant.components.notify import ATTR_DATA, ATTR_MESSAGE, ATTR_TARGET
from homeassistant.core import Event, HomeAssistant
@ -30,9 +25,7 @@ async def test_send_message(
# Send a message without an attached image.
data = {ATTR_MESSAGE: "Test message", ATTR_TARGET: list(TEST_JOINABLE_ROOMS)}
await hass.services.async_call(
MATRIX_DOMAIN, SERVICE_SEND_MESSAGE, data, blocking=True
)
await hass.services.async_call(DOMAIN, SERVICE_SEND_MESSAGE, data, blocking=True)
for room_alias_or_id in TEST_JOINABLE_ROOMS:
assert f"Message delivered to room '{room_alias_or_id}'" in caplog.messages
@ -43,18 +36,14 @@ async def test_send_message(
ATTR_TARGET: list(TEST_JOINABLE_ROOMS),
ATTR_DATA: {ATTR_FORMAT: FORMAT_HTML},
}
await hass.services.async_call(
MATRIX_DOMAIN, SERVICE_SEND_MESSAGE, data, blocking=True
)
await hass.services.async_call(DOMAIN, SERVICE_SEND_MESSAGE, data, blocking=True)
for room_alias_or_id in TEST_JOINABLE_ROOMS:
assert f"Message delivered to room '{room_alias_or_id}'" in caplog.messages
# Send a message with an attached image.
data[ATTR_DATA] = {ATTR_IMAGES: [image_path.name]}
await hass.services.async_call(
MATRIX_DOMAIN, SERVICE_SEND_MESSAGE, data, blocking=True
)
await hass.services.async_call(DOMAIN, SERVICE_SEND_MESSAGE, data, blocking=True)
for room_alias_or_id in TEST_JOINABLE_ROOMS:
assert f"Message delivered to room '{room_alias_or_id}'" in caplog.messages
@ -72,9 +61,7 @@ async def test_unsendable_message(
data = {ATTR_MESSAGE: "Test message", ATTR_TARGET: TEST_BAD_ROOM}
await hass.services.async_call(
MATRIX_DOMAIN, SERVICE_SEND_MESSAGE, data, blocking=True
)
await hass.services.async_call(DOMAIN, SERVICE_SEND_MESSAGE, data, blocking=True)
assert (
f"Unable to deliver message to room '{TEST_BAD_ROOM}': ErrorResponse: Cannot send a message in this room."

View File

@ -6,7 +6,7 @@ from freezegun.api import FrozenDateTimeFactory
import pytest
from homeassistant.components import device_tracker, mqtt
from homeassistant.components.mqtt.const import DOMAIN as MQTT_DOMAIN
from homeassistant.components.mqtt.const import DOMAIN
from homeassistant.const import STATE_HOME, STATE_NOT_HOME, STATE_UNKNOWN
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr, entity_registry as er
@ -275,7 +275,7 @@ async def test_cleanup_device_tracker(
assert state is not None
# Remove MQTT from the device
mqtt_config_entry = hass.config_entries.async_entries(MQTT_DOMAIN)[0]
mqtt_config_entry = hass.config_entries.async_entries(DOMAIN)[0]
response = await ws_client.remove_device(
device_entry.id, mqtt_config_entry.entry_id
)

View File

@ -8,7 +8,7 @@ from unittest.mock import ANY, AsyncMock
import pytest
from homeassistant.components.device_automation import DeviceAutomationType
from homeassistant.components.mqtt.const import DOMAIN as MQTT_DOMAIN
from homeassistant.components.mqtt.const import DOMAIN
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr
from homeassistant.setup import async_setup_component
@ -403,7 +403,7 @@ async def test_not_fires_on_mqtt_message_after_remove_from_registry(
tag_mock.assert_called_once_with(ANY, DEFAULT_TAG_ID, device_entry.id)
# Remove MQTT from the device
mqtt_config_entry = hass.config_entries.async_entries(MQTT_DOMAIN)[0]
mqtt_config_entry = hass.config_entries.async_entries(DOMAIN)[0]
response = await ws_client.remove_device(
device_entry.id, mqtt_config_entry.entry_id
)
@ -590,7 +590,7 @@ async def test_cleanup_tag(
mqtt_mock.async_publish.assert_not_called()
# Remove MQTT from the device
mqtt_config_entry = hass.config_entries.async_entries(MQTT_DOMAIN)[0]
mqtt_config_entry = hass.config_entries.async_entries(DOMAIN)[0]
response = await ws_client.remove_device(
device_entry1.id, mqtt_config_entry.entry_id
)

View File

@ -15,7 +15,7 @@ from homeassistant.components.music_assistant.const import (
ATTR_FAVORITE,
ATTR_MEDIA_TYPE,
ATTR_SEARCH_NAME,
DOMAIN as MASS_DOMAIN,
DOMAIN,
)
from homeassistant.core import HomeAssistant
@ -36,7 +36,7 @@ async def test_search_action(
)
)
response = await hass.services.async_call(
MASS_DOMAIN,
DOMAIN,
SERVICE_SEARCH,
{
ATTR_CONFIG_ENTRY_ID: entry.entry_id,
@ -69,7 +69,7 @@ async def test_get_library_action(
"""Test music assistant get_library action."""
entry = await setup_integration_from_fixtures(hass, music_assistant_client)
response = await hass.services.async_call(
MASS_DOMAIN,
DOMAIN,
SERVICE_GET_LIBRARY,
{
ATTR_CONFIG_ENTRY_ID: entry.entry_id,

View File

@ -30,7 +30,7 @@ from homeassistant.components.media_player import (
SERVICE_UNJOIN,
MediaPlayerEntityFeature,
)
from homeassistant.components.music_assistant.const import DOMAIN as MASS_DOMAIN
from homeassistant.components.music_assistant.const import DOMAIN
from homeassistant.components.music_assistant.media_player import (
ATTR_ALBUM,
ATTR_ANNOUNCE_VOLUME,
@ -389,7 +389,7 @@ async def test_media_player_play_media_action(
# test simple play_media call with URI as media_id and no media type
await hass.services.async_call(
MASS_DOMAIN,
DOMAIN,
SERVICE_PLAY_MEDIA_ADVANCED,
{
ATTR_ENTITY_ID: entity_id,
@ -410,7 +410,7 @@ async def test_media_player_play_media_action(
# test simple play_media call with URI and enqueue specified
music_assistant_client.send_command.reset_mock()
await hass.services.async_call(
MASS_DOMAIN,
DOMAIN,
SERVICE_PLAY_MEDIA_ADVANCED,
{
ATTR_ENTITY_ID: entity_id,
@ -432,7 +432,7 @@ async def test_media_player_play_media_action(
# test basic play_media call with URL and radio mode specified
music_assistant_client.send_command.reset_mock()
await hass.services.async_call(
MASS_DOMAIN,
DOMAIN,
SERVICE_PLAY_MEDIA_ADVANCED,
{
ATTR_ENTITY_ID: entity_id,
@ -455,7 +455,7 @@ async def test_media_player_play_media_action(
music_assistant_client.send_command.reset_mock()
music_assistant_client.music.get_item = AsyncMock(return_value=MOCK_TRACK)
await hass.services.async_call(
MASS_DOMAIN,
DOMAIN,
SERVICE_PLAY_MEDIA_ADVANCED,
{
ATTR_ENTITY_ID: entity_id,
@ -482,7 +482,7 @@ async def test_media_player_play_media_action(
music_assistant_client.send_command.reset_mock()
music_assistant_client.music.get_item_by_name = AsyncMock(return_value=MOCK_TRACK)
await hass.services.async_call(
MASS_DOMAIN,
DOMAIN,
SERVICE_PLAY_MEDIA_ADVANCED,
{
ATTR_ENTITY_ID: entity_id,
@ -521,7 +521,7 @@ async def test_media_player_play_announcement_action(
state = hass.states.get(entity_id)
assert state
await hass.services.async_call(
MASS_DOMAIN,
DOMAIN,
SERVICE_PLAY_ANNOUNCEMENT,
{
ATTR_ENTITY_ID: entity_id,
@ -551,7 +551,7 @@ async def test_media_player_transfer_queue_action(
state = hass.states.get(entity_id)
assert state
await hass.services.async_call(
MASS_DOMAIN,
DOMAIN,
SERVICE_TRANSFER_QUEUE,
{
ATTR_ENTITY_ID: entity_id,
@ -572,7 +572,7 @@ async def test_media_player_transfer_queue_action(
music_assistant_client.send_command.reset_mock()
with pytest.raises(HomeAssistantError, match="Source player not available."):
await hass.services.async_call(
MASS_DOMAIN,
DOMAIN,
SERVICE_TRANSFER_QUEUE,
{
ATTR_ENTITY_ID: entity_id,
@ -583,7 +583,7 @@ async def test_media_player_transfer_queue_action(
# test again with no source player specified (which picks first playing playerqueue)
music_assistant_client.send_command.reset_mock()
await hass.services.async_call(
MASS_DOMAIN,
DOMAIN,
SERVICE_TRANSFER_QUEUE,
{
ATTR_ENTITY_ID: entity_id,
@ -609,7 +609,7 @@ async def test_media_player_get_queue_action(
await setup_integration_from_fixtures(hass, music_assistant_client)
entity_id = "media_player.test_group_player_1"
response = await hass.services.async_call(
MASS_DOMAIN,
DOMAIN,
SERVICE_GET_QUEUE,
{
ATTR_ENTITY_ID: entity_id,

View File

@ -26,7 +26,7 @@ from homeassistant.components.netatmo.const import (
ATTR_SCHEDULE_NAME,
ATTR_TARGET_TEMPERATURE,
ATTR_TIME_PERIOD,
DOMAIN as NETATMO_DOMAIN,
DOMAIN,
SERVICE_CLEAR_TEMPERATURE_SETTING,
SERVICE_SET_PRESET_MODE_WITH_END_DATETIME,
SERVICE_SET_SCHEDULE,
@ -437,7 +437,7 @@ async def test_service_set_temperature_with_end_datetime(
# Test service setting the temperature without an end datetime
await hass.services.async_call(
NETATMO_DOMAIN,
DOMAIN,
SERVICE_SET_TEMPERATURE_WITH_END_DATETIME,
{
ATTR_ENTITY_ID: climate_entity_livingroom,
@ -495,7 +495,7 @@ async def test_service_set_temperature_with_time_period(
# Test service setting the temperature without an end datetime
await hass.services.async_call(
NETATMO_DOMAIN,
DOMAIN,
SERVICE_SET_TEMPERATURE_WITH_TIME_PERIOD,
{
ATTR_ENTITY_ID: climate_entity_livingroom,
@ -583,7 +583,7 @@ async def test_service_clear_temperature_setting(
# Test service setting the temperature without an end datetime
await hass.services.async_call(
NETATMO_DOMAIN,
DOMAIN,
SERVICE_CLEAR_TEMPERATURE_SETTING,
{ATTR_ENTITY_ID: climate_entity_livingroom},
blocking=True,

View File

@ -5,7 +5,7 @@ from pytest_unordered import unordered
from homeassistant.components import automation
from homeassistant.components.device_automation import DeviceAutomationType
from homeassistant.components.netatmo import DOMAIN as NETATMO_DOMAIN
from homeassistant.components.netatmo import DOMAIN
from homeassistant.components.netatmo.const import (
CLIMATE_TRIGGERS,
INDOOR_CAMERA_TRIGGERS,
@ -43,7 +43,7 @@ async def test_get_triggers(
event_types,
) -> None:
"""Test we get the expected triggers from a netatmo devices."""
config_entry = MockConfigEntry(domain=NETATMO_DOMAIN, data={})
config_entry = MockConfigEntry(domain=DOMAIN, data={})
config_entry.add_to_hass(hass)
device_entry = device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id,
@ -51,7 +51,7 @@ async def test_get_triggers(
model=device_type,
)
entity_entry = entity_registry.async_get_or_create(
platform, NETATMO_DOMAIN, "5678", device_id=device_entry.id
platform, DOMAIN, "5678", device_id=device_entry.id
)
expected_triggers = []
for event_type in event_types:
@ -59,7 +59,7 @@ async def test_get_triggers(
expected_triggers.extend(
{
"platform": "device",
"domain": NETATMO_DOMAIN,
"domain": DOMAIN,
"type": event_type,
"subtype": subtype,
"device_id": device_entry.id,
@ -72,7 +72,7 @@ async def test_get_triggers(
expected_triggers.append(
{
"platform": "device",
"domain": NETATMO_DOMAIN,
"domain": DOMAIN,
"type": event_type,
"device_id": device_entry.id,
"entity_id": entity_entry.id,
@ -84,7 +84,7 @@ async def test_get_triggers(
for trigger in await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id
)
if trigger["domain"] == NETATMO_DOMAIN
if trigger["domain"] == DOMAIN
]
assert triggers == unordered(expected_triggers)
@ -116,16 +116,16 @@ async def test_if_fires_on_event(
"""Test for event triggers firing."""
mac_address = "12:34:56:AB:CD:EF"
connection = (dr.CONNECTION_NETWORK_MAC, mac_address)
config_entry = MockConfigEntry(domain=NETATMO_DOMAIN, data={})
config_entry = MockConfigEntry(domain=DOMAIN, data={})
config_entry.add_to_hass(hass)
device_entry = device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id,
connections={connection},
identifiers={(NETATMO_DOMAIN, mac_address)},
identifiers={(DOMAIN, mac_address)},
model=camera_type,
)
entity_entry = entity_registry.async_get_or_create(
platform, NETATMO_DOMAIN, "5678", device_id=device_entry.id
platform, DOMAIN, "5678", device_id=device_entry.id
)
events = async_capture_events(hass, "netatmo_event")
@ -137,7 +137,7 @@ async def test_if_fires_on_event(
{
"trigger": {
"platform": "device",
"domain": NETATMO_DOMAIN,
"domain": DOMAIN,
"device_id": device_entry.id,
"entity_id": entity_entry.id,
"type": event_type,
@ -199,16 +199,16 @@ async def test_if_fires_on_event_legacy(
"""Test for event triggers firing."""
mac_address = "12:34:56:AB:CD:EF"
connection = (dr.CONNECTION_NETWORK_MAC, mac_address)
config_entry = MockConfigEntry(domain=NETATMO_DOMAIN, data={})
config_entry = MockConfigEntry(domain=DOMAIN, data={})
config_entry.add_to_hass(hass)
device_entry = device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id,
connections={connection},
identifiers={(NETATMO_DOMAIN, mac_address)},
identifiers={(DOMAIN, mac_address)},
model=camera_type,
)
entity_entry = entity_registry.async_get_or_create(
platform, NETATMO_DOMAIN, "5678", device_id=device_entry.id
platform, DOMAIN, "5678", device_id=device_entry.id
)
events = async_capture_events(hass, "netatmo_event")
@ -220,7 +220,7 @@ async def test_if_fires_on_event_legacy(
{
"trigger": {
"platform": "device",
"domain": NETATMO_DOMAIN,
"domain": DOMAIN,
"device_id": device_entry.id,
"entity_id": entity_entry.entity_id,
"type": event_type,
@ -279,16 +279,16 @@ async def test_if_fires_on_event_with_subtype(
"""Test for event triggers firing."""
mac_address = "12:34:56:AB:CD:EF"
connection = (dr.CONNECTION_NETWORK_MAC, mac_address)
config_entry = MockConfigEntry(domain=NETATMO_DOMAIN, data={})
config_entry = MockConfigEntry(domain=DOMAIN, data={})
config_entry.add_to_hass(hass)
device_entry = device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id,
connections={connection},
identifiers={(NETATMO_DOMAIN, mac_address)},
identifiers={(DOMAIN, mac_address)},
model=camera_type,
)
entity_entry = entity_registry.async_get_or_create(
platform, NETATMO_DOMAIN, "5678", device_id=device_entry.id
platform, DOMAIN, "5678", device_id=device_entry.id
)
events = async_capture_events(hass, "netatmo_event")
@ -300,7 +300,7 @@ async def test_if_fires_on_event_with_subtype(
{
"trigger": {
"platform": "device",
"domain": NETATMO_DOMAIN,
"domain": DOMAIN,
"device_id": device_entry.id,
"entity_id": entity_entry.id,
"type": event_type,
@ -358,16 +358,16 @@ async def test_if_invalid_device(
"""Test for event triggers firing."""
mac_address = "12:34:56:AB:CD:EF"
connection = (dr.CONNECTION_NETWORK_MAC, mac_address)
config_entry = MockConfigEntry(domain=NETATMO_DOMAIN, data={})
config_entry = MockConfigEntry(domain=DOMAIN, data={})
config_entry.add_to_hass(hass)
device_entry = device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id,
connections={connection},
identifiers={(NETATMO_DOMAIN, mac_address)},
identifiers={(DOMAIN, mac_address)},
model=device_type,
)
entity_entry = entity_registry.async_get_or_create(
platform, NETATMO_DOMAIN, "5678", device_id=device_entry.id
platform, DOMAIN, "5678", device_id=device_entry.id
)
assert await async_setup_component(
@ -378,7 +378,7 @@ async def test_if_invalid_device(
{
"trigger": {
"platform": "device",
"domain": NETATMO_DOMAIN,
"domain": DOMAIN,
"device_id": device_entry.id,
"entity_id": entity_entry.id,
"type": event_type,

View File

@ -4,10 +4,7 @@ from unittest.mock import AsyncMock
import pytest
from homeassistant.components.notify import (
DOMAIN as NOTIFY_DOMAIN,
migrate_notify_issue,
)
from homeassistant.components.notify import DOMAIN, migrate_notify_issue
from homeassistant.core import HomeAssistant
from homeassistant.helpers import issue_registry as ir
from homeassistant.setup import async_setup_component
@ -36,7 +33,7 @@ async def test_notify_migration_repair_flow(
translation_key: str,
) -> None:
"""Test the notify service repair flow is triggered."""
await async_setup_component(hass, NOTIFY_DOMAIN, {})
await async_setup_component(hass, DOMAIN, {})
await hass.async_block_till_done()
await async_process_repairs_platforms(hass)
@ -58,12 +55,12 @@ async def test_notify_migration_repair_flow(
await hass.async_block_till_done()
# Assert the issue is present
assert issue_registry.async_get_issue(
domain=NOTIFY_DOMAIN,
domain=DOMAIN,
issue_id=translation_key,
)
assert len(issue_registry.issues) == 1
data = await start_repair_fix_flow(http_client, NOTIFY_DOMAIN, translation_key)
data = await start_repair_fix_flow(http_client, DOMAIN, translation_key)
flow_id = data["flow_id"]
assert data["step_id"] == "confirm"
@ -75,7 +72,7 @@ async def test_notify_migration_repair_flow(
# Assert the issue is no longer present
assert not issue_registry.async_get_issue(
domain=NOTIFY_DOMAIN,
domain=DOMAIN,
issue_id=translation_key,
)
assert len(issue_registry.issues) == 0

View File

@ -5,7 +5,7 @@ from unittest.mock import AsyncMock, MagicMock
from pyotgw.vars import OTGW_MODE_RESET
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, SERVICE_PRESS
from homeassistant.components.opentherm_gw import DOMAIN as OPENTHERM_DOMAIN
from homeassistant.components.opentherm_gw import DOMAIN
from homeassistant.components.opentherm_gw.const import OpenThermDeviceIdentifier
from homeassistant.const import ATTR_ENTITY_ID, CONF_ID
from homeassistant.core import HomeAssistant
@ -33,7 +33,7 @@ async def test_cancel_room_setpoint_override_button(
assert (
button_entity_id := entity_registry.async_get_entity_id(
BUTTON_DOMAIN,
OPENTHERM_DOMAIN,
DOMAIN,
f"{mock_config_entry.data[CONF_ID]}-{OpenThermDeviceIdentifier.THERMOSTAT}-cancel_room_setpoint_override",
)
) is not None
@ -67,7 +67,7 @@ async def test_restart_button(
assert (
button_entity_id := entity_registry.async_get_entity_id(
BUTTON_DOMAIN,
OPENTHERM_DOMAIN,
DOMAIN,
f"{mock_config_entry.data[CONF_ID]}-{OpenThermDeviceIdentifier.GATEWAY}-restart_button",
)
) is not None

View File

@ -15,7 +15,7 @@ from pyotgw.vars import (
)
import pytest
from homeassistant.components.opentherm_gw import DOMAIN as OPENTHERM_DOMAIN
from homeassistant.components.opentherm_gw import DOMAIN
from homeassistant.components.opentherm_gw.const import (
DATA_GATEWAYS,
DATA_OPENTHERM_GW,
@ -133,7 +133,7 @@ async def test_select_change_value(
assert (
select_entity_id := entity_registry.async_get_entity_id(
SELECT_DOMAIN,
OPENTHERM_DOMAIN,
DOMAIN,
f"{mock_config_entry.data[CONF_ID]}-{OpenThermDeviceIdentifier.GATEWAY}-{entity_key}",
)
) is not None
@ -203,7 +203,7 @@ async def test_select_state_update(
assert (
select_entity_id := entity_registry.async_get_entity_id(
SELECT_DOMAIN,
OPENTHERM_DOMAIN,
DOMAIN,
f"{mock_config_entry.data[CONF_ID]}-{OpenThermDeviceIdentifier.GATEWAY}-{entity_key}",
)
) is not None

View File

@ -4,7 +4,7 @@ from unittest.mock import AsyncMock, MagicMock, call
import pytest
from homeassistant.components.opentherm_gw import DOMAIN as OPENTHERM_DOMAIN
from homeassistant.components.opentherm_gw import DOMAIN
from homeassistant.components.opentherm_gw.const import OpenThermDeviceIdentifier
from homeassistant.components.switch import (
DOMAIN as SWITCH_DOMAIN,
@ -44,7 +44,7 @@ async def test_switch_added_disabled(
assert (
switch_entity_id := entity_registry.async_get_entity_id(
SWITCH_DOMAIN,
OPENTHERM_DOMAIN,
DOMAIN,
f"{mock_config_entry.data[CONF_ID]}-{OpenThermDeviceIdentifier.GATEWAY}-{entity_key}",
)
) is not None
@ -80,7 +80,7 @@ async def test_ch_override_switch(
assert (
switch_entity_id := entity_registry.async_get_entity_id(
SWITCH_DOMAIN,
OPENTHERM_DOMAIN,
DOMAIN,
f"{mock_config_entry.data[CONF_ID]}-{OpenThermDeviceIdentifier.GATEWAY}-{entity_key}",
)
) is not None

View File

@ -1,7 +1,7 @@
"""Pandora media player tests."""
from homeassistant.components.media_player import DOMAIN as PLATFORM_DOMAIN
from homeassistant.components.pandora import DOMAIN as PANDORA_DOMAIN
from homeassistant.components.pandora import DOMAIN
from homeassistant.const import CONF_PLATFORM
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
from homeassistant.helpers import issue_registry as ir
@ -19,7 +19,7 @@ async def test_repair_issue_is_created(
{
PLATFORM_DOMAIN: [
{
CONF_PLATFORM: PANDORA_DOMAIN,
CONF_PLATFORM: DOMAIN,
}
],
},
@ -27,5 +27,5 @@ async def test_repair_issue_is_created(
await hass.async_block_till_done()
assert (
HOMEASSISTANT_DOMAIN,
f"deprecated_system_packages_yaml_integration_{PANDORA_DOMAIN}",
f"deprecated_system_packages_yaml_integration_{DOMAIN}",
) in issue_registry.issues

View File

@ -5,7 +5,7 @@ from unittest.mock import AsyncMock, MagicMock, patch
from pyprosegur.installation import Camera
import pytest
from homeassistant.components.prosegur import DOMAIN as PROSEGUR_DOMAIN
from homeassistant.components.prosegur import DOMAIN
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant
@ -18,7 +18,7 @@ CONTRACT = "1234abcd"
def mock_config_entry() -> MockConfigEntry:
"""Return the default mocked config entry."""
return MockConfigEntry(
domain=PROSEGUR_DOMAIN,
domain=DOMAIN,
data={
"contract": CONTRACT,
CONF_USERNAME: "user@email.com",

View File

@ -8,7 +8,7 @@ from aiohttp.client_exceptions import ClientError
import pytest
from yarl import URL
from homeassistant.components.qwikswitch import DOMAIN as QWIKSWITCH
from homeassistant.components.qwikswitch import DOMAIN
from homeassistant.const import STATE_UNKNOWN
from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component
@ -66,7 +66,7 @@ async def test_binary_sensor_device(
aioclient_mock.get("http://127.0.0.1:2020/&device", json=qs_devices)
listen_mock = MockLongPollSideEffect()
aioclient_mock.get("http://127.0.0.1:2020/&listen", side_effect=listen_mock)
assert await async_setup_component(hass, QWIKSWITCH, config)
assert await async_setup_component(hass, DOMAIN, config)
await hass.async_start()
await hass.async_block_till_done()
@ -112,7 +112,7 @@ async def test_sensor_device(
aioclient_mock.get("http://127.0.0.1:2020/&device", json=qs_devices)
listen_mock = MockLongPollSideEffect()
aioclient_mock.get("http://127.0.0.1:2020/&listen", side_effect=listen_mock)
assert await async_setup_component(hass, QWIKSWITCH, config)
assert await async_setup_component(hass, DOMAIN, config)
await hass.async_start()
await hass.async_block_till_done()
@ -143,7 +143,7 @@ async def test_switch_device(
aioclient_mock.get("http://127.0.0.1:2020/&device", side_effect=get_devices_json)
listen_mock = MockLongPollSideEffect()
aioclient_mock.get("http://127.0.0.1:2020/&listen", side_effect=listen_mock)
assert await async_setup_component(hass, QWIKSWITCH, config)
assert await async_setup_component(hass, DOMAIN, config)
await hass.async_start()
await hass.async_block_till_done()
@ -207,7 +207,7 @@ async def test_light_device(
aioclient_mock.get("http://127.0.0.1:2020/&device", side_effect=get_devices_json)
listen_mock = MockLongPollSideEffect()
aioclient_mock.get("http://127.0.0.1:2020/&listen", side_effect=listen_mock)
assert await async_setup_component(hass, QWIKSWITCH, config)
assert await async_setup_component(hass, DOMAIN, config)
await hass.async_start()
await hass.async_block_till_done()
@ -281,7 +281,7 @@ async def test_button(
aioclient_mock.get("http://127.0.0.1:2020/&device", side_effect=get_devices_json)
listen_mock = MockLongPollSideEffect()
aioclient_mock.get("http://127.0.0.1:2020/&listen", side_effect=listen_mock)
assert await async_setup_component(hass, QWIKSWITCH, config)
assert await async_setup_component(hass, DOMAIN, config)
await hass.async_start()
await hass.async_block_till_done()
@ -306,7 +306,7 @@ async def test_failed_update_devices(
aioclient_mock.get("http://127.0.0.1:2020/&device", exc=ClientError())
listen_mock = MockLongPollSideEffect()
aioclient_mock.get("http://127.0.0.1:2020/&listen", side_effect=listen_mock)
assert not await async_setup_component(hass, QWIKSWITCH, config)
assert not await async_setup_component(hass, DOMAIN, config)
await hass.async_start()
await hass.async_block_till_done()
listen_mock.stop()
@ -329,7 +329,7 @@ async def test_single_invalid_sensor(
aioclient_mock.get("http://127.0.0.1:2020/&device", json=qs_devices)
listen_mock = MockLongPollSideEffect()
aioclient_mock.get("http://127.0.0.1:2020/&listen", side_effect=listen_mock)
assert await async_setup_component(hass, QWIKSWITCH, config)
assert await async_setup_component(hass, DOMAIN, config)
await hass.async_start()
await hass.async_block_till_done()
await asyncio.sleep(0.01)
@ -363,7 +363,7 @@ async def test_non_binary_sensor_with_binary_args(
aioclient_mock.get("http://127.0.0.1:2020/&device", json=qs_devices)
listen_mock = MockLongPollSideEffect()
aioclient_mock.get("http://127.0.0.1:2020/&listen", side_effect=listen_mock)
assert await async_setup_component(hass, QWIKSWITCH, config)
assert await async_setup_component(hass, DOMAIN, config)
await hass.async_start()
await hass.async_block_till_done()
await asyncio.sleep(0.01)
@ -385,7 +385,7 @@ async def test_non_relay_switch(
aioclient_mock.get("http://127.0.0.1:2020/&device", json=qs_devices)
listen_mock = MockLongPollSideEffect()
aioclient_mock.get("http://127.0.0.1:2020/&listen", side_effect=listen_mock)
assert await async_setup_component(hass, QWIKSWITCH, config)
assert await async_setup_component(hass, DOMAIN, config)
await hass.async_start()
await hass.async_block_till_done()
await asyncio.sleep(0.01)
@ -408,7 +408,7 @@ async def test_unknown_device(
aioclient_mock.get("http://127.0.0.1:2020/&device", json=qs_devices)
listen_mock = MockLongPollSideEffect()
aioclient_mock.get("http://127.0.0.1:2020/&listen", side_effect=listen_mock)
assert await async_setup_component(hass, QWIKSWITCH, config)
assert await async_setup_component(hass, DOMAIN, config)
await hass.async_start()
await hass.async_block_till_done()
await asyncio.sleep(0.01)

View File

@ -12,7 +12,7 @@ from sqlalchemy.exc import DatabaseError, OperationalError
from sqlalchemy.orm.session import Session
from voluptuous.error import MultipleInvalid
from homeassistant.components.recorder import DOMAIN as RECORDER_DOMAIN, Recorder
from homeassistant.components.recorder import DOMAIN, Recorder
from homeassistant.components.recorder.const import SupportedDialect
from homeassistant.components.recorder.db_schema import (
Events,
@ -248,7 +248,7 @@ async def test_purge_old_states_encouters_database_corruption(
side_effect=sqlite3_exception,
),
):
await hass.services.async_call(RECORDER_DOMAIN, SERVICE_PURGE, {"keep_days": 0})
await hass.services.async_call(DOMAIN, SERVICE_PURGE, {"keep_days": 0})
await hass.async_block_till_done()
await async_wait_recording_done(hass)
@ -280,7 +280,7 @@ async def test_purge_old_states_encounters_temporary_mysql_error(
),
patch.object(recorder_mock.engine.dialect, "name", "mysql"),
):
await hass.services.async_call(RECORDER_DOMAIN, SERVICE_PURGE, {"keep_days": 0})
await hass.services.async_call(DOMAIN, SERVICE_PURGE, {"keep_days": 0})
await hass.async_block_till_done()
await async_wait_recording_done(hass)
await async_wait_recording_done(hass)
@ -304,7 +304,7 @@ async def test_purge_old_states_encounters_operational_error(
"homeassistant.components.recorder.purge._purge_old_recorder_runs",
side_effect=exception,
):
await hass.services.async_call(RECORDER_DOMAIN, SERVICE_PURGE, {"keep_days": 0})
await hass.services.async_call(DOMAIN, SERVICE_PURGE, {"keep_days": 0})
await hass.async_block_till_done()
await async_wait_recording_done(hass)
await async_wait_recording_done(hass)
@ -606,7 +606,7 @@ async def test_purge_edge_case(
)
assert events.count() == 1
await hass.services.async_call(RECORDER_DOMAIN, SERVICE_PURGE, service_data)
await hass.services.async_call(DOMAIN, SERVICE_PURGE, service_data)
await hass.async_block_till_done()
await async_recorder_block_till_done(hass)
@ -897,7 +897,7 @@ async def test_purge_filtered_states(
assert events_keep.count() == 1
# Normal purge doesn't remove excluded entities
await hass.services.async_call(RECORDER_DOMAIN, SERVICE_PURGE, service_data)
await hass.services.async_call(DOMAIN, SERVICE_PURGE, service_data)
await hass.async_block_till_done()
await async_recorder_block_till_done(hass)
@ -913,7 +913,7 @@ async def test_purge_filtered_states(
# Test with 'apply_filter' = True
service_data["apply_filter"] = True
await hass.services.async_call(RECORDER_DOMAIN, SERVICE_PURGE, service_data)
await hass.services.async_call(DOMAIN, SERVICE_PURGE, service_data)
await hass.async_block_till_done()
await async_recorder_block_till_done(hass)
@ -961,7 +961,7 @@ async def test_purge_filtered_states(
assert session.query(StateAttributes).count() == 11
# Do it again to make sure nothing changes
await hass.services.async_call(RECORDER_DOMAIN, SERVICE_PURGE, service_data)
await hass.services.async_call(DOMAIN, SERVICE_PURGE, service_data)
await async_recorder_block_till_done(hass)
await async_wait_purge_done(hass)
@ -973,7 +973,7 @@ async def test_purge_filtered_states(
assert session.query(StateAttributes).count() == 11
service_data = {"keep_days": 0}
await hass.services.async_call(RECORDER_DOMAIN, SERVICE_PURGE, service_data)
await hass.services.async_call(DOMAIN, SERVICE_PURGE, service_data)
await async_recorder_block_till_done(hass)
await async_wait_purge_done(hass)
@ -1091,9 +1091,7 @@ async def test_purge_filtered_states_multiple_rounds(
)
assert events_keep.count() == 1
await hass.services.async_call(
RECORDER_DOMAIN, SERVICE_PURGE, service_data, blocking=True
)
await hass.services.async_call(DOMAIN, SERVICE_PURGE, service_data, blocking=True)
for _ in range(2):
# Make sure the second round of purging runs
@ -1131,7 +1129,7 @@ async def test_purge_filtered_states_multiple_rounds(
assert session.query(StateAttributes).count() == 11
# Do it again to make sure nothing changes
await hass.services.async_call(RECORDER_DOMAIN, SERVICE_PURGE, service_data)
await hass.services.async_call(DOMAIN, SERVICE_PURGE, service_data)
await async_recorder_block_till_done(hass)
await async_wait_purge_done(hass)
@ -1188,7 +1186,7 @@ async def test_purge_filtered_states_to_empty(
# Test with 'apply_filter' = True
service_data["apply_filter"] = True
await hass.services.async_call(RECORDER_DOMAIN, SERVICE_PURGE, service_data)
await hass.services.async_call(DOMAIN, SERVICE_PURGE, service_data)
await async_recorder_block_till_done(hass)
await async_wait_purge_done(hass)
@ -1200,7 +1198,7 @@ async def test_purge_filtered_states_to_empty(
# Do it again to make sure nothing changes
# Why do we do this? Should we check the end result?
await hass.services.async_call(RECORDER_DOMAIN, SERVICE_PURGE, service_data)
await hass.services.async_call(DOMAIN, SERVICE_PURGE, service_data)
await async_recorder_block_till_done(hass)
await async_wait_purge_done(hass)
@ -1266,7 +1264,7 @@ async def test_purge_without_state_attributes_filtered_states_to_empty(
# Test with 'apply_filter' = True
service_data["apply_filter"] = True
await hass.services.async_call(RECORDER_DOMAIN, SERVICE_PURGE, service_data)
await hass.services.async_call(DOMAIN, SERVICE_PURGE, service_data)
await async_recorder_block_till_done(hass)
await async_wait_purge_done(hass)
@ -1278,7 +1276,7 @@ async def test_purge_without_state_attributes_filtered_states_to_empty(
# Do it again to make sure nothing changes
# Why do we do this? Should we check the end result?
await hass.services.async_call(RECORDER_DOMAIN, SERVICE_PURGE, service_data)
await hass.services.async_call(DOMAIN, SERVICE_PURGE, service_data)
await async_recorder_block_till_done(hass)
await async_wait_purge_done(hass)
@ -1334,7 +1332,7 @@ async def test_purge_filtered_events(
assert states.count() == 10
# Normal purge doesn't remove excluded events
await hass.services.async_call(RECORDER_DOMAIN, SERVICE_PURGE, service_data)
await hass.services.async_call(DOMAIN, SERVICE_PURGE, service_data)
await hass.async_block_till_done()
await async_recorder_block_till_done(hass)
@ -1350,7 +1348,7 @@ async def test_purge_filtered_events(
# Test with 'apply_filter' = True
service_data["apply_filter"] = True
await hass.services.async_call(RECORDER_DOMAIN, SERVICE_PURGE, service_data)
await hass.services.async_call(DOMAIN, SERVICE_PURGE, service_data)
await hass.async_block_till_done()
await async_recorder_block_till_done(hass)
@ -1479,7 +1477,7 @@ async def test_purge_filtered_events_state_changed(
assert events_purge.count() == 1
assert states.count() == 64
await hass.services.async_call(RECORDER_DOMAIN, SERVICE_PURGE, service_data)
await hass.services.async_call(DOMAIN, SERVICE_PURGE, service_data)
await hass.async_block_till_done()
for _ in range(4):
@ -1525,9 +1523,7 @@ async def test_purge_entities(hass: HomeAssistant, recorder_mock: Recorder) -> N
"entity_globs": entity_globs,
}
await hass.services.async_call(
RECORDER_DOMAIN, SERVICE_PURGE_ENTITIES, service_data
)
await hass.services.async_call(DOMAIN, SERVICE_PURGE_ENTITIES, service_data)
await hass.async_block_till_done()
await async_recorder_block_till_done(hass)
@ -2210,7 +2206,7 @@ async def test_purge_entities_keep_days(
assert len(states["sensor.purge"]) == 3
await hass.services.async_call(
RECORDER_DOMAIN,
DOMAIN,
SERVICE_PURGE_ENTITIES,
{
"entity_id": "sensor.purge",
@ -2231,7 +2227,7 @@ async def test_purge_entities_keep_days(
assert len(states["sensor.purge"]) == 1
await hass.services.async_call(
RECORDER_DOMAIN,
DOMAIN,
SERVICE_PURGE_ENTITIES,
{
"entity_id": "sensor.purge",

View File

@ -12,11 +12,7 @@ from sqlalchemy import text, update
from sqlalchemy.exc import DatabaseError, OperationalError
from sqlalchemy.orm.session import Session
from homeassistant.components.recorder import (
DOMAIN as RECORDER_DOMAIN,
Recorder,
migration,
)
from homeassistant.components.recorder import DOMAIN, Recorder, migration
from homeassistant.components.recorder.const import SupportedDialect
from homeassistant.components.recorder.history import get_significant_states
from homeassistant.components.recorder.purge import purge_old_data
@ -201,7 +197,7 @@ async def test_purge_old_states_encouters_database_corruption(
side_effect=sqlite3_exception,
),
):
await hass.services.async_call(RECORDER_DOMAIN, SERVICE_PURGE, {"keep_days": 0})
await hass.services.async_call(DOMAIN, SERVICE_PURGE, {"keep_days": 0})
await hass.async_block_till_done()
await async_wait_recording_done(hass)
@ -235,7 +231,7 @@ async def test_purge_old_states_encounters_temporary_mysql_error(
),
patch.object(recorder_mock.engine.dialect, "name", "mysql"),
):
await hass.services.async_call(RECORDER_DOMAIN, SERVICE_PURGE, {"keep_days": 0})
await hass.services.async_call(DOMAIN, SERVICE_PURGE, {"keep_days": 0})
await hass.async_block_till_done()
await async_wait_recording_done(hass)
await async_wait_recording_done(hass)
@ -261,7 +257,7 @@ async def test_purge_old_states_encounters_operational_error(
"homeassistant.components.recorder.purge._purge_old_recorder_runs",
side_effect=exception,
):
await hass.services.async_call(RECORDER_DOMAIN, SERVICE_PURGE, {"keep_days": 0})
await hass.services.async_call(DOMAIN, SERVICE_PURGE, {"keep_days": 0})
await hass.async_block_till_done()
await async_wait_recording_done(hass)
await async_wait_recording_done(hass)
@ -549,7 +545,7 @@ async def test_purge_edge_case(hass: HomeAssistant, use_sqlite: bool) -> None:
events = session.query(Events).filter(Events.event_type == "EVENT_TEST_PURGE")
assert events.count() == 1
await hass.services.async_call(RECORDER_DOMAIN, SERVICE_PURGE, service_data)
await hass.services.async_call(DOMAIN, SERVICE_PURGE, service_data)
await hass.async_block_till_done()
await async_recorder_block_till_done(hass)
@ -1378,7 +1374,7 @@ async def test_purge_entities_keep_days(
assert len(states["sensor.purge"]) == 3
await hass.services.async_call(
RECORDER_DOMAIN,
DOMAIN,
SERVICE_PURGE_ENTITIES,
{
"entity_id": "sensor.purge",
@ -1399,7 +1395,7 @@ async def test_purge_entities_keep_days(
assert len(states["sensor.purge"]) == 1
await hass.services.async_call(
RECORDER_DOMAIN,
DOMAIN,
SERVICE_PURGE_ENTITIES,
{
"entity_id": "sensor.purge",

View File

@ -6,7 +6,7 @@ import pytest
from reolink_aio.api import Chime
from reolink_aio.exceptions import InvalidParameterError, ReolinkError
from homeassistant.components.reolink.const import DOMAIN as REOLINK_DOMAIN
from homeassistant.components.reolink.const import DOMAIN
from homeassistant.components.reolink.services import ATTR_RINGTONE
from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import ATTR_DEVICE_ID, Platform
@ -39,7 +39,7 @@ async def test_play_chime_service_entity(
# Test chime play service with device
test_chime.play = AsyncMock()
await hass.services.async_call(
REOLINK_DOMAIN,
DOMAIN,
"play_chime",
{ATTR_DEVICE_ID: [device_id], ATTR_RINGTONE: "attraction"},
blocking=True,
@ -49,7 +49,7 @@ async def test_play_chime_service_entity(
# Test errors
with pytest.raises(ServiceValidationError):
await hass.services.async_call(
REOLINK_DOMAIN,
DOMAIN,
"play_chime",
{ATTR_DEVICE_ID: ["invalid_id"], ATTR_RINGTONE: "attraction"},
blocking=True,
@ -58,7 +58,7 @@ async def test_play_chime_service_entity(
test_chime.play = AsyncMock(side_effect=ReolinkError("Test error"))
with pytest.raises(HomeAssistantError):
await hass.services.async_call(
REOLINK_DOMAIN,
DOMAIN,
"play_chime",
{ATTR_DEVICE_ID: [device_id], ATTR_RINGTONE: "attraction"},
blocking=True,
@ -67,7 +67,7 @@ async def test_play_chime_service_entity(
test_chime.play = AsyncMock(side_effect=InvalidParameterError("Test error"))
with pytest.raises(ServiceValidationError):
await hass.services.async_call(
REOLINK_DOMAIN,
DOMAIN,
"play_chime",
{ATTR_DEVICE_ID: [device_id], ATTR_RINGTONE: "attraction"},
blocking=True,
@ -76,7 +76,7 @@ async def test_play_chime_service_entity(
reolink_connect.chime.return_value = None
with pytest.raises(ServiceValidationError):
await hass.services.async_call(
REOLINK_DOMAIN,
DOMAIN,
"play_chime",
{ATTR_DEVICE_ID: [device_id], ATTR_RINGTONE: "attraction"},
blocking=True,
@ -109,7 +109,7 @@ async def test_play_chime_service_unloaded(
# Test chime play service
with pytest.raises(ServiceValidationError):
await hass.services.async_call(
REOLINK_DOMAIN,
DOMAIN,
"play_chime",
{ATTR_DEVICE_ID: [device_id], ATTR_RINGTONE: "attraction"},
blocking=True,

View File

@ -11,7 +11,7 @@ from homeassistant.components.rflink import (
CONF_RECONNECT_INTERVAL,
DATA_ENTITY_LOOKUP,
DEFAULT_TCP_KEEPALIVE_IDLE_TIMER,
DOMAIN as RFLINK_DOMAIN,
DOMAIN,
EVENT_KEY_COMMAND,
EVENT_KEY_SENSOR,
SERVICE_SEND_COMMAND,
@ -425,9 +425,9 @@ async def test_keepalive(
) -> None:
"""Validate negative keepalive values."""
keepalive_value = -3
domain = RFLINK_DOMAIN
domain = DOMAIN
config = {
RFLINK_DOMAIN: {
DOMAIN: {
CONF_HOST: "10.10.0.1",
CONF_PORT: 1234,
CONF_KEEPALIVE_IDLE: keepalive_value,
@ -455,9 +455,9 @@ async def test_keepalive_2(
) -> None:
"""Validate very short keepalive values."""
keepalive_value = 30
domain = RFLINK_DOMAIN
domain = DOMAIN
config = {
RFLINK_DOMAIN: {
DOMAIN: {
CONF_HOST: "10.10.0.1",
CONF_PORT: 1234,
CONF_KEEPALIVE_IDLE: keepalive_value,
@ -484,10 +484,8 @@ async def test_keepalive_3(
caplog: pytest.LogCaptureFixture,
) -> None:
"""Validate keepalive=0 value."""
domain = RFLINK_DOMAIN
config = {
RFLINK_DOMAIN: {CONF_HOST: "10.10.0.1", CONF_PORT: 1234, CONF_KEEPALIVE_IDLE: 0}
}
domain = DOMAIN
config = {DOMAIN: {CONF_HOST: "10.10.0.1", CONF_PORT: 1234, CONF_KEEPALIVE_IDLE: 0}}
# setup mocking rflink module
_, mock_create, _, _ = await mock_rflink(hass, config, domain, monkeypatch)
@ -506,8 +504,8 @@ async def test_default_keepalive(
caplog: pytest.LogCaptureFixture,
) -> None:
"""Validate keepalive=0 value."""
domain = RFLINK_DOMAIN
config = {RFLINK_DOMAIN: {CONF_HOST: "10.10.0.1", CONF_PORT: 1234}}
domain = DOMAIN
config = {DOMAIN: {CONF_HOST: "10.10.0.1", CONF_PORT: 1234}}
# setup mocking rflink module
_, mock_create, _, _ = await mock_rflink(hass, config, domain, monkeypatch)
@ -567,8 +565,8 @@ async def test_enable_debug_logs(
) -> None:
"""Test that changing debug level enables RFDEBUG."""
domain = RFLINK_DOMAIN
config = {RFLINK_DOMAIN: {CONF_HOST: "10.10.0.1", CONF_PORT: 1234}}
domain = DOMAIN
config = {DOMAIN: {CONF_HOST: "10.10.0.1", CONF_PORT: 1234}}
# setup mocking rflink module
_, mock_create, _, _ = await mock_rflink(hass, config, domain, monkeypatch)