Skip to content

Commit a56f6cb

Browse files
authored
Assert Axis config entry state not hass.data (home-assistant#86648)
1 parent 7d672b4 commit a56f6cb

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

tests/components/axis/test_init.py

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,12 @@
44
import pytest
55

66
from homeassistant.components import axis
7-
from homeassistant.components.axis.const import DOMAIN as AXIS_DOMAIN
8-
from homeassistant.setup import async_setup_component
9-
10-
11-
async def test_setup_no_config(hass):
12-
"""Test setup without configuration."""
13-
assert await async_setup_component(hass, AXIS_DOMAIN, {})
14-
assert AXIS_DOMAIN not in hass.data
7+
from homeassistant.config_entries import ConfigEntryState
158

169

1710
async def test_setup_entry(hass, setup_config_entry):
1811
"""Test successful setup of entry."""
19-
assert len(hass.data[AXIS_DOMAIN]) == 1
20-
assert setup_config_entry.entry_id in hass.data[AXIS_DOMAIN]
12+
assert setup_config_entry.state == ConfigEntryState.LOADED
2113

2214

2315
async def test_setup_entry_fails(hass, config_entry):
@@ -30,15 +22,15 @@ async def test_setup_entry_fails(hass, config_entry):
3022

3123
assert not await hass.config_entries.async_setup(config_entry.entry_id)
3224

33-
assert not hass.data[AXIS_DOMAIN]
25+
assert config_entry.state == ConfigEntryState.SETUP_ERROR
3426

3527

3628
async def test_unload_entry(hass, setup_config_entry):
3729
"""Test successful unload of entry."""
38-
assert hass.data[AXIS_DOMAIN]
30+
assert setup_config_entry.state == ConfigEntryState.LOADED
3931

4032
assert await hass.config_entries.async_unload(setup_config_entry.entry_id)
41-
assert not hass.data[AXIS_DOMAIN]
33+
assert setup_config_entry.state == ConfigEntryState.NOT_LOADED
4234

4335

4436
@pytest.mark.parametrize("config_entry_version", [1])
@@ -52,12 +44,8 @@ async def test_migrate_entry(hass, config_entry):
5244
mock_device.api.vapix.light_control = None
5345
mock_device.api.vapix.params.image_format = None
5446

55-
with patch.object(axis, "get_axis_device"), patch.object(
56-
axis, "AxisNetworkDevice"
57-
) as mock_device_class:
58-
mock_device_class.return_value = mock_device
59-
47+
with patch("homeassistant.components.axis.async_setup_entry", return_value=True):
6048
assert await hass.config_entries.async_setup(config_entry.entry_id)
6149

62-
assert hass.data[AXIS_DOMAIN]
50+
assert config_entry.state == ConfigEntryState.LOADED
6351
assert config_entry.version == 3

0 commit comments

Comments
 (0)