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
|
@ -13,7 +13,7 @@ from homeassistant.const import (
|
|||
STATE_OPEN,
|
||||
STATE_OPENING,
|
||||
)
|
||||
from homeassistant.helpers import device_registry
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.helpers.entity_registry import RegistryEntryHider
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
@ -26,24 +26,10 @@ from tests.common import (
|
|||
async_get_device_automation_capabilities,
|
||||
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.fixture
|
||||
def calls(hass):
|
||||
"""Track calls to a mock service."""
|
||||
|
@ -83,8 +69,8 @@ def calls(hass):
|
|||
)
|
||||
async def test_get_triggers(
|
||||
hass,
|
||||
device_reg,
|
||||
entity_reg,
|
||||
device_registry,
|
||||
entity_registry,
|
||||
set_state,
|
||||
features_reg,
|
||||
features_state,
|
||||
|
@ -93,11 +79,11 @@ async def test_get_triggers(
|
|||
"""Test we get the expected triggers from a cover."""
|
||||
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",
|
||||
|
@ -141,19 +127,19 @@ async def test_get_triggers(
|
|||
)
|
||||
async def test_get_triggers_hidden_auxiliary(
|
||||
hass,
|
||||
device_reg,
|
||||
entity_reg,
|
||||
device_registry,
|
||||
entity_registry,
|
||||
hidden_by,
|
||||
entity_category,
|
||||
):
|
||||
"""Test we get the expected triggers 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",
|
||||
|
@ -180,7 +166,7 @@ async def test_get_triggers_hidden_auxiliary(
|
|||
|
||||
|
||||
async def test_get_trigger_capabilities(
|
||||
hass, device_reg, entity_reg, enable_custom_integrations
|
||||
hass, device_registry, entity_registry, enable_custom_integrations
|
||||
):
|
||||
"""Test we get the expected capabilities from a cover trigger."""
|
||||
platform = getattr(hass.components, f"test.{DOMAIN}")
|
||||
|
@ -191,11 +177,11 @@ async def test_get_trigger_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", ent.unique_id, device_id=device_entry.id
|
||||
)
|
||||
|
||||
|
@ -215,7 +201,7 @@ async def test_get_trigger_capabilities(
|
|||
|
||||
|
||||
async def test_get_trigger_capabilities_set_pos(
|
||||
hass, device_reg, entity_reg, enable_custom_integrations
|
||||
hass, device_registry, entity_registry, enable_custom_integrations
|
||||
):
|
||||
"""Test we get the expected capabilities from a cover trigger."""
|
||||
platform = getattr(hass.components, f"test.{DOMAIN}")
|
||||
|
@ -226,11 +212,11 @@ async def test_get_trigger_capabilities_set_pos(
|
|||
|
||||
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", ent.unique_id, device_id=device_entry.id
|
||||
)
|
||||
|
||||
|
@ -277,7 +263,7 @@ async def test_get_trigger_capabilities_set_pos(
|
|||
|
||||
|
||||
async def test_get_trigger_capabilities_set_tilt_pos(
|
||||
hass, device_reg, entity_reg, enable_custom_integrations
|
||||
hass, device_registry, entity_registry, enable_custom_integrations
|
||||
):
|
||||
"""Test we get the expected capabilities from a cover trigger."""
|
||||
platform = getattr(hass.components, f"test.{DOMAIN}")
|
||||
|
@ -288,11 +274,11 @@ async def test_get_trigger_capabilities_set_tilt_pos(
|
|||
|
||||
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", ent.unique_id, device_id=device_entry.id
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue