Use fixtures to setup Axis integration in tests (#86034)

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
Robert Svensson 2023-01-22 17:33:40 +01:00 committed by GitHub
parent 8e117ee499
commit 332d3e0f19
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 491 additions and 485 deletions

View file

@ -7,8 +7,6 @@ from homeassistant.components import axis
from homeassistant.components.axis.const import DOMAIN as AXIS_DOMAIN
from homeassistant.setup import async_setup_component
from .test_device import setup_axis_integration
async def test_setup_no_config(hass):
"""Test setup without configuration."""
@ -16,11 +14,10 @@ async def test_setup_no_config(hass):
assert AXIS_DOMAIN not in hass.data
async def test_setup_entry(hass, config_entry):
async def test_setup_entry(hass, setup_config_entry):
"""Test successful setup of entry."""
await setup_axis_integration(hass, config_entry)
assert len(hass.data[AXIS_DOMAIN]) == 1
assert config_entry.entry_id in hass.data[AXIS_DOMAIN]
assert setup_config_entry.entry_id in hass.data[AXIS_DOMAIN]
async def test_setup_entry_fails(hass, config_entry):
@ -36,12 +33,11 @@ async def test_setup_entry_fails(hass, config_entry):
assert not hass.data[AXIS_DOMAIN]
async def test_unload_entry(hass, config_entry):
async def test_unload_entry(hass, setup_config_entry):
"""Test successful unload of entry."""
await setup_axis_integration(hass, config_entry)
assert hass.data[AXIS_DOMAIN]
assert await hass.config_entries.async_unload(config_entry.entry_id)
assert await hass.config_entries.async_unload(setup_config_entry.entry_id)
assert not hass.data[AXIS_DOMAIN]