4
4
import pytest
5
5
6
6
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
15
8
16
9
17
10
async def test_setup_entry (hass , setup_config_entry ):
18
11
"""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
21
13
22
14
23
15
async def test_setup_entry_fails (hass , config_entry ):
@@ -30,15 +22,15 @@ async def test_setup_entry_fails(hass, config_entry):
30
22
31
23
assert not await hass .config_entries .async_setup (config_entry .entry_id )
32
24
33
- assert not hass . data [ AXIS_DOMAIN ]
25
+ assert config_entry . state == ConfigEntryState . SETUP_ERROR
34
26
35
27
36
28
async def test_unload_entry (hass , setup_config_entry ):
37
29
"""Test successful unload of entry."""
38
- assert hass . data [ AXIS_DOMAIN ]
30
+ assert setup_config_entry . state == ConfigEntryState . LOADED
39
31
40
32
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
42
34
43
35
44
36
@pytest .mark .parametrize ("config_entry_version" , [1 ])
@@ -52,12 +44,8 @@ async def test_migrate_entry(hass, config_entry):
52
44
mock_device .api .vapix .light_control = None
53
45
mock_device .api .vapix .params .image_format = None
54
46
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 ):
60
48
assert await hass .config_entries .async_setup (config_entry .entry_id )
61
49
62
- assert hass . data [ AXIS_DOMAIN ]
50
+ assert config_entry . state == ConfigEntryState . LOADED
63
51
assert config_entry .version == 3
0 commit comments