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