mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Use standard "entity_registry_enabled_by_default" fixture (#134962)
This commit is contained in:
parent
d155d93462
commit
3a213b2d17
@ -1,7 +1,7 @@
|
||||
"""Test helpers for Freebox."""
|
||||
|
||||
import json
|
||||
from unittest.mock import AsyncMock, PropertyMock, patch
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
from freebox_api.exceptions import HttpRequestError
|
||||
import pytest
|
||||
@ -36,16 +36,6 @@ def mock_path():
|
||||
yield
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def enable_all_entities():
|
||||
"""Make sure all entities are enabled."""
|
||||
with patch(
|
||||
"homeassistant.helpers.entity.Entity.entity_registry_enabled_default",
|
||||
PropertyMock(return_value=True),
|
||||
):
|
||||
yield
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_device_registry_devices(
|
||||
hass: HomeAssistant, device_registry: dr.DeviceRegistry
|
||||
|
@ -4,6 +4,7 @@ from copy import deepcopy
|
||||
from unittest.mock import Mock
|
||||
|
||||
from freezegun.api import FrozenDateTimeFactory
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DOMAIN as BINARY_SENSOR_DOMAIN,
|
||||
@ -45,6 +46,7 @@ async def test_raid_array_degraded(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
async def test_home(
|
||||
hass: HomeAssistant, freezer: FrozenDateTimeFactory, router: Mock
|
||||
) -> None:
|
||||
|
@ -1,6 +1,6 @@
|
||||
"""Test Prusalink sensors."""
|
||||
|
||||
from unittest.mock import PropertyMock, patch
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
@ -12,16 +12,13 @@ from homeassistant.setup import async_setup_component
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup_binary_sensor_platform_only():
|
||||
"""Only setup sensor platform."""
|
||||
with (
|
||||
patch("homeassistant.components.prusalink.PLATFORMS", [Platform.BINARY_SENSOR]),
|
||||
patch(
|
||||
"homeassistant.helpers.entity.Entity.entity_registry_enabled_default",
|
||||
PropertyMock(return_value=True),
|
||||
),
|
||||
with patch(
|
||||
"homeassistant.components.prusalink.PLATFORMS", [Platform.BINARY_SENSOR]
|
||||
):
|
||||
yield
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
async def test_binary_sensors_no_job(
|
||||
hass: HomeAssistant, mock_config_entry, mock_api
|
||||
) -> None:
|
||||
|
@ -1,7 +1,7 @@
|
||||
"""Test Prusalink sensors."""
|
||||
|
||||
from datetime import UTC, datetime
|
||||
from unittest.mock import PropertyMock, patch
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
@ -27,16 +27,11 @@ from homeassistant.setup import async_setup_component
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup_sensor_platform_only():
|
||||
"""Only setup sensor platform."""
|
||||
with (
|
||||
patch("homeassistant.components.prusalink.PLATFORMS", [Platform.SENSOR]),
|
||||
patch(
|
||||
"homeassistant.helpers.entity.Entity.entity_registry_enabled_default",
|
||||
PropertyMock(return_value=True),
|
||||
),
|
||||
):
|
||||
with patch("homeassistant.components.prusalink.PLATFORMS", [Platform.SENSOR]):
|
||||
yield
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
async def test_sensors_no_job(hass: HomeAssistant, mock_config_entry, mock_api) -> None:
|
||||
"""Test sensors while no job active."""
|
||||
assert await async_setup_component(hass, "prusalink", {})
|
||||
@ -140,6 +135,7 @@ async def test_sensors_no_job(hass: HomeAssistant, mock_config_entry, mock_api)
|
||||
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == REVOLUTIONS_PER_MINUTE
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
async def test_sensors_idle_job_mk3(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry,
|
||||
@ -248,6 +244,7 @@ async def test_sensors_idle_job_mk3(
|
||||
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == REVOLUTIONS_PER_MINUTE
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
async def test_sensors_active_job(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry,
|
||||
|
@ -7,7 +7,7 @@ import copy
|
||||
from datetime import datetime
|
||||
import socket
|
||||
from typing import Any
|
||||
from unittest.mock import AsyncMock, MagicMock, PropertyMock, create_autospec, patch
|
||||
from unittest.mock import AsyncMock, MagicMock, create_autospec, patch
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from async_upnp_client.aiohttp import AiohttpNotifyServer
|
||||
@ -286,11 +286,8 @@ async def mock_config_entry(
|
||||
|
||||
# Load config_entry.
|
||||
entry.add_to_hass(hass)
|
||||
with patch(
|
||||
"homeassistant.helpers.entity.Entity.entity_registry_enabled_default",
|
||||
PropertyMock(return_value=True),
|
||||
):
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
return entry
|
||||
|
@ -3,6 +3,7 @@
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from async_upnp_client.profiles.igd import IgdDevice, IgdState
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.upnp.const import DEFAULT_SCAN_INTERVAL
|
||||
from homeassistant.core import HomeAssistant
|
||||
@ -11,6 +12,7 @@ import homeassistant.util.dt as dt_util
|
||||
from tests.common import MockConfigEntry, async_fire_time_changed
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
async def test_upnp_sensors(
|
||||
hass: HomeAssistant, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user