8000 Remove unnecessary DOMAIN alias in tests (a-d) by epenet · Pull Request #145817 · home-assistant/core · GitHub
[go: up one dir, main page]

Skip to content

Remove unnecessary DOMAIN alias in tests (a-d) #145817

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tests/components/abode/common.py
8000
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from unittest.mock import patch

from homeassistant.components.abode import DOMAIN as ABODE_DOMAIN
from homeassistant.components.abode import DOMAIN
from homeassistant.components.abode.const import CONF_POLLING
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant
Expand All @@ -14,7 +14,7 @@
async def setup_platform(hass: HomeAssistant, platform: str) -> MockConfigEntry:
"""Set up the Abode platform."""
mock_entry = MockConfigEntry(
domain=ABODE_DOMAIN,
domain=DOMAIN,
data={
CONF_USERNAME: "user@email.com",
CONF_PASSWORD: "password",
Expand All @@ -27,7 +27,7 @@ async def setup_platform(hass: HomeAssistant, platform: str) -> MockConfigEntry:
patch("homeassistant.components.abode.PLATFORMS", [platform]),
patch("jaraco.abode.event_controller.sio"),
):
assert await async_setup_component(hass, ABODE_DOMAIN, {})
assert await async_setup_component(hass, DOMAIN, {})
await hass.async_block_till_done()

return mock_entry
4 changes: 2 additions & 2 deletions tests/components/abode/test_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from unittest.mock import patch

from homeassistant.components.abode.const import DOMAIN as ABODE_DOMAIN
from homeassistant.components.abode.const import DOMAIN
from homeassistant.components.camera import DOMAIN as CAMERA_DOMAIN, CameraState
from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.core import HomeAssistant
Expand Down Expand Up @@ -35,7 +35,7 @@ async def test_capture_image(hass: HomeAssistant) -> None:

with patch("jaraco.abode.devices.camera.Camera.capture") as mock_capture:
await hass.services.async_call(
ABODE_DOMAIN,
DOMAIN,
"capture_image",
{ATTR_ENTITY_ID: "camera.test_cam"},
blocking=True,
Expand Down
4 changes: 2 additions & 2 deletions tests/components/abode/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Exception as AbodeException,
)

from homeassistant.components.abode import DOMAIN as ABODE_DOMAIN, SERVICE_SETTINGS< 6D40 /span>
from homeassistant.components.abode import DOMAIN, SERVICE_SETTINGS
from homeassistant.components.alarm_control_panel import DOMAIN as ALARM_DOMAIN
from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import CONF_USERNAME
Expand All @@ -23,7 +23,7 @@ async def test_change_settings(hass: HomeAssistant) -> None:

with patch("jaraco.abode.client.Client.set_setting") as mock_set_setting:
await hass.services.async_call(
ABODE_DOMAIN,
DOMAIN,
SERVICE_SETTINGS,
{"setting": "confirm_snd", "value": "loud"},
blocking=True,
Expand Down
7 changes: 2 additions & 5 deletions tests/components/abode/test_switch.py
9E88
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

from unittest.mock import patch

from homeassistant.components.abode import (
DOMAIN as ABODE_DOMAIN,
SERVICE_TRIGGER_AUTOMATION,
)
from homeassistant.components.abode import DOMAIN, SERVICE_TRIGGER_AUTOMATION
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
from homeassistant.const import (
ATTR_ENTITY_ID,
Expand Down Expand Up @@ -119,7 +116,7 @@ async def test_trigger_automation(hass: HomeAssistant) -> None:

with patch("jaraco.abode.automation.Automation.trigger") as mock:
await hass.services.async_call(
ABODE_DOMAIN,
DOMAIN,
SERVICE_TRIGGER_AUTOMATION,
{ATTR_ENTITY_ID: AUTOMATION_ID},
blocking=True,
Expand Down
6 changes: 3 additions & 3 deletions tests/components/advantage_air/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from datetime import timedelta
from unittest.mock import AsyncMock, patch

from homeassistant.components.advantage_air.const import DOMAIN as ADVANTAGE_AIR_DOMAIN
from homeassistant.components.advantage_air.const import DOMAIN
from homeassistant.components.advantage_air.sensor import (
ADVANTAGE_AIR_SERVICE_SET_TIME_TO,
ADVANTAGE_AIR_SET_COUNTDOWN_VALUE,
Expand Down Expand Up @@ -41,7 +41,7 @@ async def test_sensor_platform(
value = 20

await hass.services.async_call(
ADVANTAGE_AIR_DOMAIN,
DOMAIN,
ADVANTAGE_AIR_SERVICE_SET_TIME_TO,
{ATTR_ENTITY_ID: [entity_id], ADVANTAGE_AIR_SET_COUNTDOWN_VALUE: value},
blocking=True,
Expand All @@ -61,7 +61,7 @@ async def test_sensor_platform(

value = 0
await hass.services.async_call(
ADVANTAGE_AIR_DOMAIN,
DOMAIN,
ADVANTAGE_AIR_SERVICE_SET_TIME_TO,
{ATTR_ENTITY_ID: [entity_id], ADVANTAGE_AIR_SET_COUNTDOWN_VALUE: value},
blocking=True,
Expand Down
4 changes: 2 additions & 2 deletions tests/components/alarm_control_panel/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pytest

from homeassistant.components.alarm_control_panel import (
DOMAIN as ALARM_CONTROL_PANEL_DOMAIN,
DOMAIN,
AlarmControlPanelEntity,
AlarmControlPanelEntityFeature,
)
Expand Down Expand Up @@ -202,7 +202,7 @@ async def async_setup_entry_platform(

mock_platform(
hass,
f"{TEST_DOMAIN}.{ALARM_CONTROL_PANEL_DOMAIN}",
f"{TEST_DOMAIN}.{DOMAIN}",
MockPlatform(async_setup_entry=async_setup_entry_platform),
)

Expand Down
14 changes: 4 additions & 10 deletions tests/components/alarm_control_panel/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from homeassistant.components import alarm_control_panel
from homeassistant.components.alarm_control_panel import (
DOMAIN as ALARM_CONTROL_PANEL_DOMAIN,
DOMAIN,
AlarmControlPanelEntityFeature,
CodeFormat,
)
Expand Down Expand Up @@ -280,9 +280,7 @@ def state(self) -> str:
),
built_in=False,
)
setup_test_component_platform(
hass, ALARM_CONTROL_PANEL_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)
Expand Down Expand Up @@ -343,9 +341,7 @@ def alarm_disarm(self, code: str | None = None) -> None:
),
built_in=False,
)
setup_test_component_platform(
hass, ALARM_CONTROL_PANEL_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)
Expand Down Expand Up @@ -426,9 +422,7 @@ def alarm_disarm(self, code: str | None = None) -> None:
),
built_in=False,
)
setup_test_component_platform(
hass, ALARM_CONTROL_PANEL_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)
Expand Down
4 changes: 2 additions & 2 deletions tests/components/assist_satellite/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from homeassistant.components.assist_pipeline import PipelineEvent
from homeassistant.components.assist_satellite import (
DOMAIN as AS_DOMAIN,
DOMAIN,
AssistSatelliteAnnouncement,
AssistSatelliteConfiguration,
AssistSatelliteEntity,
Expand Down Expand Up @@ -168,7 +168,7 @@ async def async_unload_entry_init(
),
)
setup_test_component_platform(
hass, AS_DOMAIN, [entity, entity2, entity_no_features], from_config_entry=True
hass, DOMAIN, [entity, entity2, entity_no_features], from_config_entry=True
)
mock_platform(hass, f"{TEST_DOMAIN}.config_flow", Mock())

Expand Down
7 changes: 2 additions & 5 deletions tests/components/aussie_broadband/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
from typing import Any
from unittest.mock import patch

from homeassistant.components.aussie_broadband.const import (
CONF_SERVICES,
DOMAIN as AUSSIE_BROADBAND_DOMAIN,
)
from homeassistant.components.aussie_broadband.const import CONF_SERVICES, DOMAIN
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import UNDEFINED, UndefinedType
Expand Down Expand Up @@ -49,7 +46,7 @@ async def setup_platform(
):
"""Set up the Aussie Broadband platform."""
mock_entry = MockConfigEntry(
domain=AUSSIE_BROADBAND_DOMAIN,
domain=DOMAIN,
data=FAKE_DATA,
options={
CONF_SERVICES: ["12345678", "87654321", "23456789", "98765432"],
Expand Down
4 changes: 2 additions & 2 deletions tests/components/axis/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import pytest
import respx

from homeassistant.components.axis.const import DOMAIN as AXIS_DOMAIN
from homeassistant.components.axis.const import DOMAIN
from homeassistant.const import (
CONF_HOST,
CONF_MODEL,
Expand Down Expand Up @@ -91,7 +91,7 @@ def fixture_config_entry(
) -> MockConfigEntry:
"""Define a config entry fixture."""
return MockConfigEntry(
domain=AXIS_DOMAIN,
domain=DOMAIN,
entry_id="676abe5b73621446e6550a2e86ffe3dd",
unique_id=FORMATTED_MAC,
data=config_entry_data,
Expand Down
24 changes: 12 additions & 12 deletions tests/components/axis/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
CONF_VIDEO_SOURCE,
DEFAULT_STREAM_PROFILE,
DEFAULT_VIDEO_SOURCE,
DOMAIN as AXIS_DOMAIN,
DOMAIN,
)
from homeassistant.config_entries import (
SOURCE_DHCP,
Expand Down Expand Up @@ -47,7 +47,7 @@
async def test_flow_manual_configuration(hass: HomeAssistant) -> None:
"""Test that config flow works."""
result = await hass.config_entries.flow.async_init(
AXIS_DOMAIN, context={"source": SOURCE_USER}
DOMAIN, context={"source": SOURCE_USER}
)

assert result["type"] is FlowResultType.FORM
Expand Down Expand Up @@ -86,7 +86,7 @@ async def test_manual_configuration_duplicate_fails(
assert config_entry_setup.data[CONF_HOST] == "1.2.3.4"

result = await hass.config_entries.flow.async_init(
AXIS_DOMAIN, context={"source": SOURCE_USER}
DOMAIN, context={"source": SOURCE_USER}
)

assert result["type"] is FlowResultType.FORM
Expand Down Expand Up @@ -122,7 +122,7 @@ async def test_flow_fails_on_api(
) -> None:
"""Test that config flow fails on faulty credentials."""
result = await hass.config_entries.flow.async_init(
AXIS_DOMAIN, context={"source": SOURCE_USER}
DOMAIN, context={"source": SOURCE_USER}
)

assert result["type"] is FlowResultType.FORM
Expand Down Expand Up @@ -152,18 +152,18 @@ async def test_flow_create_entry_multiple_existing_entries_of_same_model(
) -> None:
"""Test that create entry can generate a name with other entries."""
entry = MockConfigEntry(
domain=AXIS_DOMAIN,
domain=DOMAIN,
data={CONF_NAME: "M1065-LW 0", CONF_MODEL: "M1065-LW"},
)
entry.add_to_hass(hass)
entry2 = MockConfigEntry(
domain=AXIS_DOMAIN,
domain=DOMAIN,
data={CONF_NAME: "M1065-LW 1", CONF_MODEL: "M1065-LW"},
)
entry2.add_to_hass(hass)

result = await hass.config_entries.flow.async_init(
AXIS_DOMAIN, context={"source": SOURCE_USER}
DOMAIN, context={"source": SOURCE_USER}
)

assert result["type"] is FlowResultType.FORM
Expand Down Expand Up @@ -337,7 +337,7 @@ async def test_discovery_flow(
) -> None:
"""Test the different discovery flows for new devices work."""
result = await hass.config_entries.flow.async_init(
AXIS_DOMAIN, data=discovery_info, context={"source": source}
DOMAIN, data=discovery_info, context={"source": source}
)

assert result["type"] is FlowResultType.FORM
Expand Down Expand Up @@ -420,7 +420,7 @@ async def test_discovered_device_already_configured(
assert config_entry_setup.data[CONF_HOST] == DEFAULT_HOST

result = await hass.config_entries.flow.async_init(
AXIS_DOMAIN, data=discovery_info, context={"source": source}
DOMAIN, data=discovery_info, context={"source": source}
)

assert result["type"] is FlowResultType.ABORT
Expand Down Expand Up @@ -488,7 +488,7 @@ async def test_discovery_flow_updated_configuration(

mock_requests("2.3.4.5")
result = await hass.config_entries.flow.async_init(
AXIS_DOMAIN, data=discovery_info, context={"source": source}
DOMAIN, data=discovery_info, context={"source": source}
)
await hass.async_block_till_done()

Expand Down Expand Up @@ -546,7 +546,7 @@ async def test_discovery_flow_ignore_non_axis_device(
) -> None:
"""Test that discovery flow ignores devices with non Axis OUI."""
result = await hass.config_entries.flow.async_init(
AXIS_DOMAIN, data=discovery_info, context={"source": source}
DOMAIN, data=discovery_info, context={"source": source}
)

assert result["type"] is FlowResultType.ABORT
Expand Down Expand Up @@ -595,7 +595,7 @@ async def test_discovery_flow_ignore_link_local_address(
) -> None:
"""Test that discovery flow ignores devices with link local addresses."""
result = await hass.config_entries.flow.async_init(
AXIS_DOMAIN, data=discovery_info, context={"source": source}
DOMAIN, data=discovery_info, context={"source": source}
)

assert result["type"] is FlowResultType.ABORT
Expand Down
6 changes: 3 additions & 3 deletions tests/components/axis/test_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from syrupy.assertion import SnapshotAssertion

from homeassistant.components import axis
from homeassistant.components.axis.const import DOMAIN as AXIS_DOMAIN
from homeassistant.components.axis.const import DOMAIN
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN
from homeassistant.config_entries import SOURCE_ZEROCONF, ConfigEntryState
from homeassistant.const import STATE_OFF, STATE_ON, STATE_UNAVAILABLE
Expand Down Expand Up @@ -43,7 +43,7 @@ async def test_device_registry_entry(
) -> None:
"""Successful setup."""
device_entry = device_registry.async_get_device(
identifiers={(AXIS_DOMAIN, config_entry_setup.unique_id)}
identifiers={(DOMAIN, config_entry_setup.unique_id)}
)
assert device_entry == snapshot

Expand Down Expand Up @@ -93,7 +93,7 @@ async def test_update_address(

mock_requests("2.3.4.5")
await hass.config_entries.flow.async_init(
AXIS_DOMAIN,
DOMAIN,
data=ZeroconfServiceInfo(
ip_address=ip_address("2.3.4.5"),
ip_addresses=[ip_address("2.3.4.5")],
Expand Down
4 changes: 2 additions & 2 deletions tests/components/balboa/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from unittest.mock import MagicMock

from homeassistant.components.balboa.const import DOMAIN as BALBOA_DOMAIN
from homeassistant.components.balboa.const import DOMAIN
from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import CONF_HOST
from homeassistant.core import HomeAssistant
Expand All @@ -24,7 +24,7 @@ async def test_setup_entry(
async def test_setup_entry_fails(hass: HomeAssistant, client: MagicMock) -> None:
"""Validate that setup entry also configure the client."""
config_entry = MockConfigEntry(
domain=BALBOA_DOMAIN,
domain=DOMAIN,
data={
CONF_HOST: TEST_HOST,
},
Expand Down
Loading
Loading
0