Axis - Use core to start component tests (#31328)
* Fix test according to Martins comment in 31286 * Use core features rather than integration specific * Fix populate options test
This commit is contained in:
parent
958a867c11
commit
44f0728c60
1 changed files with 9 additions and 13 deletions
|
@ -4,7 +4,7 @@ from unittest.mock import Mock, patch
|
|||
from homeassistant.components import axis
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from .test_device import ENTRY_CONFIG, MAC, setup_axis_integration
|
||||
from .test_device import MAC, setup_axis_integration
|
||||
|
||||
from tests.common import MockConfigEntry, mock_coro
|
||||
|
||||
|
@ -37,9 +37,10 @@ async def test_setup_entry(hass):
|
|||
|
||||
async def test_setup_entry_fails(hass):
|
||||
"""Test successful setup of entry."""
|
||||
entry = MockConfigEntry(
|
||||
domain=axis.DOMAIN, data={axis.CONF_MAC: "0123"}, options=True
|
||||
config_entry = MockConfigEntry(
|
||||
domain=axis.DOMAIN, data={axis.CONF_MAC: "0123"}, options=True, version=2
|
||||
)
|
||||
config_entry.add_to_hass(hass)
|
||||
|
||||
mock_device = Mock()
|
||||
mock_device.async_setup.return_value = mock_coro(False)
|
||||
|
@ -47,7 +48,7 @@ async def test_setup_entry_fails(hass):
|
|||
with patch.object(axis, "AxisNetworkDevice") as mock_device_class:
|
||||
mock_device_class.return_value = mock_device
|
||||
|
||||
assert not await axis.async_setup_entry(hass, entry)
|
||||
assert not await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
|
||||
assert not hass.data[axis.DOMAIN]
|
||||
|
||||
|
@ -57,20 +58,15 @@ async def test_unload_entry(hass):
|
|||
device = await setup_axis_integration(hass)
|
||||
assert hass.data[axis.DOMAIN]
|
||||
|
||||
assert await axis.async_unload_entry(hass, device.config_entry)
|
||||
assert await hass.config_entries.async_unload(device.config_entry.entry_id)
|
||||
assert not hass.data[axis.DOMAIN]
|
||||
|
||||
|
||||
async def test_populate_options(hass):
|
||||
"""Test successful populate options."""
|
||||
entry = MockConfigEntry(domain=axis.DOMAIN, data=ENTRY_CONFIG)
|
||||
entry.add_to_hass(hass)
|
||||
device = await setup_axis_integration(hass, options=None)
|
||||
|
||||
with patch.object(axis, "get_device", return_value=mock_coro(Mock())):
|
||||
|
||||
await axis.async_populate_options(hass, entry)
|
||||
|
||||
assert entry.options == {
|
||||
assert device.config_entry.options == {
|
||||
axis.CONF_CAMERA: True,
|
||||
axis.CONF_EVENTS: True,
|
||||
axis.CONF_TRIGGER_TIME: axis.DEFAULT_TRIGGER_TIME,
|
||||
|
@ -95,7 +91,7 @@ async def test_migrate_entry(hass):
|
|||
assert entry.data == legacy_config
|
||||
assert entry.version == 1
|
||||
|
||||
await axis.async_migrate_entry(hass, entry)
|
||||
await entry.async_migrate(hass)
|
||||
|
||||
assert entry.data == {
|
||||
axis.CONF_DEVICE: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue