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
|
@ -5,7 +5,7 @@ import voluptuous_serialize
|
|||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.climate import DOMAIN, HVACMode, const, device_condition
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
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
|
||||
|
@ -15,24 +15,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.fixture
|
||||
def calls(hass):
|
||||
"""Track calls to a mock service."""
|
||||
|
@ -60,8 +46,8 @@ def calls(hass):
|
|||
)
|
||||
async def test_get_conditions(
|
||||
hass,
|
||||
device_reg,
|
||||
entity_reg,
|
||||
device_registry,
|
||||
entity_registry,
|
||||
set_state,
|
||||
features_reg,
|
||||
features_state,
|
||||
|
@ -70,11 +56,11 @@ async def test_get_conditions(
|
|||
"""Test we get the expected conditions from a climate."""
|
||||
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",
|
||||
|
@ -114,19 +100,19 @@ async def test_get_conditions(
|
|||
)
|
||||
async def test_get_conditions_hidden_auxiliary(
|
||||
hass,
|
||||
device_reg,
|
||||
entity_reg,
|
||||
device_registry,
|
||||
entity_registry,
|
||||
hidden_by,
|
||||
entity_category,
|
||||
):
|
||||
"""Test we get the expected conditions 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",
|
||||
|
@ -320,8 +306,8 @@ async def test_if_state(hass, calls):
|
|||
)
|
||||
async def test_capabilities(
|
||||
hass,
|
||||
device_reg,
|
||||
entity_reg,
|
||||
device_registry,
|
||||
entity_registry,
|
||||
set_state,
|
||||
capabilities_reg,
|
||||
capabilities_state,
|
||||
|
@ -331,11 +317,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",
|
||||
|
@ -374,9 +360,7 @@ async def test_capabilities(
|
|||
"condition,capability_name",
|
||||
[("is_hvac_mode", "hvac_mode"), ("is_preset_mode", "preset_mode")],
|
||||
)
|
||||
async def test_capabilities_missing_entity(
|
||||
hass, device_reg, entity_reg, condition, capability_name
|
||||
):
|
||||
async def test_capabilities_missing_entity(hass, condition, capability_name):
|
||||
"""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