Move entity_registry_enabled_by_default to decorator [q-z] (#118793)

This commit is contained in:
epenet 2024-06-04 13:38:32 +02:00 committed by GitHub
parent 3ac0fa53c8
commit 20b5aa3e0e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 71 additions and 61 deletions

View file

@ -1,5 +1,7 @@
"""The binary sensor tests for the QNAP QSW platform.""" """The binary sensor tests for the QNAP QSW platform."""
import pytest
from homeassistant.components.qnap_qsw.const import ATTR_MESSAGE from homeassistant.components.qnap_qsw.const import ATTR_MESSAGE
from homeassistant.const import STATE_OFF, STATE_ON from homeassistant.const import STATE_OFF, STATE_ON
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -8,9 +10,9 @@ from homeassistant.helpers import entity_registry as er
from .util import async_init_integration from .util import async_init_integration
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_qnap_qsw_create_binary_sensors( async def test_qnap_qsw_create_binary_sensors(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
entity_registry: er.EntityRegistry, entity_registry: er.EntityRegistry,
) -> None: ) -> None:
"""Test creation of binary sensors.""" """Test creation of binary sensors."""

View file

@ -1,14 +1,16 @@
"""The sensor tests for the QNAP QSW platform.""" """The sensor tests for the QNAP QSW platform."""
import pytest
from homeassistant.components.qnap_qsw.const import ATTR_MAX from homeassistant.components.qnap_qsw.const import ATTR_MAX
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from .util import async_init_integration from .util import async_init_integration
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_qnap_qsw_create_sensors( async def test_qnap_qsw_create_sensors(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
) -> None: ) -> None:
"""Test creation of sensors.""" """Test creation of sensors."""

View file

@ -52,10 +52,10 @@ 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,
windows: bool, windows: bool,
single: bool, single: bool,
root_folder: str, root_folder: str,

View file

@ -15,9 +15,9 @@ from homeassistant.util import dt as dt_util
from tests.common import async_fire_time_changed from tests.common import async_fire_time_changed
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_binary_sensor( async def test_binary_sensor(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
load_int: ConfigEntry, load_int: ConfigEntry,
monkeypatch: pytest.MonkeyPatch, monkeypatch: pytest.MonkeyPatch,
get_data: SensiboData, get_data: SensiboData,

View file

@ -832,9 +832,9 @@ async def test_climate_no_fan_no_swing(
assert state.attributes["swing_modes"] is None assert state.attributes["swing_modes"] is None
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_climate_set_timer( async def test_climate_set_timer(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
load_int: ConfigEntry, load_int: ConfigEntry,
monkeypatch: pytest.MonkeyPatch, monkeypatch: pytest.MonkeyPatch,
get_data: SensiboData, get_data: SensiboData,
@ -947,9 +947,9 @@ async def test_climate_set_timer(
) )
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_climate_pure_boost( async def test_climate_pure_boost(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
load_int: ConfigEntry, load_int: ConfigEntry,
monkeypatch: pytest.MonkeyPatch, monkeypatch: pytest.MonkeyPatch,
get_data: SensiboData, get_data: SensiboData,
@ -1058,9 +1058,9 @@ async def test_climate_pure_boost(
assert state4.state == "s" assert state4.state == "s"
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_climate_climate_react( async def test_climate_climate_react(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
load_int: ConfigEntry, load_int: ConfigEntry,
monkeypatch: pytest.MonkeyPatch, monkeypatch: pytest.MonkeyPatch,
get_data: SensiboData, get_data: SensiboData,
@ -1228,9 +1228,9 @@ async def test_climate_climate_react(
assert state4.state == "temperature" assert state4.state == "temperature"
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_climate_climate_react_fahrenheit( async def test_climate_climate_react_fahrenheit(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
load_int: ConfigEntry, load_int: ConfigEntry,
monkeypatch: pytest.MonkeyPatch, monkeypatch: pytest.MonkeyPatch,
get_data: SensiboData, get_data: SensiboData,
@ -1374,9 +1374,9 @@ async def test_climate_climate_react_fahrenheit(
assert state4.state == "temperature" assert state4.state == "temperature"
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_climate_full_ac_state( async def test_climate_full_ac_state(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
load_int: ConfigEntry, load_int: ConfigEntry,
monkeypatch: pytest.MonkeyPatch, monkeypatch: pytest.MonkeyPatch,
get_data: SensiboData, get_data: SensiboData,

View file

@ -22,9 +22,9 @@ from homeassistant.util import dt as dt_util
from tests.common import async_fire_time_changed from tests.common import async_fire_time_changed
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_number( async def test_number(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
load_int: ConfigEntry, load_int: ConfigEntry,
monkeypatch: pytest.MonkeyPatch, monkeypatch: pytest.MonkeyPatch,
get_data: SensiboData, get_data: SensiboData,
@ -52,9 +52,9 @@ async def test_number(
assert state1.state == "0.2" assert state1.state == "0.2"
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_number_set_value( async def test_number_set_value(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
load_int: ConfigEntry, load_int: ConfigEntry,
get_data: SensiboData, get_data: SensiboData,
) -> None: ) -> None:

View file

@ -16,9 +16,9 @@ from homeassistant.util import dt as dt_util
from tests.common import async_fire_time_changed from tests.common import async_fire_time_changed
@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,
load_int: ConfigEntry, load_int: ConfigEntry,
monkeypatch: pytest.MonkeyPatch, monkeypatch: pytest.MonkeyPatch,
get_data: SensiboData, get_data: SensiboData,

View file

@ -355,11 +355,11 @@ async def test_rpc_sensor(
assert hass.states.get(entity_id).state == STATE_UNKNOWN assert hass.states.get(entity_id).state == STATE_UNKNOWN
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_rpc_rssi_sensor_removal( async def test_rpc_rssi_sensor_removal(
hass: HomeAssistant, hass: HomeAssistant,
mock_rpc_device: Mock, mock_rpc_device: Mock,
monkeypatch: pytest.MonkeyPatch, monkeypatch: pytest.MonkeyPatch,
entity_registry_enabled_by_default: None,
) -> None: ) -> None:
"""Test RPC RSSI sensor removal if no WiFi stations enabled.""" """Test RPC RSSI sensor removal if no WiFi stations enabled."""
entity_id = f"{SENSOR_DOMAIN}.test_name_rssi" entity_id = f"{SENSOR_DOMAIN}.test_name_rssi"
@ -548,9 +548,8 @@ async def test_rpc_restored_sleeping_sensor_no_last_state(
assert hass.states.get(entity_id).state == "22.9" assert hass.states.get(entity_id).state == "22.9"
async def test_rpc_em1_sensors( @pytest.mark.usefixtures("entity_registry_enabled_by_default")
hass: HomeAssistant, mock_rpc_device: Mock, entity_registry_enabled_by_default: None async def test_rpc_em1_sensors(hass: HomeAssistant, mock_rpc_device: Mock) -> None:
) -> None:
"""Test RPC sensors for EM1 component.""" """Test RPC sensors for EM1 component."""
registry = async_get(hass) registry = async_get(hass)
await init_integration(hass, 2) await init_integration(hass, 2)

View file

@ -472,10 +472,10 @@ async def test_wall_display_relay_mode(
assert entry.unique_id == "123456789ABC-switch:0" assert entry.unique_id == "123456789ABC-switch:0"
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_create_issue_valve_switch( async def test_create_issue_valve_switch(
hass: HomeAssistant, hass: HomeAssistant,
mock_block_device: Mock, mock_block_device: Mock,
entity_registry_enabled_by_default: None,
monkeypatch: pytest.MonkeyPatch, monkeypatch: pytest.MonkeyPatch,
issue_registry: ir.IssueRegistry, issue_registry: ir.IssueRegistry,
) -> None: ) -> None:

View file

@ -44,13 +44,13 @@ from . import (
from tests.common import mock_restore_cache from tests.common import mock_restore_cache
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_block_update( async def test_block_update(
hass: HomeAssistant, hass: HomeAssistant,
freezer: FrozenDateTimeFactory, freezer: FrozenDateTimeFactory,
mock_block_device: Mock, mock_block_device: Mock,
entity_registry: EntityRegistry, entity_registry: EntityRegistry,
monkeypatch: pytest.MonkeyPatch, monkeypatch: pytest.MonkeyPatch,
entity_registry_enabled_by_default: None,
) -> None: ) -> None:
"""Test block device update entity.""" """Test block device update entity."""
entity_id = "update.test_name_firmware_update" entity_id = "update.test_name_firmware_update"
@ -96,13 +96,13 @@ async def test_block_update(
assert entry.unique_id == "123456789ABC-fwupdate" assert entry.unique_id == "123456789ABC-fwupdate"
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_block_beta_update( async def test_block_beta_update(
hass: HomeAssistant, hass: HomeAssistant,
freezer: FrozenDateTimeFactory, freezer: FrozenDateTimeFactory,
mock_block_device: Mock, mock_block_device: Mock,
entity_registry: EntityRegistry, entity_registry: EntityRegistry,
monkeypatch: pytest.MonkeyPatch, monkeypatch: pytest.MonkeyPatch,
entity_registry_enabled_by_default: None,
) -> None: ) -> None:
"""Test block device beta update entity.""" """Test block device beta update entity."""
entity_id = "update.test_name_beta_firmware_update" entity_id = "update.test_name_beta_firmware_update"
@ -156,12 +156,12 @@ async def test_block_beta_update(
assert entry.unique_id == "123456789ABC-fwupdate_beta" assert entry.unique_id == "123456789ABC-fwupdate_beta"
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_block_update_connection_error( async def test_block_update_connection_error(
hass: HomeAssistant, hass: HomeAssistant,
mock_block_device: Mock, mock_block_device: Mock,
monkeypatch: pytest.MonkeyPatch, monkeypatch: pytest.MonkeyPatch,
caplog: pytest.LogCaptureFixture, caplog: pytest.LogCaptureFixture,
entity_registry_enabled_by_default: None,
) -> None: ) -> None:
"""Test block device update connection error.""" """Test block device update connection error."""
monkeypatch.setitem(mock_block_device.status["update"], "old_version", "1") monkeypatch.setitem(mock_block_device.status["update"], "old_version", "1")
@ -183,11 +183,11 @@ async def test_block_update_connection_error(
assert "Error starting OTA update" in caplog.text assert "Error starting OTA update" in caplog.text
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_block_update_auth_error( async def test_block_update_auth_error(
hass: HomeAssistant, hass: HomeAssistant,
mock_block_device: Mock, mock_block_device: Mock,
monkeypatch: pytest.MonkeyPatch, monkeypatch: pytest.MonkeyPatch,
entity_registry_enabled_by_default: None,
) -> None: ) -> None:
"""Test block device update authentication error.""" """Test block device update authentication error."""
monkeypatch.setitem(mock_block_device.status["update"], "old_version", "1") monkeypatch.setitem(mock_block_device.status["update"], "old_version", "1")
@ -475,13 +475,13 @@ async def test_rpc_restored_sleeping_update_no_last_state(
assert state.attributes[ATTR_SUPPORTED_FEATURES] == UpdateEntityFeature(0) assert state.attributes[ATTR_SUPPORTED_FEATURES] == UpdateEntityFeature(0)
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_rpc_beta_update( async def test_rpc_beta_update(
hass: HomeAssistant, hass: HomeAssistant,
freezer: FrozenDateTimeFactory, freezer: FrozenDateTimeFactory,
mock_rpc_device: Mock, mock_rpc_device: Mock,
entity_registry: EntityRegistry, entity_registry: EntityRegistry,
monkeypatch: pytest.MonkeyPatch, monkeypatch: pytest.MonkeyPatch,
entity_registry_enabled_by_default: None,
) -> None: ) -> None:
"""Test RPC device beta update entity.""" """Test RPC device beta update entity."""
entity_id = "update.test_name_beta_firmware_update" entity_id = "update.test_name_beta_firmware_update"
@ -601,6 +601,7 @@ async def test_rpc_beta_update(
(RpcCallError(-1, "error"), "OTA update request error"), (RpcCallError(-1, "error"), "OTA update request error"),
], ],
) )
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_rpc_update_errors( async def test_rpc_update_errors(
hass: HomeAssistant, hass: HomeAssistant,
exc: Exception, exc: Exception,
@ -608,7 +609,6 @@ async def test_rpc_update_errors(
mock_rpc_device: Mock, mock_rpc_device: Mock,
monkeypatch: pytest.MonkeyPatch, monkeypatch: pytest.MonkeyPatch,
caplog: pytest.LogCaptureFixture, caplog: pytest.LogCaptureFixture,
entity_registry_enabled_by_default: None,
) -> None: ) -> None:
"""Test RPC device update connection/call errors.""" """Test RPC device update connection/call errors."""
monkeypatch.setitem(mock_rpc_device.shelly, "ver", "1") monkeypatch.setitem(mock_rpc_device.shelly, "ver", "1")
@ -635,12 +635,12 @@ async def test_rpc_update_errors(
assert error in caplog.text assert error in caplog.text
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_rpc_update_auth_error( async def test_rpc_update_auth_error(
hass: HomeAssistant, hass: HomeAssistant,
mock_rpc_device: Mock, mock_rpc_device: Mock,
entity_registry: EntityRegistry, entity_registry: EntityRegistry,
monkeypatch: pytest.MonkeyPatch, monkeypatch: pytest.MonkeyPatch,
entity_registry_enabled_by_default: None,
) -> None: ) -> None:
"""Test RPC device update authentication error.""" """Test RPC device update authentication error."""
monkeypatch.setitem(mock_rpc_device.shelly, "ver", "1") monkeypatch.setitem(mock_rpc_device.shelly, "ver", "1")

View file

@ -21,7 +21,7 @@ API_KEY = "a1b2c3d4e5f6g7h8"
@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

@ -22,12 +22,12 @@ from tests.common import MockConfigEntry, async_fire_time_changed
UPCOMING_ENTITY_ID = f"{SENSOR_DOMAIN}.sonarr_upcoming" UPCOMING_ENTITY_ID = f"{SENSOR_DOMAIN}.sonarr_upcoming"
@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,
mock_config_entry: MockConfigEntry, mock_config_entry: MockConfigEntry,
mock_sonarr: MagicMock, mock_sonarr: MagicMock,
entity_registry_enabled_by_default: None,
) -> None: ) -> None:
"""Test the creation and values of the sensors.""" """Test the creation and values of the sensors."""
sensors = { sensors = {

View file

@ -15,11 +15,11 @@ from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_setting_rising( async def test_setting_rising(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry: er.EntityRegistry, entity_registry: er.EntityRegistry,
freezer: FrozenDateTimeFactory, freezer: FrozenDateTimeFactory,
entity_registry_enabled_by_default: None,
) -> None: ) -> None:
"""Test retrieving sun setting and rising.""" """Test retrieving sun setting and rising."""
utc_now = datetime(2016, 11, 1, 8, 0, 0, tzinfo=dt_util.UTC) utc_now = datetime(2016, 11, 1, 8, 0, 0, tzinfo=dt_util.UTC)

View file

@ -1,5 +1,7 @@
"""Test the switchbot sensors.""" """Test the switchbot sensors."""
import pytest
from homeassistant.components.sensor import ATTR_STATE_CLASS from homeassistant.components.sensor import ATTR_STATE_CLASS
from homeassistant.components.switchbot.const import DOMAIN from homeassistant.components.switchbot.const import DOMAIN
from homeassistant.const import ( from homeassistant.const import (
@ -19,9 +21,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( @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."""
await async_setup_component(hass, DOMAIN, {}) await async_setup_component(hass, DOMAIN, {})
inject_bluetooth_service_info(hass, WOHAND_SERVICE_INFO) inject_bluetooth_service_info(hass, WOHAND_SERVICE_INFO)

View file

@ -20,9 +20,9 @@ from .conftest import MockProcess
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_binary_sensor( async def test_binary_sensor(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
mock_psutil: Mock, mock_psutil: Mock,
mock_os: Mock, mock_os: Mock,
entity_registry: er.EntityRegistry, entity_registry: er.EntityRegistry,
@ -62,9 +62,9 @@ async def test_binary_sensor(
assert state.attributes == snapshot(name=f"{state.name} - attributes") assert state.attributes == snapshot(name=f"{state.name} - attributes")
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_binary_sensor_icon( async def test_binary_sensor_icon(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
mock_psutil: Mock, mock_psutil: Mock,
mock_os: Mock, mock_os: Mock,
mock_config_entry: MockConfigEntry, mock_config_entry: MockConfigEntry,

View file

@ -5,6 +5,7 @@ from __future__ import annotations
from http import HTTPStatus from http import HTTPStatus
from unittest.mock import Mock from unittest.mock import Mock
import pytest
from syrupy.assertion import SnapshotAssertion from syrupy.assertion import SnapshotAssertion
from homeassistant.components.repairs.websocket_api import ( from homeassistant.components.repairs.websocket_api import (
@ -22,10 +23,10 @@ from tests.common import ANY, MockConfigEntry
from tests.typing import ClientSessionGenerator, WebSocketGenerator from tests.typing import ClientSessionGenerator, WebSocketGenerator
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_migrate_process_sensor( async def test_migrate_process_sensor(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry: er.EntityRegistry, entity_registry: er.EntityRegistry,
entity_registry_enabled_by_default: None,
mock_psutil: Mock, mock_psutil: Mock,
mock_os: Mock, mock_os: Mock,
hass_client: ClientSessionGenerator, hass_client: ClientSessionGenerator,
@ -120,11 +121,11 @@ async def test_migrate_process_sensor(
assert hass.config_entries.async_entries(DOMAIN) == snapshot(name="after_migration") assert hass.config_entries.async_entries(DOMAIN) == snapshot(name="after_migration")
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_other_fixable_issues( async def test_other_fixable_issues(
hass: HomeAssistant, hass: HomeAssistant,
hass_client: ClientSessionGenerator, hass_client: ClientSessionGenerator,
hass_ws_client: WebSocketGenerator, hass_ws_client: WebSocketGenerator,
entity_registry_enabled_by_default: None,
mock_added_config_entry: ConfigEntry, mock_added_config_entry: ConfigEntry,
) -> None: ) -> None:
"""Test fixing other issues.""" """Test fixing other issues."""

View file

@ -24,9 +24,9 @@ from .conftest import MockProcess
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,
entity_registry_enabled_by_default: None,
mock_psutil: Mock, mock_psutil: Mock,
mock_os: Mock, mock_os: Mock,
entity_registry: er.EntityRegistry, entity_registry: er.EntityRegistry,
@ -76,9 +76,9 @@ async def test_sensor(
assert state.attributes == snapshot(name=f"{state.name} - attributes") assert state.attributes == snapshot(name=f"{state.name} - attributes")
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_process_sensor_not_loaded( async def test_process_sensor_not_loaded(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
mock_psutil: Mock, mock_psutil: Mock,
mock_os: Mock, mock_os: Mock,
entity_registry: er.EntityRegistry, entity_registry: er.EntityRegistry,
@ -108,9 +108,9 @@ async def test_process_sensor_not_loaded(
assert process_sensor is None assert process_sensor is None
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_sensor_not_loading_veth_networks( async def test_sensor_not_loading_veth_networks(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
mock_added_config_entry: ConfigEntry, mock_added_config_entry: ConfigEntry,
) -> None: ) -> None:
"""Test the sensor.""" """Test the sensor."""
@ -123,9 +123,9 @@ async def test_sensor_not_loading_veth_networks(
assert network_sensor_2 is None assert network_sensor_2 is None
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_sensor_icon( async def test_sensor_icon(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
mock_psutil: Mock, mock_psutil: Mock,
mock_os: Mock, mock_os: Mock,
mock_config_entry: MockConfigEntry, mock_config_entry: MockConfigEntry,
@ -142,9 +142,9 @@ async def test_sensor_icon(
assert get_cpu_icon() == "mdi:cpu-64-bit" assert get_cpu_icon() == "mdi:cpu-64-bit"
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_sensor_yaml( async def test_sensor_yaml(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
mock_psutil: Mock, mock_psutil: Mock,
mock_os: Mock, mock_os: Mock,
) -> None: ) -> None:
@ -172,10 +172,10 @@ async def test_sensor_yaml(
assert process_sensor.state == STATE_ON assert process_sensor.state == STATE_ON
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_sensor_yaml_fails_missing_argument( async def test_sensor_yaml_fails_missing_argument(
caplog: pytest.LogCaptureFixture, caplog: pytest.LogCaptureFixture,
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
mock_psutil: Mock, mock_psutil: Mock,
mock_os: Mock, mock_os: Mock,
) -> None: ) -> None:
@ -302,10 +302,10 @@ async def test_sensor_process_fails(
assert "Failed to load process with ID: 1, old name: python3" in caplog.text assert "Failed to load process with ID: 1, old name: python3" in caplog.text
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_sensor_network_sensors( async def test_sensor_network_sensors(
freezer: FrozenDateTimeFactory, freezer: FrozenDateTimeFactory,
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
mock_added_config_entry: ConfigEntry, mock_added_config_entry: ConfigEntry,
mock_psutil: Mock, mock_psutil: Mock,
) -> None: ) -> None:
@ -378,9 +378,9 @@ async def test_sensor_network_sensors(
assert throughput_network_out_sensor.state == STATE_UNKNOWN assert throughput_network_out_sensor.state == STATE_UNKNOWN
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_missing_cpu_temperature( async def test_missing_cpu_temperature(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
mock_psutil: Mock, mock_psutil: Mock,
mock_os: Mock, mock_os: Mock,
mock_config_entry: MockConfigEntry, mock_config_entry: MockConfigEntry,
@ -402,9 +402,9 @@ async def test_missing_cpu_temperature(
assert temp_sensor is None assert temp_sensor is None
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_processor_temperature( async def test_processor_temperature(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
mock_psutil: Mock, mock_psutil: Mock,
mock_os: Mock, mock_os: Mock,
mock_config_entry: MockConfigEntry, mock_config_entry: MockConfigEntry,
@ -452,9 +452,9 @@ async def test_processor_temperature(
await hass.async_block_till_done() await hass.async_block_till_done()
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_exception_handling_disk_sensor( async def test_exception_handling_disk_sensor(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
mock_psutil: Mock, mock_psutil: Mock,
mock_added_config_entry: ConfigEntry, mock_added_config_entry: ConfigEntry,
caplog: pytest.LogCaptureFixture, caplog: pytest.LogCaptureFixture,
@ -511,9 +511,9 @@ async def test_exception_handling_disk_sensor(
assert disk_sensor.attributes["unit_of_measurement"] == "%" assert disk_sensor.attributes["unit_of_measurement"] == "%"
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_cpu_percentage_is_zero_returns_unknown( async def test_cpu_percentage_is_zero_returns_unknown(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
mock_psutil: Mock, mock_psutil: Mock,
mock_added_config_entry: ConfigEntry, mock_added_config_entry: ConfigEntry,
caplog: pytest.LogCaptureFixture, caplog: pytest.LogCaptureFixture,

View file

@ -17,9 +17,9 @@ from tests.common import MockConfigEntry
(OSError("OS error"), "was excluded because of: OS error"), (OSError("OS error"), "was excluded because of: OS error"),
], ],
) )
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_disk_setup_failure( async def test_disk_setup_failure(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
mock_psutil: Mock, mock_psutil: Mock,
mock_os: Mock, mock_os: Mock,
mock_config_entry: MockConfigEntry, mock_config_entry: MockConfigEntry,
@ -40,9 +40,9 @@ async def test_disk_setup_failure(
assert error_text in caplog.text assert error_text in caplog.text
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_disk_util( async def test_disk_util(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
mock_psutil: Mock, mock_psutil: Mock,
mock_os: Mock, mock_os: Mock,
mock_config_entry: MockConfigEntry, mock_config_entry: MockConfigEntry,

View file

@ -2,6 +2,7 @@
from __future__ import annotations from __future__ import annotations
import pytest
from pytrafikverket.trafikverket_camera import CameraInfo from pytrafikverket.trafikverket_camera import CameraInfo
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
@ -9,9 +10,9 @@ from homeassistant.const import STATE_ON
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@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,
load_int: ConfigEntry, load_int: ConfigEntry,
get_camera: CameraInfo, get_camera: CameraInfo,
) -> None: ) -> None:

View file

@ -15,9 +15,9 @@ from tests.components.recorder.common import async_wait_recording_done
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_exclude_attributes( async def test_exclude_attributes(
recorder_mock: Recorder, recorder_mock: Recorder,
entity_registry_enabled_by_default: None,
hass: HomeAssistant, hass: HomeAssistant,
load_int: ConfigEntry, load_int: ConfigEntry,
monkeypatch: pytest.MonkeyPatch, monkeypatch: pytest.MonkeyPatch,

View file

@ -2,15 +2,16 @@
from __future__ import annotations from __future__ import annotations
import pytest
from pytrafikverket.trafikverket_camera import CameraInfo from pytrafikverket.trafikverket_camera import CameraInfo
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@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,
load_int: ConfigEntry, load_int: ConfigEntry,
get_camera: CameraInfo, get_camera: CameraInfo,
) -> None: ) -> None:

View file

@ -22,9 +22,9 @@ from . import ENTRY_CONFIG
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_coordinator( async def test_coordinator(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry_enabled_by_default: None,
freezer: FrozenDateTimeFactory, freezer: FrozenDateTimeFactory,
monkeypatch: pytest.MonkeyPatch, monkeypatch: pytest.MonkeyPatch,
get_ferries: list[FerryStop], get_ferries: list[FerryStop],

View file

@ -6,6 +6,7 @@ from datetime import timedelta
from unittest.mock import patch from unittest.mock import patch
from freezegun.api import FrozenDateTimeFactory from freezegun.api import FrozenDateTimeFactory
import pytest
from pytrafikverket.exceptions import InvalidAuthentication, NoTrainAnnouncementFound from pytrafikverket.exceptions import InvalidAuthentication, NoTrainAnnouncementFound
from pytrafikverket.trafikverket_train import TrainStop from pytrafikverket.trafikverket_train import TrainStop
from syrupy.assertion import SnapshotAssertion from syrupy.assertion import SnapshotAssertion
@ -17,10 +18,10 @@ from homeassistant.core import HomeAssistant
from tests.common import async_fire_time_changed from tests.common import async_fire_time_changed
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_sensor_next( async def test_sensor_next(
hass: HomeAssistant, hass: HomeAssistant,
freezer: FrozenDateTimeFactory, freezer: FrozenDateTimeFactory,
entity_registry_enabled_by_default: None,
load_int: ConfigEntry, load_int: ConfigEntry,
get_trains_next: list[TrainStop], get_trains_next: list[TrainStop],
get_train_stop: TrainStop, get_train_stop: TrainStop,
@ -64,10 +65,10 @@ async def test_sensor_next(
assert state == snapshot assert state == snapshot
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_sensor_single_stop( async def test_sensor_single_stop(
hass: HomeAssistant, hass: HomeAssistant,
freezer: FrozenDateTimeFactory, freezer: FrozenDateTimeFactory,
entity_registry_enabled_by_default: None,
load_int: ConfigEntry, load_int: ConfigEntry,
get_trains_next: list[TrainStop], get_trains_next: list[TrainStop],
snapshot: SnapshotAssertion, snapshot: SnapshotAssertion,
@ -80,10 +81,10 @@ async def test_sensor_single_stop(
assert state == snapshot assert state == snapshot
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_sensor_update_auth_failure( async def test_sensor_update_auth_failure(
hass: HomeAssistant, hass: HomeAssistant,
freezer: FrozenDateTimeFactory, freezer: FrozenDateTimeFactory,
entity_registry_enabled_by_default: None,
load_int: ConfigEntry, load_int: ConfigEntry,
get_trains_next: list[TrainStop], get_trains_next: list[TrainStop],
snapshot: SnapshotAssertion, snapshot: SnapshotAssertion,
@ -113,10 +114,10 @@ async def test_sensor_update_auth_failure(
assert flow == snapshot assert flow == snapshot
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_sensor_update_failure( async def test_sensor_update_failure(
hass: HomeAssistant, hass: HomeAssistant,
freezer: FrozenDateTimeFactory, freezer: FrozenDateTimeFactory,
entity_registry_enabled_by_default: None,
load_int: ConfigEntry, load_int: ConfigEntry,
get_trains_next: list[TrainStop], get_trains_next: list[TrainStop],
snapshot: SnapshotAssertion, snapshot: SnapshotAssertion,
@ -143,10 +144,10 @@ async def test_sensor_update_failure(
assert state.state == STATE_UNAVAILABLE assert state.state == STATE_UNAVAILABLE
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_sensor_update_failure_no_state( async def test_sensor_update_failure_no_state(
hass: HomeAssistant, hass: HomeAssistant,
freezer: FrozenDateTimeFactory, freezer: FrozenDateTimeFactory,
entity_registry_enabled_by_default: None,
load_int: ConfigEntry, load_int: ConfigEntry,
get_trains_next: list[TrainStop], get_trains_next: list[TrainStop],
snapshot: SnapshotAssertion, snapshot: SnapshotAssertion,

View file

@ -458,13 +458,13 @@ async def test_bandwidth_sensors(
(60, 64, 60), (60, 64, 60),
], ],
) )
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_uptime_sensors( async def test_uptime_sensors(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry: er.EntityRegistry, entity_registry: er.EntityRegistry,
aioclient_mock: AiohttpClientMocker, aioclient_mock: AiohttpClientMocker,
freezer: FrozenDateTimeFactory, freezer: FrozenDateTimeFactory,
mock_unifi_websocket, mock_unifi_websocket,
entity_registry_enabled_by_default: None,
initial_uptime, initial_uptime,
event_uptime, event_uptime,
new_uptime, new_uptime,
@ -545,11 +545,11 @@ async def test_uptime_sensors(
assert hass.states.get("sensor.client1_uptime") assert hass.states.get("sensor.client1_uptime")
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_remove_sensors( async def test_remove_sensors(
hass: HomeAssistant, hass: HomeAssistant,
aioclient_mock: AiohttpClientMocker, aioclient_mock: AiohttpClientMocker,
mock_unifi_websocket, mock_unifi_websocket,
entity_registry_enabled_by_default: None,
) -> None: ) -> None:
"""Verify removing of clients work as expected.""" """Verify removing of clients work as expected."""
wired_client = { wired_client = {

View file

@ -5,6 +5,7 @@ from __future__ import annotations
from datetime import datetime, timedelta from datetime import datetime, timedelta
from unittest.mock import Mock from unittest.mock import Mock
import pytest
from pyunifiprotect.data import ( from pyunifiprotect.data import (
NVR, NVR,
Camera, Camera,
@ -399,10 +400,10 @@ async def test_sensor_setup_camera(
assert state.attributes[ATTR_ATTRIBUTION] == DEFAULT_ATTRIBUTION assert state.attributes[ATTR_ATTRIBUTION] == DEFAULT_ATTRIBUTION
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_sensor_setup_camera_with_last_trip_time( async def test_sensor_setup_camera_with_last_trip_time(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry: er.EntityRegistry, entity_registry: er.EntityRegistry,
entity_registry_enabled_by_default: None,
ufp: MockUFPFixture, ufp: MockUFPFixture,
doorbell: Camera, doorbell: Camera,
fixed_now: datetime, fixed_now: datetime,
@ -474,10 +475,10 @@ async def test_sensor_update_alarm(
await time_changed(hass, 10) await time_changed(hass, 10)
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_sensor_update_alarm_with_last_trip_time( async def test_sensor_update_alarm_with_last_trip_time(
hass: HomeAssistant, hass: HomeAssistant,
entity_registry: er.EntityRegistry, entity_registry: er.EntityRegistry,
entity_registry_enabled_by_default: None,
ufp: MockUFPFixture, ufp: MockUFPFixture,
sensor_all: Sensor, sensor_all: Sensor,
fixed_now: datetime, fixed_now: datetime,

View file

@ -2,6 +2,7 @@
from unittest.mock import AsyncMock, patch from unittest.mock import AsyncMock, patch
import pytest
from syrupy import SnapshotAssertion from syrupy import SnapshotAssertion
from homeassistant.const import Platform from homeassistant.const import Platform
@ -13,13 +14,13 @@ from . import init_integration
from tests.common import MockConfigEntry, snapshot_platform from tests.common import MockConfigEntry, snapshot_platform
@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_v2c_client: AsyncMock, mock_v2c_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.v2c.PLATFORMS", [Platform.SENSOR]): with patch("homeassistant.components.v2c.PLATFORMS", [Platform.SENSOR]):