Move entity_registry_enabled_by_default to decorator [a-p] (#118794)

This commit is contained in:
epenet 2024-06-04 16:18:42 +02:00 committed by GitHub
parent 089874f818
commit 3d31af3eb4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
32 changed files with 111 additions and 125 deletions

View File

@ -31,9 +31,9 @@ from . import init_integration
from tests.common import async_fire_time_changed, snapshot_platform from tests.common import async_fire_time_changed, snapshot_platform
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_sensor( async def test_sensor(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
entity_registry: er.EntityRegistry, entity_registry: er.EntityRegistry,
mock_accuweather_client: AsyncMock, mock_accuweather_client: AsyncMock,
snapshot: SnapshotAssertion, snapshot: SnapshotAssertion,

View File

@ -4,6 +4,7 @@ import copy
from unittest.mock import patch from unittest.mock import patch
from aioairzone.const import API_DATA, API_SYSTEMS from aioairzone.const import API_DATA, API_SYSTEMS
import pytest
from homeassistant.components.airzone.coordinator import SCAN_INTERVAL from homeassistant.components.airzone.coordinator import SCAN_INTERVAL
from homeassistant.const import STATE_UNAVAILABLE from homeassistant.const import STATE_UNAVAILABLE
@ -22,9 +23,8 @@ from .util import (
from tests.common import async_fire_time_changed from tests.common import async_fire_time_changed
async def test_airzone_create_sensors( @pytest.mark.usefixtures("entity_registry_enabled_by_default")
hass: HomeAssistant, entity_registry_enabled_by_default: None async def test_airzone_create_sensors(hass: HomeAssistant) -> None:
) -> None:
"""Test creation of sensors.""" """Test creation of sensors."""
await async_init_integration(hass) await async_init_integration(hass)
@ -81,9 +81,8 @@ async def test_airzone_create_sensors(
assert state is None assert state is None
async def test_airzone_sensors_availability( @pytest.mark.usefixtures("entity_registry_enabled_by_default")
hass: HomeAssistant, entity_registry_enabled_by_default: None async def test_airzone_sensors_availability(hass: HomeAssistant) -> None:
) -> None:
"""Test sensors availability.""" """Test sensors availability."""
await async_init_integration(hass) await async_init_integration(hass)

View File

@ -12,9 +12,8 @@ from homeassistant.exceptions import ServiceValidationError
from .util import async_init_integration from .util import async_init_integration
async def test_airzone_create_selects( @pytest.mark.usefixtures("entity_registry_enabled_by_default")
hass: HomeAssistant, entity_registry_enabled_by_default: None async def test_airzone_create_selects(hass: HomeAssistant) -> None:
) -> None:
"""Test creation of selects.""" """Test creation of selects."""
await async_init_integration(hass) await async_init_integration(hass)

View File

@ -1,13 +1,14 @@
"""The sensor tests for the Airzone Cloud platform.""" """The sensor tests for the Airzone Cloud platform."""
import pytest
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from .util import async_init_integration from .util import async_init_integration
async def test_airzone_create_sensors( @pytest.mark.usefixtures("entity_registry_enabled_by_default")
hass: HomeAssistant, entity_registry_enabled_by_default: None async def test_airzone_create_sensors(hass: HomeAssistant) -> None:
) -> None:
"""Test creation of sensors.""" """Test creation of sensors."""
await async_init_integration(hass) await async_init_integration(hass)

View File

@ -1,5 +1,7 @@
"""Test the Aranet sensors.""" """Test the Aranet sensors."""
import pytest
from homeassistant.components.aranet.const import DOMAIN from homeassistant.components.aranet.const import DOMAIN
from homeassistant.components.sensor import ATTR_STATE_CLASS from homeassistant.components.sensor import ATTR_STATE_CLASS
from homeassistant.const import ATTR_FRIENDLY_NAME, ATTR_UNIT_OF_MEASUREMENT from homeassistant.const import ATTR_FRIENDLY_NAME, ATTR_UNIT_OF_MEASUREMENT
@ -16,9 +18,8 @@ from tests.common import MockConfigEntry
from tests.components.bluetooth import inject_bluetooth_service_info from tests.components.bluetooth import inject_bluetooth_service_info
async def test_sensors_aranet_radiation( @pytest.mark.usefixtures("entity_registry_enabled_by_default")
hass: HomeAssistant, entity_registry_enabled_by_default: None async def test_sensors_aranet_radiation(hass: HomeAssistant) -> None:
) -> None:
"""Test setting up creates the sensors for Aranet Radiation device.""" """Test setting up creates the sensors for Aranet Radiation device."""
entry = MockConfigEntry( entry = MockConfigEntry(
domain=DOMAIN, domain=DOMAIN,
@ -75,9 +76,8 @@ async def test_sensors_aranet_radiation(
await hass.async_block_till_done() await hass.async_block_till_done()
async def test_sensors_aranet2( @pytest.mark.usefixtures("entity_registry_enabled_by_default")
hass: HomeAssistant, entity_registry_enabled_by_default: None async def test_sensors_aranet2(hass: HomeAssistant) -> None:
) -> None:
"""Test setting up creates the sensors for Aranet2 device.""" """Test setting up creates the sensors for Aranet2 device."""
entry = MockConfigEntry( entry = MockConfigEntry(
domain=DOMAIN, domain=DOMAIN,
@ -125,9 +125,8 @@ async def test_sensors_aranet2(
await hass.async_block_till_done() await hass.async_block_till_done()
async def test_sensors_aranet4( @pytest.mark.usefixtures("entity_registry_enabled_by_default")
hass: HomeAssistant, entity_registry_enabled_by_default: None async def test_sensors_aranet4(hass: HomeAssistant) -> None:
) -> None:
"""Test setting up creates the sensors for Aranet4 device.""" """Test setting up creates the sensors for Aranet4 device."""
entry = MockConfigEntry( entry = MockConfigEntry(
domain=DOMAIN, domain=DOMAIN,
@ -189,9 +188,8 @@ async def test_sensors_aranet4(
await hass.async_block_till_done() await hass.async_block_till_done()
async def test_smart_home_integration_disabled( @pytest.mark.usefixtures("entity_registry_enabled_by_default")
hass: HomeAssistant, entity_registry_enabled_by_default: None async def test_smart_home_integration_disabled(hass: HomeAssistant) -> None:
) -> None:
"""Test disabling smart home integration marks entities as unavailable.""" """Test disabling smart home integration marks entities as unavailable."""
entry = MockConfigEntry( entry = MockConfigEntry(
domain=DOMAIN, domain=DOMAIN,

View File

@ -3,6 +3,7 @@
from unittest.mock import AsyncMock, patch from unittest.mock import AsyncMock, patch
from freezegun.api import FrozenDateTimeFactory from freezegun.api import FrozenDateTimeFactory
import pytest
from syrupy import SnapshotAssertion from syrupy import SnapshotAssertion
from homeassistant.components.brother.const import DOMAIN, UPDATE_INTERVAL from homeassistant.components.brother.const import DOMAIN, UPDATE_INTERVAL
@ -16,10 +17,10 @@ from . import init_integration
from tests.common import MockConfigEntry, async_fire_time_changed, snapshot_platform from tests.common import MockConfigEntry, async_fire_time_changed, snapshot_platform
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_sensors( async def test_sensors(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry: er.EntityRegistry, entity_registry: er.EntityRegistry,
entity_registry_enabled_by_default: None,
snapshot: SnapshotAssertion, snapshot: SnapshotAssertion,
mock_brother_client: AsyncMock, mock_brother_client: AsyncMock,
mock_config_entry: MockConfigEntry, mock_config_entry: MockConfigEntry,

View File

@ -28,7 +28,7 @@ from tests.test_util.aiohttp import AiohttpClientMocker
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def enable_all_entities(entity_registry_enabled_by_default): def enable_all_entities(entity_registry_enabled_by_default: None) -> None:
"""Make sure all entities are enabled.""" """Make sure all entities are enabled."""

View File

@ -77,9 +77,9 @@ async def test_buttons(
assert button.state != STATE_UNKNOWN assert button.state != STATE_UNKNOWN
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_wol_button( async def test_wol_button(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
fc_class_mock, fc_class_mock,
fh_class_mock, fh_class_mock,
) -> None: ) -> None:
@ -110,9 +110,9 @@ async def test_wol_button(
assert button.state != STATE_UNKNOWN assert button.state != STATE_UNKNOWN
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_wol_button_new_device( async def test_wol_button_new_device(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
fc_class_mock, fc_class_mock,
fh_class_mock, fh_class_mock,
) -> None: ) -> None:
@ -138,9 +138,9 @@ async def test_wol_button_new_device(
assert hass.states.get("button.server_wake_on_lan") assert hass.states.get("button.server_wake_on_lan")
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_wol_button_absent_for_mesh_slave( async def test_wol_button_absent_for_mesh_slave(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
fc_class_mock, fc_class_mock,
fh_class_mock, fh_class_mock,
) -> None: ) -> None:
@ -160,9 +160,9 @@ async def test_wol_button_absent_for_mesh_slave(
assert button is None assert button is None
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_wol_button_absent_for_non_lan_device( async def test_wol_button_absent_for_non_lan_device(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
fc_class_mock, fc_class_mock,
fh_class_mock, fh_class_mock,
) -> None: ) -> None:

View File

@ -1,5 +1,7 @@
"""Sensor tests for the Goalzero integration.""" """Sensor tests for the Goalzero integration."""
import pytest
from homeassistant.components.goalzero.const import DEFAULT_NAME from homeassistant.components.goalzero.const import DEFAULT_NAME
from homeassistant.components.sensor import ( from homeassistant.components.sensor import (
ATTR_STATE_CLASS, ATTR_STATE_CLASS,
@ -25,10 +27,9 @@ from . import async_init_integration
from tests.test_util.aiohttp import AiohttpClientMocker from tests.test_util.aiohttp import AiohttpClientMocker
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_sensors( async def test_sensors(
hass: HomeAssistant, hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
aioclient_mock: AiohttpClientMocker,
entity_registry_enabled_by_default: None,
) -> None: ) -> None:
"""Test we get sensor data.""" """Test we get sensor data."""
await async_init_integration(hass, aioclient_mock) await async_init_integration(hass, aioclient_mock)

View File

@ -61,9 +61,8 @@ async def test_registry_settings(
ENTITY_ID_XFAN, ENTITY_ID_XFAN,
], ],
) )
async def test_send_switch_on( @pytest.mark.usefixtures("entity_registry_enabled_by_default")
hass: HomeAssistant, entity, entity_registry_enabled_by_default: None async def test_send_switch_on(hass: HomeAssistant, entity: str) -> None:
) -> None:
"""Test for sending power on command to the device.""" """Test for sending power on command to the device."""
await async_setup_gree(hass) await async_setup_gree(hass)
@ -89,8 +88,9 @@ async def test_send_switch_on(
ENTITY_ID_XFAN, ENTITY_ID_XFAN,
], ],
) )
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_send_switch_on_device_timeout( async def test_send_switch_on_device_timeout(
hass: HomeAssistant, device, entity, entity_registry_enabled_by_default: None hass: HomeAssistant, device, entity: str
) -> None: ) -> None:
"""Test for sending power on command to the device with a device timeout.""" """Test for sending power on command to the device with a device timeout."""
device().push_state_update.side_effect = DeviceTimeoutError device().push_state_update.side_effect = DeviceTimeoutError
@ -119,9 +119,8 @@ async def test_send_switch_on_device_timeout(
ENTITY_ID_XFAN, ENTITY_ID_XFAN,
], ],
) )
async def test_send_switch_off( @pytest.mark.usefixtures("entity_registry_enabled_by_default")
hass: HomeAssistant, entity, entity_registry_enabled_by_default: None async def test_send_switch_off(hass: HomeAssistant, entity: str) -> None:
) -> None:
"""Test for sending power on command to the device.""" """Test for sending power on command to the device."""
await async_setup_gree(hass) await async_setup_gree(hass)
@ -147,9 +146,8 @@ async def test_send_switch_off(
ENTITY_ID_XFAN, ENTITY_ID_XFAN,
], ],
) )
async def test_send_switch_toggle( @pytest.mark.usefixtures("entity_registry_enabled_by_default")
hass: HomeAssistant, entity, entity_registry_enabled_by_default: None async def test_send_switch_toggle(hass: HomeAssistant, entity: str) -> None:
) -> None:
"""Test for sending power on command to the device.""" """Test for sending power on command to the device."""
await async_setup_gree(hass) await async_setup_gree(hass)

View File

@ -2,6 +2,8 @@
from datetime import timedelta from datetime import timedelta
import pytest
from homeassistant.components import automation, script from homeassistant.components import automation, script
from homeassistant.components.automation import automations_with_entity from homeassistant.components.automation import automations_with_entity
from homeassistant.components.harmony.const import DOMAIN from homeassistant.components.harmony.const import DOMAIN
@ -142,12 +144,12 @@ async def _toggle_switch_and_wait(hass, service_name, entity):
await hass.async_block_till_done() await hass.async_block_till_done()
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_create_issue( async def test_create_issue(
harmony_client, harmony_client,
mock_hc, mock_hc,
hass: HomeAssistant, hass: HomeAssistant,
mock_write_config, mock_write_config,
entity_registry_enabled_by_default: None,
issue_registry: ir.IssueRegistry, issue_registry: ir.IssueRegistry,
) -> None: ) -> None:
"""Test we create an issue when an automation or script is using a deprecated entity.""" """Test we create an issue when an automation or script is using a deprecated entity."""

View File

@ -999,10 +999,10 @@ async def test_coordinator_updates(
assert "Error on Supervisor API: Unknown" in caplog.text assert "Error on Supervisor API: Unknown" in caplog.text
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_coordinator_updates_stats_entities_enabled( async def test_coordinator_updates_stats_entities_enabled(
hass: HomeAssistant, hass: HomeAssistant,
caplog: pytest.LogCaptureFixture, caplog: pytest.LogCaptureFixture,
entity_registry_enabled_by_default: None,
) -> None: ) -> None:
"""Test coordinator updates with stats entities enabled.""" """Test coordinator updates with stats entities enabled."""
await async_setup_component(hass, "homeassistant", {}) await async_setup_component(hass, "homeassistant", {})

View File

@ -8,6 +8,7 @@ from aiohomekit.model.characteristics.const import ThreadNodeCapabilities, Threa
from aiohomekit.model.services import ServicesTypes from aiohomekit.model.services import ServicesTypes
from aiohomekit.protocol.statuscodes import HapStatusCode from aiohomekit.protocol.statuscodes import HapStatusCode
from aiohomekit.testing import FakePairing from aiohomekit.testing import FakePairing
import pytest
from homeassistant.components.homekit_controller.sensor import ( from homeassistant.components.homekit_controller.sensor import (
thread_node_capability_to_str, thread_node_capability_to_str,
@ -381,11 +382,8 @@ def test_thread_status_to_str() -> None:
assert thread_status_to_str(ThreadStatus.DISABLED) == "disabled" assert thread_status_to_str(ThreadStatus.DISABLED) == "disabled"
async def test_rssi_sensor( @pytest.mark.usefixtures("enable_bluetooth", "entity_registry_enabled_by_default")
hass: HomeAssistant, async def test_rssi_sensor(hass: HomeAssistant) -> None:
entity_registry_enabled_by_default: None,
enable_bluetooth: None,
) -> None:
"""Test an rssi sensor.""" """Test an rssi sensor."""
inject_bluetooth_service_info(hass, TEST_DEVICE_SERVICE_INFO) inject_bluetooth_service_info(hass, TEST_DEVICE_SERVICE_INFO)
@ -405,11 +403,9 @@ async def test_rssi_sensor(
assert hass.states.get("sensor.testdevice_signal_strength").state == "-56" assert hass.states.get("sensor.testdevice_signal_strength").state == "-56"
@pytest.mark.usefixtures("enable_bluetooth", "entity_registry_enabled_by_default")
async def test_migrate_rssi_sensor_unique_id( async def test_migrate_rssi_sensor_unique_id(
hass: HomeAssistant, hass: HomeAssistant, entity_registry: er.EntityRegistry
entity_registry: er.EntityRegistry,
entity_registry_enabled_by_default: None,
enable_bluetooth: None,
) -> None: ) -> None:
"""Test an rssi sensor unique id migration.""" """Test an rssi sensor unique id migration."""
rssi_sensor = entity_registry.async_get_or_create( rssi_sensor = entity_registry.async_get_or_create(

View File

@ -2,16 +2,15 @@
from unittest.mock import MagicMock from unittest.mock import MagicMock
import pytest
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from . import init_integration from . import init_integration
async def test_height_sensor( @pytest.mark.usefixtures("entity_registry_enabled_by_default")
hass: HomeAssistant, async def test_height_sensor(hass: HomeAssistant, mock_desk_api: MagicMock) -> None:
mock_desk_api: MagicMock,
entity_registry_enabled_by_default: None,
) -> None:
"""Test height sensor.""" """Test height sensor."""
await init_integration(hass) await init_integration(hass)

View File

@ -4,6 +4,7 @@ from unittest.mock import AsyncMock, patch
from freezegun.api import FrozenDateTimeFactory from freezegun.api import FrozenDateTimeFactory
from imgw_pib import ApiError from imgw_pib import ApiError
import pytest
from syrupy import SnapshotAssertion from syrupy import SnapshotAssertion
from homeassistant.components.imgw_pib.const import UPDATE_INTERVAL from homeassistant.components.imgw_pib.const import UPDATE_INTERVAL
@ -18,13 +19,13 @@ from tests.common import MockConfigEntry, async_fire_time_changed, snapshot_plat
ENTITY_ID = "sensor.river_name_station_name_water_level" ENTITY_ID = "sensor.river_name_station_name_water_level"
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_sensor( async def test_sensor(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry: er.EntityRegistry, entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion, snapshot: SnapshotAssertion,
mock_imgw_pib_client: AsyncMock, mock_imgw_pib_client: AsyncMock,
mock_config_entry: MockConfigEntry, mock_config_entry: MockConfigEntry,
entity_registry_enabled_by_default: None,
) -> None: ) -> None:
"""Test states of the sensor.""" """Test states of the sensor."""
with patch("homeassistant.components.imgw_pib.PLATFORMS", [Platform.SENSOR]): with patch("homeassistant.components.imgw_pib.PLATFORMS", [Platform.SENSOR]):

View File

@ -92,12 +92,12 @@ def mock_get_setting_values(mock_plenticore_client: ApiClient) -> list:
return setting_values return setting_values
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_setup_all_entries( async def test_setup_all_entries(
hass: HomeAssistant, hass: HomeAssistant,
mock_config_entry: MockConfigEntry, mock_config_entry: MockConfigEntry,
mock_plenticore_client: ApiClient, mock_plenticore_client: ApiClient,
mock_get_setting_values: list, mock_get_setting_values: list,
entity_registry_enabled_by_default: None,
) -> None: ) -> None:
"""Test if all available entries are setup.""" """Test if all available entries are setup."""
@ -111,12 +111,12 @@ async def test_setup_all_entries(
assert ent_reg.async_get("number.scb_battery_min_home_consumption") is not None assert ent_reg.async_get("number.scb_battery_min_home_consumption") is not None
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_setup_no_entries( async def test_setup_no_entries(
hass: HomeAssistant, hass: HomeAssistant,
mock_config_entry: MockConfigEntry, mock_config_entry: MockConfigEntry,
mock_plenticore_client: ApiClient, mock_plenticore_client: ApiClient,
mock_get_setting_values: list, mock_get_setting_values: list,
entity_registry_enabled_by_default: None,
) -> None: ) -> None:
"""Test that no entries are setup if Plenticore does not provide data.""" """Test that no entries are setup if Plenticore does not provide data."""
@ -145,12 +145,12 @@ async def test_setup_no_entries(
assert ent_reg.async_get("number.scb_battery_min_home_consumption") is None assert ent_reg.async_get("number.scb_battery_min_home_consumption") is None
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_number_has_value( async def test_number_has_value(
hass: HomeAssistant, hass: HomeAssistant,
mock_config_entry: MockConfigEntry, mock_config_entry: MockConfigEntry,
mock_plenticore_client: ApiClient, mock_plenticore_client: ApiClient,
mock_get_setting_values: list, mock_get_setting_values: list,
entity_registry_enabled_by_default: None,
) -> None: ) -> None:
"""Test if number has a value if data is provided on update.""" """Test if number has a value if data is provided on update."""
@ -170,12 +170,12 @@ async def test_number_has_value(
assert state.attributes[ATTR_MAX] == 100 assert state.attributes[ATTR_MAX] == 100
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_number_is_unavailable( async def test_number_is_unavailable(
hass: HomeAssistant, hass: HomeAssistant,
mock_config_entry: MockConfigEntry, mock_config_entry: MockConfigEntry,
mock_plenticore_client: ApiClient, mock_plenticore_client: ApiClient,
mock_get_setting_values: list, mock_get_setting_values: list,
entity_registry_enabled_by_default: None,
) -> None: ) -> None:
"""Test if number is unavailable if no data is provided on update.""" """Test if number is unavailable if no data is provided on update."""
@ -191,12 +191,12 @@ async def test_number_is_unavailable(
assert state.state == STATE_UNAVAILABLE assert state.state == STATE_UNAVAILABLE
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_set_value( async def test_set_value(
hass: HomeAssistant, hass: HomeAssistant,
mock_config_entry: MockConfigEntry, mock_config_entry: MockConfigEntry,
mock_plenticore_client: ApiClient, mock_plenticore_client: ApiClient,
mock_get_setting_values: list, mock_get_setting_values: list,
entity_registry_enabled_by_default: None,
) -> None: ) -> None:
"""Test if a new value could be set.""" """Test if a new value could be set."""

View File

@ -5,6 +5,7 @@ from unittest.mock import patch
from freezegun.api import FrozenDateTimeFactory from freezegun.api import FrozenDateTimeFactory
from pykrakenapi.pykrakenapi import KrakenAPIError from pykrakenapi.pykrakenapi import KrakenAPIError
import pytest
from homeassistant.components.kraken.const import ( from homeassistant.components.kraken.const import (
CONF_TRACKED_ASSET_PAIRS, CONF_TRACKED_ASSET_PAIRS,
@ -26,10 +27,10 @@ from .const import (
from tests.common import MockConfigEntry, async_fire_time_changed from tests.common import MockConfigEntry, async_fire_time_changed
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_sensor( async def test_sensor(
hass: HomeAssistant, hass: HomeAssistant,
freezer: FrozenDateTimeFactory, freezer: FrozenDateTimeFactory,
entity_registry_enabled_by_default: None,
) -> None: ) -> None:
"""Test that sensor has a value.""" """Test that sensor has a value."""
with ( with (

View File

@ -1,5 +1,7 @@
"""The tests for Lidarr sensor platform.""" """The tests for Lidarr sensor platform."""
import pytest
from homeassistant.components.sensor import CONF_STATE_CLASS, SensorStateClass from homeassistant.components.sensor import CONF_STATE_CLASS, SensorStateClass
from homeassistant.const import ATTR_UNIT_OF_MEASUREMENT from homeassistant.const import ATTR_UNIT_OF_MEASUREMENT
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -7,10 +9,10 @@ from homeassistant.core import HomeAssistant
from .conftest import ComponentSetup from .conftest import ComponentSetup
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_sensors( async def test_sensors(
hass: HomeAssistant, hass: HomeAssistant,
setup_integration: ComponentSetup, setup_integration: ComponentSetup,
entity_registry_enabled_by_default: None,
connection, connection,
) -> None: ) -> None:
"""Test for successfully setting up the Lidarr platform.""" """Test for successfully setting up the Lidarr platform."""

View File

@ -15,10 +15,10 @@ from .conftest import setup_integration
@pytest.mark.freeze_time("2022-09-18 23:00:44+00:00") @pytest.mark.freeze_time("2022-09-18 23:00:44+00:00")
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_binary_sensors( async def test_binary_sensors(
hass: HomeAssistant, hass: HomeAssistant,
mock_account: MagicMock, mock_account: MagicMock,
entity_registry_enabled_by_default: None,
) -> None: ) -> None:
"""Tests binary sensors.""" """Tests binary sensors."""
await setup_integration(hass, mock_account, PLATFORM_DOMAIN) await setup_integration(hass, mock_account, PLATFORM_DOMAIN)

View File

@ -33,9 +33,9 @@ from tests.common import (
) )
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_sensor( async def test_sensor(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
entity_registry: er.EntityRegistry, entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion, snapshot: SnapshotAssertion,
freezer: FrozenDateTimeFactory, freezer: FrozenDateTimeFactory,

View File

@ -1,5 +1,6 @@
"""The tests for Netgear LTE binary sensor platform.""" """The tests for Netgear LTE binary sensor platform."""
import pytest
from syrupy.assertion import SnapshotAssertion from syrupy.assertion import SnapshotAssertion
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN
@ -8,9 +9,9 @@ from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er from homeassistant.helpers import entity_registry as er
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_binary_sensors( async def test_binary_sensors(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
setup_integration: None, setup_integration: None,
entity_registry: er.EntityRegistry, entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion, snapshot: SnapshotAssertion,

View File

@ -1,5 +1,6 @@
"""The tests for Netgear LTE sensor platform.""" """The tests for Netgear LTE sensor platform."""
import pytest
from syrupy.assertion import SnapshotAssertion from syrupy.assertion import SnapshotAssertion
from homeassistant.components.netgear_lte.const import DOMAIN from homeassistant.components.netgear_lte.const import DOMAIN
@ -8,9 +9,9 @@ from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er from homeassistant.helpers import entity_registry as er
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_sensors( async def test_sensors(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
setup_integration: None, setup_integration: None,
entity_registry: er.EntityRegistry, entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion, snapshot: SnapshotAssertion,

View File

@ -4,6 +4,7 @@ from datetime import timedelta
from unittest.mock import patch from unittest.mock import patch
from nextdns import ApiError from nextdns import ApiError
import pytest
from syrupy import SnapshotAssertion from syrupy import SnapshotAssertion
from homeassistant.const import STATE_UNAVAILABLE, Platform from homeassistant.const import STATE_UNAVAILABLE, Platform
@ -16,9 +17,9 @@ from . import init_integration, mock_nextdns
from tests.common import async_fire_time_changed, snapshot_platform from tests.common import async_fire_time_changed, snapshot_platform
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_sensor( async def test_sensor(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
entity_registry: er.EntityRegistry, entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion, snapshot: SnapshotAssertion,
) -> None: ) -> None:
@ -29,9 +30,9 @@ async def test_sensor(
await snapshot_platform(hass, entity_registry, snapshot, entry.entry_id) await snapshot_platform(hass, entity_registry, snapshot, entry.entry_id)
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_availability( async def test_availability(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
entity_registry: er.EntityRegistry, entity_registry: er.EntityRegistry,
) -> None: ) -> None:
"""Ensure that we mark the entities unavailable correctly when service causes an error.""" """Ensure that we mark the entities unavailable correctly when service causes an error."""

View File

@ -29,9 +29,9 @@ from . import init_integration, mock_nextdns
from tests.common import async_fire_time_changed, snapshot_platform from tests.common import async_fire_time_changed, snapshot_platform
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_switch( async def test_switch(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
entity_registry: er.EntityRegistry, entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion, snapshot: SnapshotAssertion,
) -> None: ) -> None:

View File

@ -66,6 +66,7 @@ def _setup_climate_group(
(Model.F730, "s1", "climate.climate_system_s1"), (Model.F730, "s1", "climate.climate_system_s1"),
], ],
) )
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_basic( async def test_basic(
hass: HomeAssistant, hass: HomeAssistant,
mock_connection: MockConnection, mock_connection: MockConnection,
@ -73,7 +74,6 @@ async def test_basic(
climate_id: str, climate_id: str,
entity_id: str, entity_id: str,
coils: dict[int, Any], coils: dict[int, Any],
entity_registry_enabled_by_default: None,
snapshot: SnapshotAssertion, snapshot: SnapshotAssertion,
) -> None: ) -> None:
"""Test setting of value.""" """Test setting of value."""
@ -113,6 +113,7 @@ async def test_basic(
(Model.F1155, "s3", "climate.climate_system_s3"), (Model.F1155, "s3", "climate.climate_system_s3"),
], ],
) )
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_active_accessory( async def test_active_accessory(
hass: HomeAssistant, hass: HomeAssistant,
mock_connection: MockConnection, mock_connection: MockConnection,
@ -120,7 +121,6 @@ async def test_active_accessory(
climate_id: str, climate_id: str,
entity_id: str, entity_id: str,
coils: dict[int, Any], coils: dict[int, Any],
entity_registry_enabled_by_default: None,
snapshot: SnapshotAssertion, snapshot: SnapshotAssertion,
) -> None: ) -> None:
"""Test climate groups that can be deactivated by configuration.""" """Test climate groups that can be deactivated by configuration."""
@ -141,6 +141,7 @@ async def test_active_accessory(
(Model.F1155, "s2", "climate.climate_system_s2"), (Model.F1155, "s2", "climate.climate_system_s2"),
], ],
) )
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_set_temperature_supported_cooling( async def test_set_temperature_supported_cooling(
hass: HomeAssistant, hass: HomeAssistant,
mock_connection: MockConnection, mock_connection: MockConnection,
@ -148,7 +149,6 @@ async def test_set_temperature_supported_cooling(
climate_id: str, climate_id: str,
entity_id: str, entity_id: str,
coils: dict[int, Any], coils: dict[int, Any],
entity_registry_enabled_by_default: None,
snapshot: SnapshotAssertion, snapshot: SnapshotAssertion,
) -> None: ) -> None:
"""Test setting temperature for models with cooling support.""" """Test setting temperature for models with cooling support."""
@ -234,6 +234,7 @@ async def test_set_temperature_supported_cooling(
(Model.F730, "s1", "climate.climate_system_s1"), (Model.F730, "s1", "climate.climate_system_s1"),
], ],
) )
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_set_temperature_unsupported_cooling( async def test_set_temperature_unsupported_cooling(
hass: HomeAssistant, hass: HomeAssistant,
mock_connection: MockConnection, mock_connection: MockConnection,
@ -241,7 +242,6 @@ async def test_set_temperature_unsupported_cooling(
climate_id: str, climate_id: str,
entity_id: str, entity_id: str,
coils: dict[int, Any], coils: dict[int, Any],
entity_registry_enabled_by_default: None,
snapshot: SnapshotAssertion, snapshot: SnapshotAssertion,
) -> None: ) -> None:
"""Test setting temperature for models that do not support cooling.""" """Test setting temperature for models that do not support cooling."""
@ -300,6 +300,7 @@ async def test_set_temperature_unsupported_cooling(
(Model.F730, "s1", "climate.climate_system_s1"), (Model.F730, "s1", "climate.climate_system_s1"),
], ],
) )
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_set_hvac_mode( async def test_set_hvac_mode(
hass: HomeAssistant, hass: HomeAssistant,
mock_connection: MockConnection, mock_connection: MockConnection,
@ -310,7 +311,6 @@ async def test_set_hvac_mode(
use_room_sensor: str, use_room_sensor: str,
hvac_mode: HVACMode, hvac_mode: HVACMode,
coils: dict[int, Any], coils: dict[int, Any],
entity_registry_enabled_by_default: None,
) -> None: ) -> None:
"""Test setting a hvac mode.""" """Test setting a hvac mode."""
climate, unit = _setup_climate_group(coils, model, climate_id) climate, unit = _setup_climate_group(coils, model, climate_id)
@ -349,6 +349,7 @@ async def test_set_hvac_mode(
(Model.F730, "s1", "climate.climate_system_s1", HVACMode.COOL), (Model.F730, "s1", "climate.climate_system_s1", HVACMode.COOL),
], ],
) )
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_set_invalid_hvac_mode( async def test_set_invalid_hvac_mode(
hass: HomeAssistant, hass: HomeAssistant,
mock_connection: MockConnection, mock_connection: MockConnection,
@ -357,7 +358,6 @@ async def test_set_invalid_hvac_mode(
entity_id: str, entity_id: str,
unsupported_mode: str, unsupported_mode: str,
coils: dict[int, Any], coils: dict[int, Any],
entity_registry_enabled_by_default: None,
) -> None: ) -> None:
"""Test setting an invalid hvac mode.""" """Test setting an invalid hvac mode."""
_setup_climate_group(coils, model, climate_id) _setup_climate_group(coils, model, climate_id)

View File

@ -22,10 +22,10 @@ async def fixture_single_platform():
yield yield
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_partial_refresh( async def test_partial_refresh(
hass: HomeAssistant, hass: HomeAssistant,
coils: dict[int, Any], coils: dict[int, Any],
entity_registry_enabled_by_default: None,
snapshot: SnapshotAssertion, snapshot: SnapshotAssertion,
) -> None: ) -> None:
"""Test that coordinator can handle partial fields.""" """Test that coordinator can handle partial fields."""
@ -45,10 +45,10 @@ async def test_partial_refresh(
assert data == snapshot(name="3. Sensor is available") assert data == snapshot(name="3. Sensor is available")
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_invalid_coil( async def test_invalid_coil(
hass: HomeAssistant, hass: HomeAssistant,
coils: dict[int, Any], coils: dict[int, Any],
entity_registry_enabled_by_default: None,
snapshot: SnapshotAssertion, snapshot: SnapshotAssertion,
freezer_ticker: Any, freezer_ticker: Any,
) -> None: ) -> None:
@ -67,10 +67,10 @@ async def test_invalid_coil(
assert hass.states.get(entity_id) == snapshot(name="Sensor is not available") assert hass.states.get(entity_id) == snapshot(name="Sensor is not available")
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_pushed_update( async def test_pushed_update(
hass: HomeAssistant, hass: HomeAssistant,
coils: dict[int, Any], coils: dict[int, Any],
entity_registry_enabled_by_default: None,
snapshot: SnapshotAssertion, snapshot: SnapshotAssertion,
mock_connection: MockConnection, mock_connection: MockConnection,
freezer_ticker: Any, freezer_ticker: Any,
@ -97,10 +97,10 @@ async def test_pushed_update(
assert hass.states.get(entity_id) == snapshot(name="4. final values") assert hass.states.get(entity_id) == snapshot(name="4. final values")
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_shutdown( async def test_shutdown(
hass: HomeAssistant, hass: HomeAssistant,
coils: dict[int, Any], coils: dict[int, Any],
entity_registry_enabled_by_default: None,
mock_connection: MockConnection, mock_connection: MockConnection,
freezer_ticker: Any, freezer_ticker: Any,
) -> None: ) -> None:

View File

@ -43,6 +43,7 @@ async def fixture_single_platform():
(Model.F750, 47062, "number.hw_charge_offset_47062", None), (Model.F750, 47062, "number.hw_charge_offset_47062", None),
], ],
) )
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_update( async def test_update(
hass: HomeAssistant, hass: HomeAssistant,
model: Model, model: Model,
@ -50,7 +51,6 @@ async def test_update(
address: int, address: int,
value: Any, value: Any,
coils: dict[int, Any], coils: dict[int, Any],
entity_registry_enabled_by_default: None,
snapshot: SnapshotAssertion, snapshot: SnapshotAssertion,
) -> None: ) -> None:
"""Test setting of value.""" """Test setting of value."""
@ -73,6 +73,7 @@ async def test_update(
(Model.F750, 47062, "number.hw_charge_offset_47062", 10), (Model.F750, 47062, "number.hw_charge_offset_47062", 10),
], ],
) )
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_set_value( async def test_set_value(
hass: HomeAssistant, hass: HomeAssistant,
mock_connection: AsyncMock, mock_connection: AsyncMock,
@ -81,7 +82,6 @@ async def test_set_value(
address: int, address: int,
value: Any, value: Any,
coils: dict[int, Any], coils: dict[int, Any],
entity_registry_enabled_by_default: None,
) -> None: ) -> None:
"""Test setting of value.""" """Test setting of value."""
coils[address] = 0 coils[address] = 0

View File

@ -3,6 +3,8 @@
from datetime import timedelta from datetime import timedelta
import time import time
import pytest
from homeassistant.components.bluetooth import ( from homeassistant.components.bluetooth import (
FALLBACK_MAXIMUM_STALE_ADVERTISEMENT_SECONDS, FALLBACK_MAXIMUM_STALE_ADVERTISEMENT_SECONDS,
async_address_present, async_address_present,
@ -27,9 +29,8 @@ from tests.components.bluetooth import (
) )
async def test_sensors( @pytest.mark.usefixtures("entity_registry_enabled_by_default")
hass: HomeAssistant, entity_registry_enabled_by_default: None async def test_sensors(hass: HomeAssistant) -> None:
) -> None:
"""Test setting up creates the sensors.""" """Test setting up creates the sensors."""
start_monotonic = time.monotonic() start_monotonic = time.monotonic()
entry = MockConfigEntry( entry = MockConfigEntry(
@ -79,9 +80,8 @@ async def test_sensors(
assert toothbrush_sensor.state == "running" assert toothbrush_sensor.state == "running"
async def test_sensors_io_series_4( @pytest.mark.usefixtures("entity_registry_enabled_by_default")
hass: HomeAssistant, entity_registry_enabled_by_default: None async def test_sensors_io_series_4(hass: HomeAssistant) -> None:
) -> None:
"""Test setting up creates the sensors with an io series 4.""" """Test setting up creates the sensors with an io series 4."""
start_monotonic = time.monotonic() start_monotonic = time.monotonic()

View File

@ -106,13 +106,13 @@ from tests.common import MockConfigEntry
), ),
], ],
) )
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_sensor( async def test_sensor(
hass: HomeAssistant, hass: HomeAssistant,
mock_config_entry_data: dict, mock_config_entry_data: dict,
mock_station_details: Station, mock_station_details: Station,
mock_station_measurement: StationMeasurements, mock_station_measurement: StationMeasurements,
expected_states: dict, expected_states: dict,
entity_registry_enabled_by_default: None,
) -> None: ) -> None:
"""Tests sensor entity.""" """Tests sensor entity."""
entry = MockConfigEntry( entry = MockConfigEntry(

View File

@ -3,6 +3,7 @@
from datetime import timedelta from datetime import timedelta
from unittest.mock import Mock, patch from unittest.mock import Mock, patch
import pytest
from tesla_powerwall import MetersAggregatesResponse from tesla_powerwall import MetersAggregatesResponse
from tesla_powerwall.error import MissingAttributeError from tesla_powerwall.error import MissingAttributeError
@ -25,11 +26,8 @@ from .mocks import MOCK_GATEWAY_DIN, _mock_powerwall_with_fixtures
from tests.common import MockConfigEntry, async_fire_time_changed from tests.common import MockConfigEntry, async_fire_time_changed
async def test_sensors( @pytest.mark.usefixtures("entity_registry_enabled_by_default")
hass: HomeAssistant, async def test_sensors(hass: HomeAssistant, device_registry: dr.DeviceRegistry) -> None:
device_registry: dr.DeviceRegistry,
entity_registry_enabled_by_default: None,
) -> None:
"""Test creation of the sensors.""" """Test creation of the sensors."""
mock_powerwall = await _mock_powerwall_with_fixtures(hass) mock_powerwall = await _mock_powerwall_with_fixtures(hass)
@ -245,11 +243,11 @@ async def test_sensors_with_empty_meters(hass: HomeAssistant) -> None:
assert hass.states.get("sensor.mysite_solar_power") is None assert hass.states.get("sensor.mysite_solar_power") is None
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_unique_id_migrate( async def test_unique_id_migrate(
hass: HomeAssistant, hass: HomeAssistant,
device_registry: dr.DeviceRegistry, device_registry: dr.DeviceRegistry,
entity_registry: er.EntityRegistry, entity_registry: er.EntityRegistry,
entity_registry_enabled_by_default: None,
) -> None: ) -> None:
"""Test we can migrate unique ids of the sensors.""" """Test we can migrate unique ids of the sensors."""
config_entry = MockConfigEntry(domain=DOMAIN, data={CONF_IP_ADDRESS: "1.2.3.4"}) config_entry = MockConfigEntry(domain=DOMAIN, data={CONF_IP_ADDRESS: "1.2.3.4"})

View File

@ -3,6 +3,7 @@
import time import time
from habluetooth.advertisement_tracker import ADVERTISING_TIMES_NEEDED from habluetooth.advertisement_tracker import ADVERTISING_TIMES_NEEDED
import pytest
from homeassistant.components.bluetooth.api import ( from homeassistant.components.bluetooth.api import (
async_get_fallback_availability_interval, async_get_fallback_availability_interval,
@ -184,11 +185,8 @@ async def test_old_tracker_leave_home(
assert state.state == "not_home" assert state.state == "not_home"
async def test_mac_rotation( @pytest.mark.usefixtures("enable_bluetooth", "entity_registry_enabled_by_default")
hass: HomeAssistant, async def test_mac_rotation(hass: HomeAssistant) -> None:
enable_bluetooth: None,
entity_registry_enabled_by_default: None,
) -> None:
"""Test sensors get value when we receive a broadcast.""" """Test sensors get value when we receive a broadcast."""
await async_mock_config_entry(hass) await async_mock_config_entry(hass)

View File

@ -1,6 +1,7 @@
"""Tests for sensors.""" """Tests for sensors."""
from habluetooth.advertisement_tracker import ADVERTISING_TIMES_NEEDED from habluetooth.advertisement_tracker import ADVERTISING_TIMES_NEEDED
import pytest
from homeassistant.components.bluetooth import async_set_fallback_availability_interval from homeassistant.components.bluetooth import async_set_fallback_availability_interval
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -13,11 +14,8 @@ from . import (
) )
async def test_sensor_unavailable( @pytest.mark.usefixtures("enable_bluetooth", "entity_registry_enabled_by_default")
hass: HomeAssistant, async def test_sensor_unavailable(hass: HomeAssistant) -> None:
enable_bluetooth: None,
entity_registry_enabled_by_default: None,
) -> None:
"""Test sensors are unavailable.""" """Test sensors are unavailable."""
await async_mock_config_entry(hass) await async_mock_config_entry(hass)
@ -26,11 +24,8 @@ async def test_sensor_unavailable(
assert state.state == "unavailable" assert state.state == "unavailable"
async def test_sensors_already_home( @pytest.mark.usefixtures("enable_bluetooth", "entity_registry_enabled_by_default")
hass: HomeAssistant, async def test_sensors_already_home(hass: HomeAssistant) -> None:
enable_bluetooth: None,
entity_registry_enabled_by_default: None,
) -> None:
"""Test sensors get value when we start at home.""" """Test sensors get value when we start at home."""
await async_inject_broadcast(hass, MAC_RPA_VALID_1) await async_inject_broadcast(hass, MAC_RPA_VALID_1)
await async_mock_config_entry(hass) await async_mock_config_entry(hass)
@ -40,11 +35,8 @@ async def test_sensors_already_home(
assert state.state == "-63" assert state.state == "-63"
async def test_sensors_come_home( @pytest.mark.usefixtures("enable_bluetooth", "entity_registry_enabled_by_default")
hass: HomeAssistant, async def test_sensors_come_home(hass: HomeAssistant) -> None:
enable_bluetooth: None,
entity_registry_enabled_by_default: None,
) -> None:
"""Test sensors get value when we receive a broadcast.""" """Test sensors get value when we receive a broadcast."""
await async_mock_config_entry(hass) await async_mock_config_entry(hass)
await async_inject_broadcast(hass, MAC_RPA_VALID_1) await async_inject_broadcast(hass, MAC_RPA_VALID_1)
@ -54,11 +46,8 @@ async def test_sensors_come_home(
assert state.state == "-63" assert state.state == "-63"
async def test_estimated_broadcast_interval( @pytest.mark.usefixtures("enable_bluetooth", "entity_registry_enabled_by_default")
hass: HomeAssistant, async def test_estimated_broadcast_interval(hass: HomeAssistant) -> None:
enable_bluetooth: None,
entity_registry_enabled_by_default: None,
) -> None:
"""Test sensors get value when we receive a broadcast.""" """Test sensors get value when we receive a broadcast."""
await async_mock_config_entry(hass) await async_mock_config_entry(hass)
await async_inject_broadcast(hass, MAC_RPA_VALID_1) await async_inject_broadcast(hass, MAC_RPA_VALID_1)