Exemplo n.º 1
0
def mock_area_registry(hass, mock_entries=None):
    """Mock the Area Registry."""
    registry = area_registry.AreaRegistry(hass)
    registry.areas = mock_entries or OrderedDict()

    hass.data[area_registry.DATA_REGISTRY] = registry
    return registry
Exemplo n.º 2
0
def mock_area_registry(hass, mock_entries=None):
    """Mock the Area Registry."""
    registry = area_registry.AreaRegistry(hass)
    registry.areas = mock_entries or OrderedDict()

    async def _get_reg():
        return registry

    hass.data[area_registry.DATA_REGISTRY] = \
        hass.loop.create_task(_get_reg())
    return registry
Exemplo n.º 3
0
async def test_load_area(hass, registry):
    """Make sure that we can load/save data correctly."""
    registry.async_create("mock1")
    registry.async_create("mock2")

    assert len(registry.areas) == 2

    registry2 = area_registry.AreaRegistry(hass)
    await flush_store(registry._store)
    await registry2.async_load()

    assert list(registry.areas) == list(registry2.areas)