mirror of
				https://github.com/home-assistant/core.git
				synced 2025-11-04 08:29:37 +00:00 
			
		
		
		
	Clean up unnecessary registry mocks from Core tests (#87726)
This commit is contained in:
		@@ -5,7 +5,7 @@ import homeassistant.components.automation as automation
 | 
			
		||||
from homeassistant.components.device_automation import DeviceAutomationType
 | 
			
		||||
from homeassistant.components.fan import DOMAIN
 | 
			
		||||
from homeassistant.const import STATE_OFF, STATE_ON
 | 
			
		||||
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
 | 
			
		||||
@@ -15,39 +15,27 @@ 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."""
 | 
			
		||||
    return async_mock_service(hass, "test", "automation")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
async def test_get_conditions(hass, device_reg, entity_reg):
 | 
			
		||||
async def test_get_conditions(hass, device_registry, entity_registry):
 | 
			
		||||
    """Test we get the expected conditions from a fan."""
 | 
			
		||||
    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_registry.async_get_or_create(
 | 
			
		||||
        DOMAIN, "test", "5678", device_id=device_entry.id
 | 
			
		||||
    )
 | 
			
		||||
    entity_reg.async_get_or_create(DOMAIN, "test", "5678", device_id=device_entry.id)
 | 
			
		||||
    expected_conditions = [
 | 
			
		||||
        {
 | 
			
		||||
            "condition": "device",
 | 
			
		||||
@@ -76,19 +64,19 @@ async def test_get_conditions(hass, device_reg, entity_reg):
 | 
			
		||||
)
 | 
			
		||||
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",
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user