hass-core/tests/components/srp_energy/test_init.py

29 lines
1 KiB
Python
Raw Normal View History

2020-11-20 06:18:02 -07:00
"""Tests for Srp Energy component Init."""
from homeassistant import config_entries
2020-11-20 06:18:02 -07:00
from homeassistant.components import srp_energy
from homeassistant.core import HomeAssistant
2020-11-20 06:18:02 -07:00
from . import init_integration
2020-11-20 06:18:02 -07:00
async def test_setup_entry(hass: HomeAssistant) -> None:
2020-11-20 06:18:02 -07:00
"""Test setup entry fails if deCONZ is not available."""
config_entry = await init_integration(hass)
assert config_entry.state == config_entries.ConfigEntryState.LOADED
2020-11-20 06:18:02 -07:00
assert hass.data[srp_energy.SRP_ENERGY_DOMAIN]
async def test_unload_entry(hass: HomeAssistant) -> None:
2020-11-20 06:18:02 -07:00
"""Test being able to unload an entry."""
config_entry = await init_integration(hass)
assert hass.data[srp_energy.SRP_ENERGY_DOMAIN]
assert await srp_energy.async_unload_entry(hass, config_entry)
assert not hass.data[srp_energy.SRP_ENERGY_DOMAIN]
async def test_async_setup_entry_with_exception(hass: HomeAssistant) -> None:
2020-11-20 06:18:02 -07:00
"""Test exception when SrpClient can't load."""
await init_integration(hass, side_effect=Exception())
assert srp_energy.SRP_ENERGY_DOMAIN not in hass.data