Clean up unnecessary registry mocks from Core tests (#87726)
This commit is contained in:
parent
899adef590
commit
51a9f65a01
50 changed files with 882 additions and 1455 deletions
|
@ -7,7 +7,7 @@ from homeassistant.components.device_automation import DeviceAutomationType
|
|||
from homeassistant.components.humidifier import DOMAIN, const, device_action
|
||||
from homeassistant.const import STATE_ON
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import config_validation as cv, device_registry
|
||||
from homeassistant.helpers import config_validation as cv, device_registry as dr
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.helpers.entity_registry import RegistryEntryHider
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
@ -17,24 +17,10 @@ from tests.common import (
|
|||
assert_lists_same,
|
||||
async_get_device_automations,
|
||||
async_mock_service,
|
||||
mock_device_registry,
|
||||
mock_registry,
|
||||
)
|
||||
from tests.components.blueprint.conftest import stub_blueprint_populate # noqa: F401
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def device_reg(hass):
|
||||
"""Return an empty, loaded, registry."""
|
||||
return mock_device_registry(hass)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def entity_reg(hass):
|
||||
"""Return an empty, loaded, registry."""
|
||||
return mock_registry(hass)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"set_state,features_reg,features_state,expected_action_types",
|
||||
[
|
||||
|
@ -46,8 +32,8 @@ def entity_reg(hass):
|
|||
)
|
||||
async def test_get_actions(
|
||||
hass,
|
||||
device_reg,
|
||||
entity_reg,
|
||||
device_registry,
|
||||
entity_registry,
|
||||
set_state,
|
||||
features_reg,
|
||||
features_state,
|
||||
|
@ -56,11 +42,11 @@ async def test_get_actions(
|
|||
"""Test we get the expected actions from a humidifier."""
|
||||
config_entry = MockConfigEntry(domain="test", data={})
|
||||
config_entry.add_to_hass(hass)
|
||||
device_entry = device_reg.async_get_or_create(
|
||||
device_entry = device_registry.async_get_or_create(
|
||||
config_entry_id=config_entry.entry_id,
|
||||
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
||||
connections={(dr.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
||||
)
|
||||
entity_reg.async_get_or_create(
|
||||
entity_registry.async_get_or_create(
|
||||
DOMAIN,
|
||||
"test",
|
||||
"5678",
|
||||
|
@ -110,19 +96,19 @@ async def test_get_actions(
|
|||
)
|
||||
async def test_get_actions_hidden_auxiliary(
|
||||
hass,
|
||||
device_reg,
|
||||
entity_reg,
|
||||
device_registry,
|
||||
entity_registry,
|
||||
hidden_by,
|
||||
entity_category,
|
||||
):
|
||||
"""Test we get the expected actions from a hidden or auxiliary entity."""
|
||||
config_entry = MockConfigEntry(domain="test", data={})
|
||||
config_entry.add_to_hass(hass)
|
||||
device_entry = device_reg.async_get_or_create(
|
||||
device_entry = device_registry.async_get_or_create(
|
||||
config_entry_id=config_entry.entry_id,
|
||||
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
||||
connections={(dr.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
||||
)
|
||||
entity_reg.async_get_or_create(
|
||||
entity_registry.async_get_or_create(
|
||||
DOMAIN,
|
||||
"test",
|
||||
"5678",
|
||||
|
@ -366,8 +352,8 @@ async def test_action(hass: HomeAssistant) -> None:
|
|||
)
|
||||
async def test_capabilities(
|
||||
hass,
|
||||
device_reg,
|
||||
entity_reg,
|
||||
device_registry,
|
||||
entity_registry,
|
||||
set_state,
|
||||
capabilities_reg,
|
||||
capabilities_state,
|
||||
|
@ -377,11 +363,11 @@ async def test_capabilities(
|
|||
"""Test getting capabilities."""
|
||||
config_entry = MockConfigEntry(domain="test", data={})
|
||||
config_entry.add_to_hass(hass)
|
||||
device_entry = device_reg.async_get_or_create(
|
||||
device_entry = device_registry.async_get_or_create(
|
||||
config_entry_id=config_entry.entry_id,
|
||||
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
||||
connections={(dr.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
||||
)
|
||||
entity_reg.async_get_or_create(
|
||||
entity_registry.async_get_or_create(
|
||||
DOMAIN,
|
||||
"test",
|
||||
"5678",
|
||||
|
@ -422,9 +408,7 @@ async def test_capabilities(
|
|||
("set_mode", "mode", {"type": "select", "options": []}),
|
||||
],
|
||||
)
|
||||
async def test_capabilities_missing_entity(
|
||||
hass, device_reg, entity_reg, action, capability_name, extra
|
||||
):
|
||||
async def test_capabilities_missing_entity(hass, action, capability_name, extra):
|
||||
"""Test getting capabilities."""
|
||||
config_entry = MockConfigEntry(domain="test", data={})
|
||||
config_entry.add_to_hass(hass)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue