Assert Axis config entry state not hass.data (#86648)
parent
7d672b4a4d
commit
a56f6cb863
|
@ -4,20 +4,12 @@ from unittest.mock import AsyncMock, Mock, patch
|
|||
import pytest
|
||||
|
||||
from homeassistant.components import axis
|
||||
from homeassistant.components.axis.const import DOMAIN as AXIS_DOMAIN
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
|
||||
async def test_setup_no_config(hass):
|
||||
"""Test setup without configuration."""
|
||||
assert await async_setup_component(hass, AXIS_DOMAIN, {})
|
||||
assert AXIS_DOMAIN not in hass.data
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
|
||||
|
||||
async def test_setup_entry(hass, setup_config_entry):
|
||||
"""Test successful setup of entry."""
|
||||
assert len(hass.data[AXIS_DOMAIN]) == 1
|
||||
assert setup_config_entry.entry_id in hass.data[AXIS_DOMAIN]
|
||||
assert setup_config_entry.state == ConfigEntryState.LOADED
|
||||
|
||||
|
||||
async def test_setup_entry_fails(hass, config_entry):
|
||||
|
@ -30,15 +22,15 @@ async def test_setup_entry_fails(hass, config_entry):
|
|||
|
||||
assert not await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
|
||||
assert not hass.data[AXIS_DOMAIN]
|
||||
assert config_entry.state == ConfigEntryState.SETUP_ERROR
|
||||
|
||||
|
||||
async def test_unload_entry(hass, setup_config_entry):
|
||||
"""Test successful unload of entry."""
|
||||
assert hass.data[AXIS_DOMAIN]
|
||||
assert setup_config_entry.state == ConfigEntryState.LOADED
|
||||
|
||||
assert await hass.config_entries.async_unload(setup_config_entry.entry_id)
|
||||
assert not hass.data[AXIS_DOMAIN]
|
||||
assert setup_config_entry.state == ConfigEntryState.NOT_LOADED
|
||||
|
||||
|
||||
@pytest.mark.parametrize("config_entry_version", [1])
|
||||
|
@ -52,12 +44,8 @@ async def test_migrate_entry(hass, config_entry):
|
|||
mock_device.api.vapix.light_control = None
|
||||
mock_device.api.vapix.params.image_format = None
|
||||
|
||||
with patch.object(axis, "get_axis_device"), patch.object(
|
||||
axis, "AxisNetworkDevice"
|
||||
) as mock_device_class:
|
||||
mock_device_class.return_value = mock_device
|
||||
|
||||
with patch("homeassistant.components.axis.async_setup_entry", return_value=True):
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
|
||||
assert hass.data[AXIS_DOMAIN]
|
||||
assert config_entry.state == ConfigEntryState.LOADED
|
||||
assert config_entry.version == 3
|
||||
|
|
Loading…
Reference in New Issue