Files
houseplan-card/tests_backend/test_ha_setup.py
T

37 lines
1.2 KiB
Python

"""Entry setup/unload tests (CI)."""
import pytest
@pytest.fixture(autouse=True)
def _enable_custom_integrations(enable_custom_integrations):
"""Allow loading custom_components in the test hass."""
yield
from homeassistant.core import HomeAssistant
from pytest_homeassistant_custom_component.common import MockConfigEntry
from custom_components.houseplan.const import DOMAIN
async def _setup(hass: HomeAssistant) -> MockConfigEntry:
entry = MockConfigEntry(domain=DOMAIN, title="House Plan", data={}, options={})
entry.add_to_hass(hass)
assert await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
return entry
async def test_setup_creates_runtime_data(hass: HomeAssistant) -> None:
entry = await _setup(hass)
assert entry.state.value == "loaded"
assert entry.runtime_data is not None
assert entry.runtime_data.store is not None
assert entry.runtime_data.config_store is not None
async def test_unload(hass: HomeAssistant) -> None:
entry = await _setup(hass)
assert await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done()
assert entry.state.value == "not_loaded"